:root {
  --canvas: #f8f6f0;
  --surface: #fffefb;
  --surface-soft: #f1eee6;
  --surface-strong: #e9e5da;
  --ink: #1c1c1f;
  --muted: #6f6d72;
  --line: #e4dfd4;
  --line-strong: #cbc4b7;
  --accent: #f8be2b;
  --accent-hover: #ffd363;
  --accent-soft: #fff0c2;
  --accent-ink: #5f4305;
  --success: #247a52;
  --success-soft: #def4e7;
  --warning: #8b6309;
  --warning-soft: #fff0c2;
  --danger: #b23c48;
  --danger-soft: #fbe4e6;
  --info: #2e73b5;
  --info-soft: #e1effb;
  --shadow-sm: 0 8px 22px rgba(34, 31, 24, 0.06);
  --shadow-lg: 0 26px 75px rgba(32, 28, 20, 0.14);
  color: var(--ink);
  background: var(--canvas);
  font-family: Manrope, Aptos, "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  --canvas: #121214;
  --surface: #19191c;
  --surface-soft: #202024;
  --surface-strong: #29292e;
  --ink: #f6f3eb;
  --muted: #aaa8af;
  --line: #2d2d32;
  --line-strong: #424249;
  --accent: #f8be2b;
  --accent-hover: #ffd363;
  --accent-soft: #372d14;
  --accent-ink: #f8be2b;
  --success: #47c486;
  --success-soft: #143426;
  --warning: #f8be2b;
  --warning-soft: #372d14;
  --danger: #ee7680;
  --danger-soft: #412329;
  --info: #69aef0;
  --info-soft: #182d43;
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; min-height: 100%; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 8%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 27rem),
    radial-gradient(circle at 92% 91%, color-mix(in srgb, var(--info) 7%, transparent), transparent 24rem),
    var(--canvas);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 2px;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 26rem;
  height: 26rem;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(70px);
  opacity: 0.12;
}
.ambient-one { top: -12rem; left: -9rem; background: var(--accent); }
.ambient-two { right: -13rem; bottom: -15rem; background: var(--info); }

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
}
.login-card {
  width: min(100%, 470px);
  padding: clamp(30px, 6vw, 48px);
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #251b04;
  font-size: 18px;
  font-weight: 850;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -0.02em; }
.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.brand-login { margin-bottom: 46px; }
.login-copy { margin-bottom: 28px; }
.login-copy h1 {
  margin: 7px 0 10px;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}
.login-copy > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}
.eyebrow {
  margin: 0;
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 820;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.stack-form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field textarea { min-height: 94px; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-strong); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 13%, transparent);
  outline: 0;
}
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field-full { grid-column: 1 / -1; }
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
}
.checkbox-field input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}
.button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 790;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: #261d07; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button-secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}
.button-secondary:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-soft); }
.button-danger { border-color: color-mix(in srgb, var(--danger) 25%, var(--line)); background: var(--danger-soft); color: var(--danger); }
.button-quiet { border: 0; background: transparent; color: var(--muted); }
.button-wide { width: 100%; min-height: 46px; margin-top: 2px; }
.button-small { min-height: 31px; padding: 0 10px; border-radius: 7px; font-size: 11px; }
.security-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}
.security-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.control-shell { display: grid; min-height: 100vh; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 26px 18px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px);
}
.sidebar > .brand { padding: 0 9px; }
.side-nav {
  display: grid;
  gap: 4px;
  margin-top: 38px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.nav-group-label {
  margin: 20px 10px 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 820;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.nav-group-label:first-child { margin-top: 0; }
.side-nav-button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 730;
  text-align: left;
}
.side-nav-button:hover { background: var(--surface-soft); color: var(--ink); }
.side-nav-button.is-active {
  border-color: color-mix(in srgb, var(--accent) 26%, var(--line));
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.nav-glyph {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, currentColor 8%, transparent);
  font-size: 12px;
  font-weight: 850;
}
.sidebar-footer { display: grid; gap: 10px; margin-top: auto; }
.theme-toggle {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 730;
}
.theme-toggle:hover { background: var(--surface-soft); color: var(--ink); }
.theme-icon { font-size: 16px; }
.account-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.account-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}
.account-copy { min-width: 0; }
.account-copy strong, .account-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-copy strong { font-size: 11px; }
.account-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.icon-button {
  display: grid;
  width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.icon-button:hover { background: var(--surface-soft); color: var(--ink); }

.workspace { min-width: 0; padding: 30px clamp(22px, 4vw, 58px) 60px; }
.workspace-header {
  display: flex;
  min-height: 84px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.workspace-header h1 {
  margin: 6px 0 6px;
  font-size: clamp(27px, 4vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}
.workspace-header p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.live-state {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: var(--success);
  font-size: 10px;
  font-weight: 770;
}
.live-state > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}
.view-content { min-width: 0; }
.loading-state, .empty-state, .error-state {
  display: grid;
  min-height: 300px;
  padding: 30px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  color: var(--muted);
  text-align: center;
}
.loading-pulse {
  width: 38px;
  height: 38px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card, .panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.metric-card { min-height: 142px; padding: 18px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.metric-label { color: var(--muted); font-size: 10px; font-weight: 760; letter-spacing: 0.04em; }
.metric-glyph {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.metric-value { display: block; margin-top: 24px; font-size: 30px; line-height: 1; letter-spacing: -0.045em; }
.metric-note { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr); gap: 14px; margin-top: 14px; }
.panel { min-width: 0; overflow: hidden; }
.panel-header {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-header h2 { margin: 0; font-size: 13px; letter-spacing: -0.01em; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 18px; }
.health-list { display: grid; gap: 10px; }
.health-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--surface-soft);
}
.health-item strong { font-size: 11px; }
.health-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 13px;
}
.search-box { position: relative; width: min(100%, 320px); }
.search-box input {
  width: 100%;
  min-height: 39px;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
}
.search-box::before {
  position: absolute;
  top: 50%;
  left: 13px;
  color: var(--muted);
  content: "⌕";
  font-size: 15px;
  transform: translateY(-52%);
}
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}
.data-table td {
  max-width: 330px;
  padding: 13px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--surface-soft) 74%, transparent); }
