:root {
  --ink: #17191c;
  --muted: #697078;
  --line: #dfe3e6;
  --surface: #ffffff;
  --canvas: #f3f5f6;
  --brand: #574a41;
  --brand-2: #bdaf96;
  --gold: #a67c24;
  --red: #b72d32;
  --teal: #1d7668;
  --warning: #9a650d;
  --radius: 7px;
  --shadow: 0 10px 28px rgba(26, 31, 35, .07);
  font-family: Tahoma, Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; stroke-width: 1.8; flex: 0 0 auto; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 0 0 auto; z-index: 40; width: 270px;
  display: flex; flex-direction: column; color: #fff; background: #292c2e;
  border-left: 1px solid rgba(255,255,255,.08);
}
.brand { min-height: 96px; padding: 20px; display: flex; align-items: center; gap: 13px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 50px; height: 50px; display: grid; place-items: center; background: var(--brand-2); color: #292c2e; font-size: 25px; font-weight: 800; border-radius: 6px; }
.brand strong, .brand span, .user-summary strong, .user-summary span { display: block; }
.brand strong { font-size: 20px; }
.brand span { margin-top: 5px; color: #c9cdcf; font-size: 12px; }
.nav-list { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-link { min-height: 45px; padding: 10px 12px; margin-bottom: 4px; display: flex; align-items: center; gap: 12px; color: #cfd3d5; border-radius: 5px; font-size: 14px; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-link.active { color: #fff; background: var(--brand); border-right: 3px solid var(--brand-2); }
.sidebar-footer { padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(255,255,255,.1); }
.user-summary { min-width: 0; display: flex; align-items: center; gap: 9px; }
.user-summary strong { max-width: 135px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-summary span { color: #b8bdc0; font-size: 11px; margin-top: 3px; }
.user-avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-2); color: #292c2e; font-weight: 700; }
.logout-link, .icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; }
.sidebar .logout-link { color: #fff; background: transparent; border-color: rgba(255,255,255,.16); }

.main-area { min-height: 100vh; margin-right: 270px; display: flex; flex-direction: column; }
.topbar { height: 82px; padding: 0 clamp(18px, 3vw, 38px); display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: 20px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { margin-right: auto; color: var(--muted); font-size: 13px; }
.menu-button { display: none; }
.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 28px clamp(16px, 3vw, 38px) 40px; flex: 1; }
.app-footer { min-height: 58px; padding: 16px clamp(18px, 3vw, 38px); display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: #fff; }
.app-footer a { text-decoration: underline; text-underline-offset: 4px; }

.page-heading { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.page-heading h2 { margin: 0; font-size: 25px; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { min-height: 62px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-header h3 { margin: 0; font-size: 17px; }
.panel-body { padding: 20px; }

.stat { min-height: 126px; padding: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stat-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 6px; background: #ece9e4; color: var(--brand); }
.stat strong { display: block; margin-top: 11px; font-size: 29px; line-height: 1; }
.stat span { display: block; margin-top: 7px; color: var(--muted); font-size: 13px; }
.stat.danger .stat-icon { background: #f8e7e8; color: var(--red); }
.stat.success .stat-icon { background: #e4f3ef; color: var(--teal); }
.stat.warning .stat-icon { background: #fbf0dc; color: var(--warning); }

.button { min-height: 40px; padding: 9px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 5px; background: var(--brand); color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; }
.button:hover { filter: brightness(.94); }
.button.secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button.danger { background: var(--red); }
.button.success { background: var(--teal); }
.button.small { min-height: 34px; padding: 7px 10px; font-size: 12px; }
.button svg { width: 17px; height: 17px; }
.icon-button:hover { background: #f4f4f4; }

.filters { margin-bottom: 16px; padding: 14px; display: flex; align-items: end; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.filters .field { min-width: 150px; flex: 1 1 170px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 15px; }
.col-12 { grid-column: span 12; }.col-8 { grid-column: span 8; }.col-6 { grid-column: span 6; }.col-4 { grid-column: span 4; }.col-3 { grid-column: span 3; }
.field { margin-bottom: 15px; }
.field label { margin-bottom: 7px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.field label small { color: var(--muted); font-weight: 400; }
.input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfd4d8; border-radius: 5px; color: var(--ink); background: #fff; outline: none; }
.input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(87,74,65,.12); }
textarea { min-height: 95px; resize: vertical; }
.checkbox { min-height: 42px; display: flex; align-items: center; gap: 9px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-actions { padding-top: 14px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.7; }
.required { color: var(--red); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: right; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
th { color: #454b50; background: #f7f8f8; white-space: nowrap; font-size: 12px; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.table-actions form { margin: 0; }
.code { direction: ltr; display: inline-block; font-family: Consolas, monospace; font-size: 12px; }
.badge { min-height: 25px; padding: 4px 9px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; background: #eceff1; color: #4b545a; }
.badge.success { background: #e1f2ed; color: #17695d; }
.badge.warning { background: #fbefd6; color: #875908; }
.badge.danger { background: #f8e2e4; color: #a3292f; }
.badge.neutral { background: #eceff1; color: #4b545a; }

.alert { margin-bottom: 16px; padding: 13px 15px; display: flex; align-items: center; gap: 10px; border: 1px solid; border-radius: 6px; font-size: 13px; }
.alert.success { color: #155f54; background: #e8f5f1; border-color: #b8dfd5; }
.alert.error, .alert.danger { color: #94252a; background: #fbe9ea; border-color: #edbec1; }
.alert.warning { color: #7f570e; background: #fff5df; border-color: #efd7a7; }
.alert.info { color: #31556b; background: #eaf3f8; border-color: #bfd6e3; }
.empty-state { min-height: 260px; padding: 40px 20px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state svg { width: 42px; height: 42px; margin-bottom: 12px; color: var(--brand-2); }
.empty-state h3 { margin: 0; color: var(--ink); font-size: 17px; }
.empty-state p { max-width: 420px; margin: 8px 0 0; font-size: 13px; line-height: 1.8; }

.detail-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.detail-item { min-height: 76px; padding: 14px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-item:nth-child(4n) { border-left: 0; }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.detail-item strong { font-size: 14px; }
.section-title { margin: 0 0 16px; padding-bottom: 10px; font-size: 17px; border-bottom: 2px solid var(--brand-2); }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }
.meter { height: 7px; overflow: hidden; background: #e9ecee; border-radius: 99px; }
.meter span { display: block; height: 100%; background: var(--teal); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eef0f1; }
.auth-box { width: min(940px, 100%); min-height: 560px; display: grid; grid-template-columns: .85fr 1.15fr; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 22px 60px rgba(30,35,38,.13); }
.auth-brand { padding: 44px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: #292c2e; }
.auth-brand .brand-mark { width: 65px; height: 65px; font-size: 31px; }
.auth-brand h1 { margin: 22px 0 8px; font-size: 32px; }
.auth-brand p { margin: 0; color: #ced1d3; line-height: 1.8; }
.auth-brand small { color: #aeb4b7; }
.auth-form { padding: 48px; align-self: center; }
.auth-form h2 { margin: 0 0 8px; font-size: 25px; }
.auth-form > p { margin: 0 0 28px; color: var(--muted); line-height: 1.8; font-size: 14px; }
.auth-form .button { width: 100%; margin-top: 5px; }

.privacy-page { max-width: 900px; margin: 0 auto; padding: 42px 20px 70px; }
.privacy-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.privacy-header .brand { min-height: auto; padding: 0; border: 0; color: var(--ink); }
.privacy-header .brand span { color: var(--muted); }
.prose { padding: clamp(22px,4vw,44px); background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.prose h1 { margin-top: 0; font-size: 28px; }.prose h2 { margin-top: 30px; font-size: 18px; }.prose p, .prose li { color: #4f565c; line-height: 2; font-size: 14px; }

.print-only { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-item:nth-child(4n) { border-left: 1px solid var(--line); }
  .detail-item:nth-child(2n) { border-left: 0; }
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(100%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.38); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .main-area { margin-right: 0; }
  .menu-button { display: inline-grid; }
  .today { display: none; }
  .content { padding-top: 20px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .col-12,.col-8,.col-6,.col-4,.col-3 { grid-column: span 1; }
  .auth-box { grid-template-columns: 1fr; }
  .auth-brand { min-height: 230px; padding: 30px; }
  .auth-form { padding: 30px; }
}

@media (max-width: 560px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .topbar { height: 72px; }
  .topbar h1 { font-size: 17px; }
  .panel-body { padding: 15px; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-item { border-left: 0 !important; }
  .filters { align-items: stretch; }
  .filters .field { min-width: 100%; }
  .filters .button { flex: 1; }
  th, td { padding: 11px 10px; }
}

@media print {
  .sidebar, .topbar, .app-footer, .no-print, .page-actions { display: none !important; }
  .main-area { margin: 0; }
  .content { max-width: none; padding: 0; }
  .panel { box-shadow: none; border-color: #aaa; }
  .print-only { display: block; }
  body { background: #fff; }
}
