@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

/* ── RESET & BASE ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: #f6f5f2; }
body {
  font-family: 'Geist', -apple-system, sans-serif;
  color: #16161a;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

/* ── TOKENS ── */
:root {
  --bg: #f6f5f2;
  --canvas: #ffffff;
  --ink: #16161a;
  --ink-2: #57544e;
  --mute: #8b8985;
  --line: #eeece7;
  --subtle: #faf9f6;
  --green: #1a6b3f;
  --red: #b8452f;
  --amber: #8c6120;
  --blue: #3b5bc4;
  --purple: #6a3b8f;
  --orange: #b8452f;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(22,22,26,0.04);
  --shadow-md: 0 4px 12px -4px rgba(22,22,26,0.12);
  --shadow-lg: 0 12px 40px -12px rgba(22,22,26,0.08);
}

/* ── LAYOUT ── */
.app { width: 1440px; margin: 0 auto; display: flex; min-height: 100vh; background: var(--bg); }
.app.login-layout { display: block; }

/* ── SIDEBAR ── */
.sidebar {
  width: 232px;
  padding: 20px 14px;
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.logo-wrap { padding: 4px 8px 20px; display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 30px; height: 30px;
  background: var(--ink);
  border-radius: var(--radius-sm);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Instrument Serif', serif;
  font-size: 18px;
  font-style: italic;
}
.logo-text { font-weight: 500; font-size: 14.5px; letter-spacing: -0.01em; color: var(--ink); }
.logo-text small { display: block; font-size: 10.5px; color: var(--mute); letter-spacing: 0.02em; font-weight: 400; }

.nav-group { margin-bottom: 6px; }
.nav-header {
  font-size: 10.5px; text-transform: uppercase;
  color: #a8a5a0; letter-spacing: 0.09em;
  padding: 12px 10px 6px;
  font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 400;
  margin-bottom: 1px;
  letter-spacing: -0.005em;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(22,22,26,0.04); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  box-shadow: 0 4px 12px -4px rgba(22,22,26,0.35);
}
.nav-item .count { margin-left: auto; font-size: 11px; color: #a8a5a0; font-family: 'Geist Mono', monospace; }
.nav-item.active .count { color: rgba(246,245,242,0.55); }
.nav-item svg { flex-shrink: 0; opacity: 0.85; }

.sb-footer {
  margin-top: auto;
  padding: 10px;
  background: rgba(22,22,26,0.03);
  border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.sb-footer:hover { background: rgba(22,22,26,0.06); }
.sb-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ink), var(--ink-2));
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 12px;
  flex-shrink: 0;
}
.sb-user { font-size: 13px; font-weight: 500; color: var(--ink); }
.sb-role { font-size: 11px; color: var(--mute); }

/* ── MAIN CANVAS ── */
.main { flex: 1; padding: 16px 20px 20px 4px; }
.canvas {
  background: var(--canvas);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm), var(--shadow-lg);
  min-height: calc(100vh - 32px);
  overflow: hidden;
}

/* ── HEADER ── */
.header {
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px;
  background: var(--canvas);
  position: sticky; top: 0; z-index: 5;
}
.crumbs { font-size: 12.5px; color: var(--mute); display: flex; align-items: center; gap: 8px; }
.crumbs .cur { color: var(--ink); font-weight: 500; }
.crumbs .sep { color: #d4d1cb; }

.h-search {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  border-radius: 10px;
  padding: 8px 14px;
  width: 340px;
  color: var(--mute); font-size: 13px;
}
.h-search input { flex:1; border: none; background: transparent; outline: none; font-family: inherit; font-size: 13px; color: var(--ink); }
.h-search .kbd { font-family: 'Geist Mono', monospace; background: white; border-radius: 4px; padding: 1px 5px; font-size: 10px; color: var(--mute); }

.h-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--bg); }
.notif-dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; background: #e85d4c; border-radius: 50%; border: 2px solid white; }

