/* ============================================================
   KADIMA SKELETON — shared shell
   Full-screen layout · animated hover sidebar · live clock
   ============================================================ */

:root {
  --bg:           #f4f3f1;
  --surface:      #ffffff;
  --sidebar:      #faf9f7;
  --border:       #e8e5e1;
  --border-soft:  #f0ede9;

  --text:         #1c1917;
  --text-2:       #57534e;
  --muted:        #a8a29e;

  --accent:       #d97706;
  --accent-soft:  #fdf0dd;
  --accent-ink:   #92400e;

  --blue:         #3b82f6;  --blue-soft:  #eff6ff;
  --green:        #16a34a;  --green-soft: #f0fdf4;
  --red:          #dc2626;  --red-soft:   #fef2f2;
  --amber:        #d97706;  --amber-soft: #fffbeb;

  --sidebar-w:    248px;
  --radius:       10px;
  --radius-sm:    7px;

  --ease-out:     cubic-bezier(0.22, 1, 0.36, 1);
  --drawer-time:  320ms;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p  { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { min-height: 100vh; }

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  transition: margin-left var(--drawer-time) var(--ease-out);
}
body.sidebar-pinned .main { margin-left: var(--sidebar-w); }

/* ============================================================
   HAMBURGER
   ============================================================ */
.sidebar-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  transition: opacity 220ms var(--ease-out),
              transform 220ms var(--ease-out),
              background 160ms ease,
              color 160ms ease,
              border-color 160ms ease;
}
.sidebar-toggle svg { width: 18px; height: 18px; stroke-width: 1.9; }
.sidebar-toggle:hover { background: var(--border-soft); color: var(--text); }

body.sidebar-pinned .sidebar-toggle {
  opacity: 0;
  transform: translateX(-8px) scale(0.9);
  pointer-events: none;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  z-index: 150;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  overflow-y: auto;
  overflow-x: hidden;

  transform: translateX(calc(-1 * var(--sidebar-w) - 20px));
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: transform var(--drawer-time) var(--ease-out),
              box-shadow var(--drawer-time) var(--ease-out);
  will-change: transform;
}

.sidebar.is-open {
  transform: translateX(0);
  box-shadow: 16px 0 44px -22px rgba(0, 0, 0, 0.28);
}

body.sidebar-pinned .sidebar {
  transform: translateX(0);
  box-shadow: none;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar:hover::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }

/* ---- staggered entrance for sidebar children (leaf nodes only,
        never hide .nav-section — that hides whole groups) ---- */
.sidebar .brand,
.sidebar .user-chip,
.sidebar .nav-item,
.sidebar .nav-section-label,
.sidebar .sidebar-foot {
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 220ms var(--ease-out),
              transform 260ms var(--ease-out);
}

.sidebar.is-open .brand,
body.sidebar-pinned .sidebar .brand {
  opacity: 1; transform: translateX(0);
  transition-delay: 40ms;
}

.sidebar.is-open .user-chip,
body.sidebar-pinned .sidebar .user-chip {
  opacity: 1; transform: translateX(0);
  transition-delay: 80ms;
}

.sidebar.is-open .nav-item,
body.sidebar-pinned .sidebar .nav-item {
  opacity: 1; transform: translateX(0);
}

.sidebar.is-open .nav-section-label,
body.sidebar-pinned .sidebar .nav-section-label {
  opacity: 1; transform: translateX(0);
  transition-delay: 90ms;
}

.sidebar.is-open .sidebar-foot,
body.sidebar-pinned .sidebar .sidebar-foot {
  opacity: 1; transform: translateX(0);
  transition-delay: 300ms;
}

/* tiny stagger on the Systems items */
.sidebar.is-open .nav-section .nav-item:nth-child(2) { transition-delay: 100ms; }
.sidebar.is-open .nav-section .nav-item:nth-child(3) { transition-delay: 130ms; }
.sidebar.is-open .nav-section .nav-item:nth-child(4) { transition-delay: 160ms; }
.sidebar.is-open .nav-section .nav-item:nth-child(5) { transition-delay: 190ms; }
.sidebar.is-open .nav-section .nav-item:nth-child(6) { transition-delay: 220ms; }
.sidebar.is-open .nav-section .nav-item:nth-child(7) { transition-delay: 250ms; }

