:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --panel: #fffdf8;
  --border: #d8d1c6;
  --text: #1f2523;
  --muted: #67716c;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --accent-soft: #d9efeb;
  --danger: #b42318;
  --danger-soft: #fde4df;
  --warning: #936314;
  --shadow: 0 18px 60px rgba(41, 37, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI Variable", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 18px;
}

.topbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 104px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.panel {
  padding: 22px;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.topbar-actions,
.section-heading,
.device-actions,
.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-heading {
  justify-content: space-between;
  margin-bottom: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 760;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.button:hover {
  background: var(--accent-strong);
}

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

.button.ghost {
  color: var(--text);
  border-color: var(--border);
  background: #fff;
}

.button.danger {
  color: var(--danger);
  border-color: #efb5ad;
  background: var(--danger-soft);
}

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.badge {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 750;
}

.badge.soft {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #abd8d1;
}

.badge.warning {
  color: var(--warning);
  background: #fff2cf;
  border-color: #e8c56f;
}

.login-panel {
  max-width: 480px;
}

.login-form,
.password-form {
  display: grid;
  gap: 14px;
}

.password-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.message {
  min-height: 24px;
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.settings-panel {
  grid-column: 1 / -1;
}

.approved-panel {
  display: flex;
  flex-direction: column;
  max-height: min(720px, calc(100vh - 190px));
  min-height: 0;
}

.approved-panel .section-heading {
  flex: 0 0 auto;
}

.approved-panel .device-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.device-list {
  display: grid;
  gap: 12px;
}

.device-card {
  border: 1px solid var(--border);
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 12px;
  min-width: 0;
}

.compact .device-card {
  gap: 8px;
}

.device-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: flex-start;
  gap: 12px;
}

.device-name {
  font-size: 17px;
  font-weight: 820;
  overflow-wrap: anywhere;
}

.device-platform,
.device-meta,
.empty-state {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.meta-row {
  flex-wrap: wrap;
}

.mini-pill {
  padding: 4px 8px;
  background: #f2eee7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.device-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  min-height: 34px;
}

.toast-rack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 10;
}

.toast {
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: #22312d;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 820px) {
  .admin-shell {
    width: min(100% - 20px, 1180px);
    margin-top: 10px;
  }

  .topbar,
  .device-top,
  .dashboard-grid,
  .password-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .device-actions {
    justify-content: start;
  }

  .approved-panel {
    max-height: min(620px, 70vh);
  }
}