.ai-btn {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--ink), #2a2a30);
  color: var(--bg);
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: inherit; font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(22,22,26,0.35);
  transition: background 0.15s ease;
}
.ai-btn:hover { background: linear-gradient(135deg, #2a2a30, #3a3a40); }
.ai-btn .dot { width: 6px; height: 6px; background: #a4f4a2; border-radius: 50%; box-shadow: 0 0 8px #a4f4a2; animation: p 2s infinite; }

/* ── CONTENT ── */
.content { padding: 28px 32px 40px; }

.page-title-row { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.h1 {
  font-family: 'Instrument Serif', serif;
  font-size: 40px;
  font-weight: 400;
  line-height: 1.05;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.h1 em { font-style: italic; color: var(--ink-2); }
.subtitle {
  color: var(--ink-2);
  font-size: 13.5px;
  margin-top: 8px;
  display: flex; align-items: center; gap: 12px;
}
.live-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34,139,84,0.08);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.live-tag .lv { width: 5px; height: 5px; background: var(--green); border-radius: 50%; animation: p 2s infinite; }
@keyframes p { 0%,100% { opacity:1; } 50% { opacity: 0.35; } }

/* ── PILLS ── */
.pill-group { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; }
.pill {
  padding: 6px 12px; border-radius: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.pill:hover { color: var(--ink); }
.pill.active { background: white; color: var(--ink); box-shadow: 0 1px 3px rgba(22,22,26,0.08); }

/* ── BUTTONS ── */
.g-btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: var(--canvas);
  padding: 8px 13px;
  border-radius: 10px;
  font-family: inherit; font-size: 12.5px; color: var(--ink); font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.g-btn:hover { background: var(--bg); }
.g-btn.primary {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
  box-shadow: 0 6px 16px -6px rgba(22,22,26,0.4);
}
.g-btn.primary:hover { background: #2a2a30; }

.actions-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* ── HERO STATS ── */
.hero-stats {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--line);
}
.hs {
  background: var(--canvas);
  padding: 22px 24px;
  position: relative;
}
.hs-primary {
  background: linear-gradient(135deg, var(--ink) 0%, #2a2a30 100%);
  color: var(--bg);
}
.hs-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  font-weight: 500;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.hs-primary .hs-label { color: rgba(246,245,242,0.6); }
.hs-value {
  font-family: 'Instrument Serif', serif;
  font-size: 44px;
  line-height: 1;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: -0.02em;
}
.hs-primary .hs-value { color: var(--bg); }
.hs-value small { font-family: 'Geist Mono', monospace; font-size: 15px; color: #a8a5a0; font-style: normal; margin-left: 6px; }
.hs-primary .hs-value small { color: rgba(246,245,242,0.5); }
.hs-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.hs-primary .hs-sub { color: rgba(246,245,242,0.65); }
.delta-up { color: var(--green); font-weight: 500; }
.delta-down { color: var(--red); font-weight: 500; }
.hs-primary .delta-up { color: #a4f4a2; }

.spark { position: absolute; bottom: 12px; right: 16px; opacity: 0.6; }

/* ── ATTENTION CARD ── */
.attention {
  background: linear-gradient(135deg, #fef8ea 0%, #fdf1d4 100%);
  border: 1px solid #f0e2b8;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 28px;
}
.att-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.att-body { flex: 1; }
.att-title { font-size: 14.5px; font-weight: 500; color: var(--ink); margin-bottom: 3px; }
.att-desc { font-size: 12.5px; color: #7a6f4a; }
.att-desc b { color: #4d411a; font-weight: 600; }
.att-actions { display: flex; gap: 8px; }

/* ── GRID LAYOUT ── */
.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; margin-bottom: 28px; }

/* ── PANEL ── */
.panel {
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.panel-head {
  padding: 20px 22px 14px;
  display: flex; justify-content: space-between; align-items: flex-start;
}
.panel-title { font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.panel-sub { font-size: 12px; color: var(--mute); margin-top: 3px; }
.panel-body { padding: 8px 22px 22px; }

/* ── BUCKETS ── */
.buckets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; padding: 4px 4px 8px; }
.bucket-tile {
  background: #f9f7f3;
  border-radius: 14px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease;
}
.bucket-tile:hover { transform: translateY(-1px); }
.bucket-tile.rq { background: linear-gradient(135deg, #f0f4ff 0%, #e6ecff 100%); }
.bucket-tile.rf { background: linear-gradient(135deg, #eef7f4 0%, #e0efe9 100%); }
.bucket-tile.vc { background: linear-gradient(135deg, #f4eef7 0%, #ebe1f2 100%); }
.bucket-tile.rm { background: linear-gradient(135deg, #fdf3ea 0%, #f8e5d3 100%); }

.bucket-tile-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.bucket-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.bucket-code { font-family: 'Geist Mono', monospace; font-size: 10px; color: var(--mute); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.05em; }
.bucket-total-val {
  font-family: 'Instrument Serif', serif;
  font-size: 30px;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.funnel { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.funnel-row { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); }
.funnel-row .label { display: flex; align-items: center; gap: 6px; }
.funnel-row .dt { width: 6px; height: 6px; border-radius: 50%; }
.funnel-row .val { font-family: 'Geist Mono', monospace; font-weight: 500; color: var(--ink); font-size: 12px; }

/* ── STALE LIST ── */
.stale-list { display: flex; flex-direction: column; }
.stale-row {
  padding: 14px 22px;
  border-top: 1px solid #f0eee9;
  display: flex; align-items: center; gap: 12px;
  transition: background 0.15s ease;
}
.stale-row:hover { background: var(--subtle); }
.stale-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; color: var(--ink-2);
  flex-shrink: 0;
  font-family: 'Geist Mono', monospace;
}
.stale-info { flex: 1; min-width: 0; }
.stale-title { font-size: 13px; font-weight: 500; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.anchor-chip {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1.5px 5px;
  border-radius: 3px;
  background: var(--ink);
  color: var(--bg);
  letter-spacing: 0.05em;
}
.stale-meta { font-size: 11.5px; color: var(--mute); margin-top: 2px; }
.stale-age {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--red);
  font-weight: 500;
}
.stale-age.warn { color: #b8862f; }

/* ── TABLE ── */
.table-wrap { overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left;
  padding: 12px 20px;
  font-size: 10.5px;
  color: var(--mute);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--subtle);
  border-bottom: 1px solid var(--line);
}
.tbl tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid #f4f2ed;
  font-size: 13px;
  color: var(--ink);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--subtle); }

.ld-cell { display: flex; align-items: center; gap: 11px; }
.ld-av {
  width: 34px; height: 34px; border-radius: 10px;
  color: white; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ld-name { font-weight: 500; color: var(--ink); }
.ld-role { font-size: 11px; color: var(--mute); margin-top: 1px; }

.num { font-family: 'Geist Mono', monospace; font-weight: 500; font-size: 13px; }

.progress-cell { display: flex; flex-direction: column; gap: 5px; min-width: 110px; }
.progress-vals { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--mute); }
.progress-vals b { color: var(--ink); font-family: 'Geist Mono', monospace; font-weight: 500; }
.progress-bar { height: 5px; background: #f0eee9; border-radius: 100px; overflow: hidden; display: flex; }
.progress-fill { height: 100%; background: var(--ink); border-radius: 100px; transition: width 0.4s ease; }

/* ── TAGS ── */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  font-family: 'Geist Mono', monospace;
}
.tag-ok { background: rgba(26,107,63,0.1); color: var(--green); }
.tag-warn { background: rgba(184,134,47,0.12); color: var(--amber); }
.tag-bad { background: rgba(184,69,47,0.1); color: var(--red); }

.trend { display: inline-flex; align-items: center; gap: 4px; font-family: 'Geist Mono', monospace; font-size: 12px; font-weight: 500; }

.row-action {
  width: 28px; height: 28px; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  color: var(--mute); display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.row-action:hover { background: #f0eee9; color: var(--ink); }

/* ── FOOTER ── */
.canvas-foot {
  padding: 18px 32px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between;
  font-size: 11.5px;
  color: var(--mute);
}
.canvas-foot .ops { display: flex; align-items: center; gap: 6px; }
.canvas-foot .ops .lv { width: 6px; height: 6px; background: var(--green); border-radius: 50%; }

/* ── DROPDOWN ── */
.dropdown-menu { transition: opacity 0.15s ease; }
.dropdown-item:hover { background: var(--bg) !important; }

/* ── FORMS ── */
.form-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mute);
  font-weight: 500;
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--canvas);
  outline: none;
  transition: border-color 0.15s ease;
}
.form-input:focus { border-color: var(--ink); }
select.form-input { cursor: pointer; }
textarea.form-input { font-family: inherit; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { color: var(--mute); margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 500; color: var(--ink); margin-bottom: 4px; }
.empty-desc { font-size: 13px; color: var(--mute); }

/* ── LOGIN ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 40px 20px;
}
.login-container {
  width: 520px;
  background: var(--canvas);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm), var(--shadow-lg);
  padding: 40px 36px;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.login-section { margin-bottom: 24px; }
.login-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mute);
  font-weight: 500;
  margin-bottom: 10px;
}
.login-cards { display: flex; flex-direction: column; gap: 8px; }
.login-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}
.login-card:hover { background: var(--subtle); border-color: #d4d1cb; }
.login-card.disabled { cursor: default; opacity: 0.6; }
.login-card.disabled:hover { background: transparent; border-color: var(--line); }
.login-card-info { flex: 1; }
.login-card-name { font-weight: 500; color: var(--ink); font-size: 14px; }
.login-card-role { font-size: 12px; color: var(--mute); margin-top: 1px; }
.login-footer {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--mute);
}

/* ── DETAIL FIELDS ── */
.detail-field {
  padding: 8px 0;
}
.detail-field .form-label {
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── UPLOAD ZONE ── */
.upload-zone:hover { border-color: var(--ink) !important; }
