/* Neumorphism — DESIGN.md
   Soft, extruded UI on monochromatic surface (#E7E5E4) with paired shadows. */
*{box-sizing:border-box;margin:0;padding:0}

:root{
  color-scheme: light dark;

  --c-primary:    #006666;
  --c-primary-h:  #00807d;
  --c-secondary:  #F1F2F5;
  --c-success:    #00A63D;
  --c-warning:    #FE9900;
  --c-danger:     #FF2157;
  --c-danger-h:   #d61b4a;
  --c-surface:    #E7E5E4;
  --c-thumb:      #ffffff;
  --c-text:       #1E2938;
  --c-text-muted: #6B7280;

  /* Shadows derived from surface: darker + brighter. */
  --sh-dark:   #b8b5b4;
  --sh-light:  #ffffff;

  --sh-out-sm:  4px 4px 8px var(--sh-dark), -4px -4px 8px var(--sh-light);
  --sh-out-md:  6px 6px 14px var(--sh-dark), -6px -6px 14px var(--sh-light);
  --sh-out-lg:  10px 10px 24px var(--sh-dark), -10px -10px 24px var(--sh-light);
  --sh-in-sm:   inset 3px 3px 6px var(--sh-dark), inset -3px -3px 6px var(--sh-light);
  --sh-in-md:   inset 5px 5px 10px var(--sh-dark), inset -5px -5px 10px var(--sh-light);
  --sh-in-lg:   inset 8px 8px 16px var(--sh-dark), inset -8px -8px 16px var(--sh-light);

  --r-sm: 4px;
  --r-md: 8px;
  --r-pill: 999px;
  --easing: cubic-bezier(0.22, 1, 0.36, 1);

  --f-body: "Space Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --f-display: "Space Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --f-mono: "JetBrains Mono", "Space Mono", ui-monospace, Menlo, monospace;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px;
}

/* Dark mode — applied by inline head script via data-theme="dark" */
:root[data-theme="dark"] {
  --c-surface:    #2a2d31;
  --c-thumb:      #3b3f44;
  --c-text:       #E5E7EB;
  --c-text-muted: #9CA3AF;
  --c-primary:    #4FD1C5;
  --c-primary-h:  #6EE7DC;
  --c-danger:     #F87171;
  --c-danger-h:   #EF4444;
  --c-warning:    #FBBF24;
  --c-success:    #4ADE80;
  --sh-dark:   #1a1c20;
  --sh-light:  #3a3e44;
}

body{
  font-family: var(--f-body);
  background: var(--c-surface); color: var(--c-text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--f-display); color: var(--c-text);
  line-height: 1.2; letter-spacing: -0.01em;
}
h1{ font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
h2{ font-size: 1.15rem; font-weight: 700; margin-bottom: 12px; }
h3{
  font-family: var(--f-mono);
  font-size: .75rem; font-weight: 700; color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}

a { color: var(--c-primary); text-decoration: none; font-weight: 500; }
a:hover { color: var(--c-primary-h); }

code, pre { font-family: var(--f-mono); font-size: .82rem; }
pre {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-in-sm);
  padding: 14px 16px;
  overflow-x: auto; line-height: 1.5;
}

/* App shell */
.app {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
  gap: var(--s-5);
  padding: var(--s-5);
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; padding: var(--s-3); gap: var(--s-3); }
}

.sidebar {
  display: flex; flex-direction: column;
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-md);
  padding: 18px 14px;
  position: sticky; top: var(--s-5);
  height: calc(100vh - var(--s-5) * 2);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 6px 18px;
  margin-bottom: 14px;
  border-bottom: 0;
  position: relative;
}
.brand::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--sh-dark), transparent);
}
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: #000; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--sh-out-sm);
  object-fit: contain;
}
img.brand-mark { padding: 2px; }
.brand-title { font-size: 1rem; font-weight: 700; font-family: var(--f-display); }

.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-md);
  background: transparent; border: none;
  color: var(--c-text-muted); font: inherit; font-size: .87rem; font-weight: 500;
  cursor: pointer; text-align: left; width: 100%;
  text-decoration: none;
  transition: color .18s var(--easing), box-shadow .18s var(--easing);
}
.nav-item:hover { color: var(--c-text); }
.nav-item.active {
  color: var(--c-primary);
  box-shadow: var(--sh-in-sm);
  font-weight: 700;
}

