/* ===== Base tokens & layout ===== */
:root {
  --primary: #244B3A;
  --primary-700: #1B3A2D;
  --primary-900: #132A20;
  --primary-50: #EAF1ED;
  --primary-100: #D5E3DA;
  --gold: #C6A15B;
  --gold-600: #A9853F;
  --gold-50: #F8F2E6;
  --bg: #F7F7F4;
  --surface: #FFFFFF;
  --surface-2: #FBFBF9;
  --text: #202923;
  --muted: #7A837C;
  --border: #E8EAE5;
  --border-strong: #D9DCD5;
  --danger: #B4423A;
  --danger-50: #FBEDEB;
  --warning: #B7791F;
  --warning-50: #FDF4E3;
  --info: #2F6690;
  --info-50: #E9F1F8;
  --success: #2E7D4F;
  --success-50: #E7F4EC;
  --purple: #6B4E9B;
  --purple-50: #F0EBF7;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 35, 27, .05);
  --shadow: 0 1px 3px rgba(20, 35, 27, .06), 0 6px 16px rgba(20, 35, 27, .05);
  --shadow-lg: 0 12px 40px rgba(20, 35, 27, .16);
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
::selection { background: var(--gold-50); }
.hidden { display: none !important; }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary-900);
  background: linear-gradient(180deg, #17332A 0%, #132A20 100%);
  color: #DCE6E0;
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: width .22s ease, transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-h);
}
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, #D8B977, #A9853F);
  display: grid; place-items: center;
  color: #17332A; font-family: var(--font-display); font-weight: 700; font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { overflow: hidden; white-space: nowrap; }
.brand-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #fff; line-height: 1.05; white-space: normal; }
.brand-sub { font-size: 11px; color: var(--gold); letter-spacing: .12em; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: rgba(220,230,224,.45); padding: 14px 12px 6px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; margin: 2px 0;
  border-radius: 9px;
  color: #C9D6CF; font-weight: 500;
  cursor: pointer; position: relative;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(198,161,91,.14); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gold);
}
.nav-item.active svg { color: var(--gold); }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.sidebar-user .avatar { background: rgba(198,161,91,.2); color: var(--gold); }
.sidebar-user-info { overflow: hidden; white-space: nowrap; flex: 1; }
.sidebar-user-name { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar-user-role { color: rgba(220,230,224,.6); font-size: 11.5px; }
.sidebar-user .icon-btn { color: #C9D6CF; }
.sidebar-user .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-badge,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-user .icon-btn { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 18px 0 16px; }
body.sidebar-collapsed .sidebar-user { justify-content: center; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin-left .22s ease; }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.global-search { position: relative; flex: 1; max-width: 520px; }
.global-search input {
  width: 100%; height: 40px; padding: 0 14px 0 40px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); font: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(36,75,58,.1); }
.global-search > svg { position: absolute; left: 13px; top: 11px; width: 18px; height: 18px; color: var(--muted); }
.search-results {
  position: absolute; top: 46px; left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 440px; overflow-y: auto; padding: 6px;
}
.search-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 8px 10px 4px; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.search-item:hover, .search-item.focused { background: var(--primary-50); }
.search-item .si-title { font-weight: 500; }
.search-item .si-sub { font-size: 12px; color: var(--muted); }
.search-item svg { width: 16px; height: 16px; color: var(--muted); }
.search-empty { padding: 18px; text-align: center; color: var(--muted); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-date { color: var(--muted); font-size: 13px; white-space: nowrap; padding: 0 8px; display: flex; align-items: center; gap: 6px; }
.topbar-date svg { width: 16px; height: 16px; }

.content { padding: 24px; max-width: 1560px; margin: 0 auto; }

/* ===== Page header ===== */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title .mono { font-size: inherit; font-weight: 600; }
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.page-subtitle { color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--muted); }

/* ===== Print area ===== */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
}