/* ============================================================
   SIDEBAR — brand, user chip, nav styles
   ============================================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  flex-shrink: 0;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
  transition: transform 260ms var(--ease-out);
}
.sidebar.is-open .brand-mark,
body.sidebar-pinned .sidebar .brand-mark {
  transform: rotate(-4deg) scale(1.02);
}
.brand-text { min-width: 0; flex: 1; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }

.sidebar-pin {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  padding: 0;
  transition: background .12s, color .12s, border-color .12s;
  flex-shrink: 0;
}
.sidebar-pin svg { width: 15px; height: 15px; stroke-width: 1.9; }
.sidebar-pin:hover { background: var(--border-soft); color: var(--text); }
body.sidebar-pinned .sidebar-pin {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: rgba(217, 119, 6, 0.25);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 18px;
  flex-shrink: 0;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: 11px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-section { margin-top: 18px; }
.nav-section-label {
  display: block;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
  transition: background 140ms ease,
              color 140ms ease,
              padding-left 220ms var(--ease-out);
}
.nav-item:hover { background: var(--border-soft); color: var(--text); padding-left: 14px; }
.nav-item svg {
  width: 16px; height: 16px;
  stroke-width: 1.75;
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform 220ms var(--ease-out), opacity 140ms ease;
}
.nav-item:hover svg { transform: scale(1.08); opacity: 1; }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}
.nav-item.is-active svg { opacity: 1; }

.nav-label { flex: 1; }

.nav-badge {
  font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: var(--border-soft);
  color: var(--text-2);
}
.nav-item.is-active .nav-badge {
  background: rgba(217, 119, 6, 0.15);
  color: var(--accent-ink);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-foot .nav-item { color: var(--text-2); font-weight: 500; }
.sidebar-foot .nav-item:hover { background: var(--red-soft); color: var(--red); }
.sidebar-foot .nav-item:hover svg { opacity: 1; }

/* ============================================================
   BACKDROP (touch)
   ============================================================ */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.35);
  z-index: 140;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--drawer-time) var(--ease-out);
}
body.sidebar-touch-open .sidebar-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px 16px 74px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: padding-left var(--drawer-time) var(--ease-out);
}
body.sidebar-pinned .topbar { padding-left: 28px; }

.topbar-left { min-width: 0; }
.topbar h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.topbar .desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}
.clock-time { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.clock-date { font-size: 10.5px; color: var(--muted); letter-spacing: 0.02em; }

/* ============================================================
   CONTENT
   ============================================================ */
.content { padding: 22px 28px 40px; flex: 1; }
.content-grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   CARD
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

.stat-label {
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }
.stat-delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}
.btn:hover  { background: var(--border-soft); }
.btn:active { transform: translateY(1px); }
.btn svg    { width: 15px; height: 15px; stroke-width: 1.75; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #c2660a; border-color: #c2660a; }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--border-soft); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============================================================
   PILLS / BADGES
   ============================================================ */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6;
}
.pill::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.pill-blue  { background: var(--blue-soft);  color: var(--blue); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red   { background: var(--red-soft);   color: var(--red); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-gray  { background: var(--border-soft); color: var(--text-2); }

.badge {
  display: inline-block; padding: 1px 7px;
  border-radius: 5px; font-size: 11px; font-weight: 600;
  background: var(--border-soft); color: var(--text-2);
}

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 14px; }
.label { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit; font-size: 13px; color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 88px; resize: vertical; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* ============================================================
   TABLES
   ============================================================ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--border-soft); }

/* ============================================================
   UTILITIES
   ============================================================ */
.muted   { color: var(--muted); }
.text-2  { color: var(--text-2); }
.mono    { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

.flex    { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.empty {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 13px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  body.sidebar-pinned .main { margin-left: 0; }
  .topbar { padding-left: 74px; }
  .topbar, .content { padding-right: 18px; }
  .content { padding-left: 18px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .topbar-clock { display: none; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .sidebar { transform: translateX(0); }
  .sidebar .brand,
  .sidebar .user-chip,
  .sidebar .nav-item,
  .sidebar .nav-section-label,
  .sidebar .sidebar-foot { opacity: 1; transform: none; }
}