.prefs {
  display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap;
}
.seg {
  display: inline-flex; background: var(--c-surface);
  border-radius: var(--r-pill); padding: 3px;
  box-shadow: var(--sh-in-sm);
  margin: 0;
}
.seg-btn {
  background: transparent; border: none; box-shadow: none;
  padding: 4px 10px; border-radius: var(--r-pill);
  color: var(--c-text-muted); font: inherit; font-size: .72rem; font-weight: 700;
  font-family: var(--f-mono); cursor: pointer; letter-spacing: .04em;
  transition: color .2s var(--easing);
}
.seg-btn:hover { color: var(--c-text); }
.seg-btn.on {
  color: var(--c-primary);
  background: var(--c-thumb);
  box-shadow:
    0 1px 2px rgba(0,0,0,.06),
    0 2px 6px rgba(0,0,0,.08);
}
:root[data-theme="dark"] .seg-btn.on {
  box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.35);
}

.sidebar-foot { margin-top: auto; padding-top: 12px; position: relative; }
.sidebar-foot::before {
  content: ""; position: absolute; left: 6px; right: 6px; top: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--sh-dark), transparent);
}
.logout-form { margin: 0; }
.logout-btn {
  width: 100%; padding: 9px 12px; border-radius: var(--r-md);
  background: var(--c-surface); border: none;
  color: var(--c-text-muted); font: inherit; font-size: .82rem; font-weight: 500;
  cursor: pointer; text-align: center;
  box-shadow: var(--sh-out-sm);
  transition: box-shadow .18s var(--easing), color .18s var(--easing);
}
.logout-btn:hover { color: var(--c-danger); }
.logout-btn:active { box-shadow: var(--sh-in-sm); }

/* Main content */
.main { padding: var(--s-3) var(--s-4) var(--s-6); max-width: 1100px; }
.view-head {
  margin-bottom: 36px;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
}
.view-head > div:first-child { flex: 1; }
.view-sub { font-size: .85rem; color: var(--c-text-muted); margin-top: 4px; }

.muted { color: var(--c-text-muted); font-size: .85rem; }
.ok { color: var(--c-success); font-weight: 700; }
.bad { color: var(--c-danger); font-weight: 700; }

.panel { margin-bottom: 40px; }

/* Stat cards — extruded */
.stats {
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 40px;
}
.stat {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-md);
  padding: 16px 18px;
}
.stat-label {
  font-family: var(--f-mono); font-size: .68rem;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--c-text-muted); margin-bottom: 8px;
}
.stat-value {
  font-family: var(--f-display); font-size: 1.9rem; font-weight: 700;
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  color: var(--c-primary);
}

/* Tabs — premium sliding thumb */
.tabs {
  position: relative;
  display: inline-flex; background: var(--c-surface);
  border-radius: var(--r-pill); padding: 6px;
  box-shadow: var(--sh-in-sm);
}
.tab {
  position: relative; z-index: 1;
  padding: 9px 22px; border-radius: var(--r-pill);
  background: transparent; border: none;
  box-shadow: none;
  color: var(--c-text-muted); font-size: .85rem; font-weight: 500;
  text-decoration: none; font-family: var(--f-body); cursor: pointer;
  transition: color .35s cubic-bezier(0.32, 0.72, 0, 1);
}
.tab:hover:not(.active) { color: var(--c-text); }
.tab:active { box-shadow: none; transform: scale(.98); }
.tab.active { color: var(--c-primary); font-weight: 700; }
.tab-thumb {
  position: absolute; top: 6px; bottom: 6px; left: 0;
  width: 0; pointer-events: none;
  background: var(--c-thumb);
  border-radius: var(--r-pill);
  box-shadow:
    0 1px 2px rgba(0,0,0,.06),
    0 4px 12px rgba(0,0,0,.08),
    inset 0 1px 0 rgba(255,255,255,.6);
  transform: translate3d(0,0,0);
  will-change: transform, width;
  transition:
    transform .42s cubic-bezier(0.32, 0.72, 0, 1),
    width     .42s cubic-bezier(0.32, 0.72, 0, 1);
}
:root[data-theme="dark"] .tab-thumb {
  box-shadow:
    0 1px 2px rgba(0,0,0,.4),
    0 6px 16px rgba(0,0,0,.45),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.tabs-no-anim .tab-thumb { transition: none !important; }

.row { display: flex; gap: var(--s-3); align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }

/* Tables — panel with inset */
table.data {
  width: 100%; border-collapse: collapse;
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-sm);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: 12px 16px;
  font-size: .85rem;
  border-bottom: 1px solid color-mix(in srgb, var(--sh-dark) 30%, transparent);
}
table.data tr:last-child td { border-bottom: none; }
table.data th {
  font-family: var(--f-mono);
  font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--c-text-muted); font-weight: 700;
  background: color-mix(in srgb, var(--sh-dark) 12%, var(--c-surface));
}
table.data tbody tr:hover td {
  background: color-mix(in srgb, var(--sh-light) 35%, transparent);
}

