.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  background: var(--bg);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-tint);
}

textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

input[readonly] {
  background: var(--surface);
  color: var(--muted);
}

.hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--brand);
  flex: none;
}

/* Range slider */
input[type="range"] {
  width: 100%;
  height: 44px;
  accent-color: var(--brand);
}

output {
  font-weight: 700;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

/* Buttons - 44px minimum touch target throughout */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.button--ghost {
  border-color: transparent;
  background: transparent;
}

.button--ghost:hover:not(:disabled) {
  background: var(--surface-sunken);
  border-color: transparent;
  color: var(--brand-dark);
}

/* Inside the brand bar the buttons sit on red, so they invert. */
.topbar .button {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: transparent;
}

.topbar .button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.75);
  color: #fff;
}

.button--block {
  width: 100%;
}

/* Destructive actions read as such, but stay quiet until hovered so they do
   not compete with the primary flow. */
.button--danger {
  border-color: transparent;
  background: transparent;
  color: var(--danger);
}

.button--danger:hover:not(:disabled) {
  background: var(--danger-tint);
  border-color: var(--danger);
  color: var(--danger);
}

/* Upload form */
.upload-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 24px;
  align-items: end;
}

.upload-form .field:first-child {
  grid-column: 1 / -1;
}

.upload-form button {
  margin-bottom: 18px;
}

/* Search form */
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.search-form input[type="search"] {
  flex: 2 1 200px;
  width: auto;
}

.search-form select,
.search-form input[type="number"] {
  flex: 1 1 130px;
  width: auto;
}

.filter {
  width: auto;
  min-width: 180px;
}

@media (max-width: 768px) {
  .upload-form {
    grid-template-columns: 1fr;
  }

  .search-form > * {
    flex: 1 1 100%;
  }

  .filter {
    min-width: 0;
    flex: 1;
  }

  .list-header__actions {
    width: 100%;
    margin-left: 0;
  }
}

/* Keep a row's action buttons on one line and give them a little breathing
   room between each other. */
.table--catalog td.nowrap {
  white-space: nowrap;
}

.table--catalog td.nowrap .button + .button {
  margin-left: 0.35rem;
}

/* The "Look up" result banner in the catalogue editor. Shown once per lookup,
   above the form; carries the AI suggestion's confidence plus links to verify
   against SPECpower and the vendor datasheet. */
.lookup-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface);
}

.lookup-banner--found {
  border-left-color: var(--brand);
  background: var(--brand-tint);
}

.lookup-banner--empty {
  border-left-color: var(--border-strong);
  background: var(--surface-sunken);
}

.lookup-banner p {
  margin: 0.15rem 0;
}

.lookup-banner__links {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem !important;
  font-size: 0.9rem;
}

/* The estate trend chart in the history modal needs an explicit height, since
   its canvas is not inside the dashboard's .chart__canvas box. */
.chart-box--trend {
  position: relative;
  height: 260px;
  margin: 0 0 1.25rem;
}

.chart-box--trend canvas {
  max-height: 260px;
}

/* Time-travel drill-down inside a snapshot: breadcrumb + clickable rows. */
.history-crumbs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.crumb-trail {
  color: var(--muted);
  font-size: 0.95rem;
}

.link-crumb {
  border: none;
  background: none;
  padding: 0;
  color: var(--brand-dark);
  cursor: pointer;
  font: inherit;
}

.link-crumb:hover {
  text-decoration: underline;
}

.crumb-sep {
  color: var(--border-strong);
  margin: 0 0.15rem;
}

tr.row--clickable {
  cursor: pointer;
}

tr.row--clickable:hover {
  background: var(--surface-sunken);
}

tr.row--clickable small {
  font-weight: 400;
  margin-left: 0.5rem;
  opacity: 0;
}

tr.row--clickable:hover small {
  opacity: 1;
}

/* Device-count / energy-by-type table in the details panel. */
.table--types {
  margin-top: 0.5rem;
}

.table--types .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table--types th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table--types th.sortable:hover {
  color: var(--brand-dark);
}

.table--types th.sortable:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.table--types th.sorted {
  color: var(--brand-dark);
}

/* Include/exclude mode chooser in the site-filter modal. */
.filter-mode {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
}

.filter-mode legend {
  padding: 0 0.4rem;
  font-weight: 600;
  color: var(--muted);
}

.filter-mode .check + .check {
  margin-top: 0.4rem;
}

/* Inline PUE editor on a data centre's details panel. */
.dc-pue {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  background: var(--surface);
}

.dc-pue input[type="number"] {
  width: 7rem;
}

.dc-pue .hint {
  flex-basis: 100%;
  margin: 0.25rem 0 0;
}

.dcpue-input {
  width: 6rem;
}

/* Stockroom badge + override on a floor/room details panel. */
.stockroom-control {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid #a97400;
  border-radius: var(--radius);
  background: var(--surface);
}

.stockroom-control__actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.stockroom-control .hint {
  margin: 0.35rem 0 0;
}

.chip--warn {
  border-color: #a97400;
  color: #a97400;
}

.table--types tfoot th,
.table--types tfoot td {
  border-top: 2px solid var(--border-strong);
  font-weight: 600;
}