.table-primary { display: block; color: var(--ink); font-weight: 760; }
.table-secondary { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.align-right { text-align: right !important; }
.status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 820;
}
.status::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status-success { background: var(--success-soft); color: var(--success); }
.status-warning { background: var(--warning-soft); color: var(--warning); }
.status-danger { background: var(--danger-soft); color: var(--danger); }
.status-muted { background: var(--surface-soft); color: var(--muted); }
.status-info { background: var(--info-soft); color: var(--info); }
.mono { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; font-size: 10px; }

.permission-grid { display: grid; gap: 8px; }
.permission-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(210px, 1.2fr);
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.permission-row strong { font-size: 11px; }
.permission-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid;
  min-height: 29px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 760;
}
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent-ink); }

.audit-list { display: grid; }
.audit-item {
  display: grid;
  grid-template-columns: 38px minmax(180px, 1fr) minmax(120px, 0.5fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.audit-item:last-child { border-bottom: 0; }
.audit-glyph {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}
.audit-item strong { font-size: 11px; }
.audit-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

.modal {
  width: min(calc(100% - 28px), 680px);
  max-height: min(88vh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(15, 15, 17, 0.58); backdrop-filter: blur(5px); }
.modal-card { display: grid; max-height: inherit; grid-template-rows: auto minmax(0, 1fr); }
.modal-card-compact { max-width: 540px; margin: auto; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 6px 0 4px; font-size: 20px; letter-spacing: -0.025em; }
.modal-header p:last-child { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.modal-close {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  padding: 0 0 2px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
}
.modal-close:hover { border-color: var(--line-strong); color: var(--ink); }
.modal-body { overflow-y: auto; padding: 22px 24px 24px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; padding-top: 15px; border-top: 1px solid var(--line); }
.secret-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 16px;
}
.secret-value code, .totp-secret {
  display: block;
  padding: 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
}
.setup-step { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; align-items: start; }
.setup-step > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #261d07;
  font-size: 11px;
  font-weight: 850;
}
.setup-step strong { display: block; margin: 3px 0 8px; font-size: 11px; }

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(calc(100% - 36px), 360px);
  gap: 8px;
}
.toast {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.45;
  animation: toast-in 180ms ease-out;
}
.toast-error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .control-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    z-index: 10;
    width: 100%;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar > .brand { display: none; }
  .side-nav {
    display: flex;
    margin: 0;
    overflow-x: auto;
    gap: 5px;
  }
  .nav-group-label, .sidebar-footer { display: none; }
  .side-nav-button { width: auto; min-width: max-content; min-height: 36px; padding: 0 10px; }
  .nav-glyph { display: none; }
  .workspace { padding: 24px 16px 44px; }
  .workspace-header { display: grid; }
  .header-actions { justify-content: flex-start; }
}

@media (max-width: 580px) {
  .login-card { padding: 28px 22px; border-radius: 18px; }
  .metrics-grid, .field-grid { grid-template-columns: 1fr; }
  .permission-row { grid-template-columns: 1fr; }
  .workspace-header { margin-bottom: 20px; }
  .workspace-header h1 { font-size: 28px; }
  .live-state { display: none; }
  .modal-header, .modal-body { padding-right: 18px; padding-left: 18px; }
  .secret-value { grid-template-columns: 1fr; }
  .audit-item { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .audit-item > :nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; }
}