/* Forms — inputs are inset wells */
label { display: block; margin-bottom: var(--s-3);
        font-size: .78rem; color: var(--c-text-muted);
        font-family: var(--f-mono); letter-spacing: .03em; }
label input, label select, label textarea { display: block; margin-top: 6px; width: 100%; }

input[type="text"], input[type="number"], input[type="password"], input[type="email"],
input[type="file"], select, textarea {
  font: inherit; padding: 11px 14px; width: 100%;
  background: var(--c-surface); color: var(--c-text);
  border: none; border-radius: var(--r-md);
  box-shadow: var(--sh-in-sm);
  transition: box-shadow .18s var(--easing);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: var(--sh-in-md),
              0 0 0 2px color-mix(in srgb, var(--c-primary) 40%, transparent);
}
textarea { font-family: var(--f-mono); line-height: 1.55; resize: vertical; min-height: 120px; }

/* Buttons — extruded → inset on press */
button, .btn {
  font: inherit; cursor: pointer; font-weight: 700;
  padding: 10px 18px;
  background: var(--c-surface); color: var(--c-primary);
  border: none; border-radius: var(--r-md);
  box-shadow: var(--sh-out-sm);
  text-decoration: none; display: inline-block;
  letter-spacing: .03em;
  transition: box-shadow .15s var(--easing), color .15s var(--easing), background .15s var(--easing);
}
button:hover, .btn:hover { color: var(--c-primary-h); }
button:active, .btn:active { box-shadow: var(--sh-in-sm); }
button:disabled { color: var(--c-text-muted); cursor: not-allowed; box-shadow: var(--sh-in-sm); }
button.danger { color: var(--c-danger); }
button.danger:hover { color: var(--c-danger-h); }
button.ghost { color: var(--c-text-muted); box-shadow: none; }
button.ghost:hover { color: var(--c-text); box-shadow: var(--sh-out-sm); }

/* Primary CTA — solid teal slab */
.btn-primary, button.primary, .login-form > button {
  background: var(--c-primary); color: #fff;
  box-shadow: var(--sh-out-md);
}
.btn-primary:hover, button.primary:hover, .login-form > button:hover {
  background: var(--c-primary-h); color: #fff;
}
.btn-primary:active, button.primary:active, .login-form > button:active {
  box-shadow: var(--sh-in-sm);
}

.toolbar { display: flex; gap: 6px; margin-bottom: 10px; }
.toolbar button {
  padding: 6px 12px; font-family: var(--f-mono); font-size: .8rem;
  background: var(--c-surface); color: var(--c-text);
  box-shadow: var(--sh-out-sm);
}
.toolbar button:hover { color: var(--c-primary); }
.toolbar button:active { box-shadow: var(--sh-in-sm); }

.filters {
  display: flex; gap: 20px; margin-bottom: 28px;
  align-items: end; flex-wrap: wrap;
  padding: 22px 24px;
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-sm);
}
.filters > * { margin: 0; }
.filters fieldset {
  border: none;
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-in-sm);
  padding: 12px 16px 10px;
}
.filters fieldset legend {
  font-family: var(--f-mono); font-size: .68rem;
  text-transform: uppercase; color: var(--c-text-muted);
  padding: 0 6px; letter-spacing: .08em;
}
.filters fieldset label {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0 var(--s-3) 0 0;
  color: var(--c-text); font-size: .82rem; font-family: var(--f-body);
}
.filters button { align-self: end; }

.grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }

.card {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-md);
  padding: 18px 20px;
}

.pager {
  display: flex; gap: 20px; margin-top: 24px;
  align-items: center; font-size: .85rem; font-family: var(--f-mono);
}

.alert {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-in-sm);
  color: var(--c-danger);
  padding: 12px 16px; margin-bottom: var(--s-3);
  font-size: .88rem; font-weight: 500;
}

.level-DEBUG { color: var(--c-text-muted); }
.level-INFO  { color: var(--c-text); }
.level-WARNING { color: var(--c-warning); font-weight: 700; }
.level-ERROR { color: var(--c-danger); font-weight: 700; }
.level-CRITICAL {
  color: #fff; background: var(--c-danger);
  padding: 1px 8px; border-radius: var(--r-sm); font-weight: 700;
}

/* Inline media player */
.media > summary {
  cursor: pointer; color: var(--c-primary); font-size: .85rem;
  list-style: none; user-select: none; font-weight: 700;
}
.media > summary::-webkit-details-marker { display: none; }
.media > summary:hover { color: var(--c-primary-h); }
.media[open] > summary { color: var(--c-text-muted); }
.media-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 0 4px;
}
.media video, .media audio {
  display: block;
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-sm);
}

/* Auth screen */
.auth-box {
  max-width: 380px; margin: 12vh auto 0; padding: var(--s-6);
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-out-lg);
}
.auth-logo {
  display: flex; justify-content: center; margin-bottom: var(--s-4);
}
.auth-logo img {
  width: 84px; height: 84px;
  background: #000; border-radius: 18px; padding: 4px;
  box-shadow: var(--sh-out-md);
  object-fit: contain;
}
.auth-box h1 {
  text-align: center; margin-bottom: var(--s-2);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 1.1rem; color: var(--c-text-muted); font-weight: 500;
  font-family: var(--f-display);
}
.auth-box h1 span {
  color: var(--c-text); font-size: 1.4rem; font-weight: 700;
  font-family: var(--f-display); letter-spacing: -0.01em;
}
.auth-icon { color: var(--c-primary); }
.auth-hint {
  text-align: center; color: var(--c-text-muted);
  font-size: .85rem; line-height: 1.55;
  font-family: var(--f-mono);
  margin: var(--s-3) 0 var(--s-5);
}
.auth-hint code {
  background: var(--c-surface); color: var(--c-primary);
  padding: 2px 8px; border-radius: var(--r-sm);
  font-weight: 700;
  box-shadow: var(--sh-in-sm);
}
.auth-box input.otp {
  width: 100%; padding: 18px 16px;
  background: var(--c-surface); color: var(--c-text);
  border: none; border-radius: var(--r-md);
  box-shadow: var(--sh-in-md);
  text-align: center; letter-spacing: .55em;
  font-family: var(--f-mono);
  font-size: 1.6rem; font-weight: 700;
  margin-bottom: var(--s-4);
}
.auth-box input.otp:focus {
  outline: none;
  box-shadow: var(--sh-in-lg),
              0 0 0 2px color-mix(in srgb, var(--c-primary) 40%, transparent);
}
.auth-box .alert { text-align: left; }
.auth-box form { display: flex; flex-direction: column; gap: var(--s-3); }
.auth-box form button[type="submit"] {
  width: 100%;
  padding: 14px;
  background: var(--c-primary); color: #fff;
  border: none; border-radius: var(--r-md);
  font: inherit; font-family: var(--f-display); font-weight: 700;
  font-size: 1rem; letter-spacing: .05em;
  cursor: pointer;
  box-shadow: var(--sh-out-md);
  transition: background .15s var(--easing), box-shadow .15s var(--easing);
}
.auth-box form button[type="submit"]:hover { background: var(--c-primary-h); }
.auth-box form button[type="submit"]:active { box-shadow: var(--sh-in-sm); }
