:root {
  --ink: #172322;
  --muted: #5c6a68;
  --line: #d9e0df;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --brand: #123c3a;
  --brand-strong: #0a2d2b;
  --accent: #e7a93f;
  --success: #167a55;
  --warning: #a36208;
  --danger: #ad3434;
  --info: #276b83;
  --focus: #0b78a0;
  --sidebar-width: 232px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--canvas); color: var(--ink); }

body { margin: 0; min-height: 100vh; }

button, input, select, textarea { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 14px;
  border: 1px solid var(--line);
}

.skip-link:focus { top: 12px; }

.login-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, transparent 49px, rgba(18, 60, 58, .04) 50px),
    linear-gradient(transparent 49px, rgba(18, 60, 58, .04) 50px),
    var(--canvas);
  background-size: 50px 50px;
}

.login-panel {
  width: min(100%, 460px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  padding: 32px;
  box-shadow: 0 18px 50px rgba(22, 40, 38, .1);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { flex: 0 0 auto; }
.brand strong, .brand span { display: block; }
.brand span { color: #b9c9c7; font-size: .82rem; }
.brand-login { margin-bottom: 24px; }
.brand-login h1 { margin: 2px 0 0; font-size: 1.75rem; }

.product-kicker {
  margin: 0;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-intro, .privacy-note { color: var(--muted); line-height: 1.6; }
.auth-switcher { display: flex; gap: 8px; margin: 18px 0; flex-wrap: wrap; }
.auth-switcher .is-active { background: var(--brand); color: white; border-color: var(--brand); }
.privacy-note { font-size: .82rem; margin: 20px 0 0; }
.stack { display: grid; gap: 18px; }
form[hidden] { display: none !important; }
.field { display: grid; gap: 7px; }
.field label { font-size: .86rem; font-weight: 700; }
.password-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.password-toggle { min-width: 68px; min-height: 42px; }

input, select, textarea {
  width: 100%;
  border: 1px solid #b9c5c3;
  border-radius: 4px;
  padding: 10px 11px;
  background: var(--surface);
  color: var(--ink);
}

textarea { min-height: 100px; resize: vertical; }
input:disabled, button:disabled { opacity: .55; cursor: not-allowed; }

.checkbox-row { display: flex; gap: 9px; align-items: center; color: var(--muted); }
.checkbox-row input { width: 17px; height: 17px; }

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 8px 13px;
  font-weight: 700;
  cursor: pointer;
}

.button-primary { background: var(--brand); color: white; }
.button-primary:hover { background: var(--brand-strong); }
.button-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.button-quiet { background: transparent; color: inherit; border-color: var(--line); }
.button-danger { background: var(--danger); color: white; }
.button-small { min-height: 32px; padding: 5px 9px; font-size: .82rem; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  background: var(--brand);
  color: white;
}

.sidebar nav { display: grid; gap: 4px; margin-top: 36px; }
.sidebar nav a {
  color: #dfeae8;
  padding: 10px 12px;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar nav a:hover, .sidebar nav a[aria-current="page"] {
  background: rgba(255, 255, 255, .09);
  border-left-color: var(--accent);
  color: white;
}
.sidebar-footer { margin-top: auto; display: grid; gap: 14px; }
.sidebar-footer .button { border-color: rgba(255,255,255,.25); color: white; }
.connection-state { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); }
.connection-state[data-state="ready"] .status-dot { background: #4dd6a0; }
.connection-state[data-state="offline"] .status-dot { background: #ff8d82; }

.workspace { margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar h1 { margin: 2px 0 0; font-size: 1.45rem; }
.actor-summary { text-align: right; font-size: .84rem; color: var(--muted); }
.actor-summary strong { display: block; color: var(--ink); }

main { padding: 26px 28px 48px; max-width: 1500px; }
.page-actions, .toolbar, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.page-actions { justify-content: space-between; margin-bottom: 20px; }
.section {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}
.section:first-child { border-top: 0; padding-top: 0; }
.section h2 { margin: 0 0 14px; font-size: 1rem; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}
.metric { min-height: 112px; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: .8rem; }
.metric strong { display: block; margin-top: 14px; font-size: 1.35rem; overflow-wrap: anywhere; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px;
}
.panel + .panel { margin-top: 14px; }
.panel-header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.panel h2, .panel h3 { margin-top: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.details {
  display: grid;
  grid-template-columns: minmax(120px, .45fr) minmax(0, 1fr);
  margin: 0;
  gap: 0;
}
.details dt, .details dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); font-size: .8rem; font-weight: 700; }
.details dd { overflow-wrap: anywhere; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.data-table th, .data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.data-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.data-table tbody tr:hover { background: #f7faf9; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8efee;
  color: #334744;
  font-size: .75rem;
  font-weight: 700;
}
.badge-success { background: #dff3ea; color: #0c6041; }
.badge-warning { background: #fff0cf; color: #7b4a04; }
.badge-danger { background: #f9dddd; color: #8a2323; }
.badge-info { background: #deeff5; color: #1e5a70; }

.message { padding: 11px 13px; border-left: 4px solid var(--info); background: #edf6f8; }
.message-error { border-left-color: var(--danger); background: #fff0f0; color: #7d2525; }
.message-success { border-left-color: var(--success); background: #edf8f3; }
.notification-region { padding: 0 28px; }
.notification-region .message { margin-top: 14px; }
.empty-state { padding: 44px 20px; text-align: center; color: var(--muted); border: 1px dashed #b8c5c3; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs a { padding: 10px 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom: 3px solid var(--brand); }

.global-loading {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}

dialog {
  width: min(92vw, 480px);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  color: var(--ink);
}
dialog::backdrop { background: rgba(10, 30, 28, .56); }
.dialog-content { padding: 22px; }
.dialog-content h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 900px) {
  :root { --sidebar-width: 190px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .app-shell { padding-bottom: 64px; }
  .sidebar {
    inset: auto 0 0;
    width: 100%;
    height: 62px;
    z-index: 20;
    padding: 6px 10px;
    flex-direction: row;
    align-items: center;
  }
  .sidebar .brand, .sidebar-footer { display: none; }
  .sidebar nav { margin: 0; width: 100%; display: flex; justify-content: space-around; }
  .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 10px; }
  .sidebar nav a[aria-current="page"] { border-left: 0; border-bottom-color: var(--accent); }
  .workspace { margin-left: 0; }
  .topbar { padding: 15px 18px; align-items: start; }
  .actor-summary { max-width: 42%; }
  main { padding: 20px 16px 90px; }
  .notification-region { padding: 0 16px; }
  .metrics, .form-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line); margin-bottom: 12px; background: var(--surface); }
  .data-table td { border: 0; padding: 8px 12px; }
  .data-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
