/* ============ Siku Mesh — design tokens & shared shell ============ */
:root {
  --green-950: #04302A;
  --green-900: #063D35;
  --green-800: #0A493D;
  --green-700: #17604E;
  --green-600: #1F7A63;
  --green-100: #DCE8DF;
  --green-50: #EEF4EF;
  --brass-600: #8B6729;
  --brass-500: #A7792D;
  --brass-400: #CDA95B;
  --brass-200: #E2C276;
  --brass-100: #F2DEAA;
  --paper: #FAF7EF;
  --parchment: #F8F1DE;
  --parchment-deep: #F1E7CC;
  --card: #FFFFFF;
  --ink: #26261F;
  --ink-2: #55554A;
  --ink-3: #8C8B7B;
  --line: #E4DECB;
  --line-strong: #CFC7AC;
  --red-600: #B03024;
  --red-500: #C0392B;
  --red-bg: #FBEEEC;
  --amber-600: #B07B24;
  --amber-bg: #FBF3E0;
  --blue-600: #3C5A78;
  --blue-bg: #EDF2F7;
  --grey-bg: #F0EFEA;
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --shadow-card: 0 1px 2px rgba(64, 52, 28, 0.06), 0 2px 8px rgba(64, 52, 28, 0.05);
  --radius: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 12px; color: var(--ink); }
a { color: inherit; text-decoration: none; }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ============ App layout ============ */
.app { display: flex; min-height: 100vh; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============ Sidebar ============ */
.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: #FDFCF7;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand img { width: 34px; height: 34px; }

.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--green-800);
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--brass-600);
  letter-spacing: 0.28em;
}

.sidebar-nav { flex: 1; padding: 10px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: var(--ink-2);
  font-size: 13px;
  border-left: 3px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; }

.nav-item:hover { color: var(--green-800); background: var(--green-50); }

.nav-item.active {
  color: var(--green-800);
  font-weight: 600;
  background: var(--green-50);
  border-left-color: var(--green-800);
}

.nav-item .nav-caret {
  margin-left: auto;
  font-size: 10px;
  color: var(--ink-3);
  transition: transform 0.15s;
}

.nav-item.open .nav-caret { transform: rotate(180deg); }

.nav-children { display: none; }
.nav-children.open { display: block; }

.nav-child {
  display: block;
  padding: 7px 16px 7px 43px;
  font-size: 12.5px;
  color: var(--ink-2);
  border-left: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.nav-child:hover { color: var(--green-800); }

.nav-child.active {
  color: var(--green-800);
  font-weight: 600;
  background: var(--green-50);
  border-left-color: var(--green-800);
}

.sidebar-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  background:
    radial-gradient(circle at 30% 120%, rgba(205, 169, 91, 0.12), transparent 65%);
}

.sidebar-foot .num { font-size: 11px; }

.sidebar-foot .refresh {
  margin-top: 4px;
  color: var(--green-700);
  cursor: pointer;
}

.sidebar-foot .foot-compliance {
  margin-top: 8px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--brass-600);
}

/* ============ Topbar ============ */
.topbar {
  height: 48px;
  flex-shrink: 0;
  background: #FDFCF7;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .crumbs {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.topbar .crumbs .crumb-current {
  font-size: 15px;
  font-weight: 700;
  color: var(--green-900);
}

.topbar .crumbs .crumb-sep { color: var(--line-strong); }

.topbar .top-date {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--parchment);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 10px;
}

.topbar .spacer { flex: 1; }

.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-2);
  position: relative;
}

.top-btn:hover { border-color: var(--brass-400); color: var(--green-800); }

.top-btn .badge-dot {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--red-500);
  color: #fff;
  font-size: 10px;
  border-radius: 8px;
  padding: 0 4px;
  line-height: 14px;
  font-family: var(--mono);
}

.top-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
  flex-shrink: 0;
}

.top-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green-800);
  color: var(--brass-200);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.top-user { position: relative; cursor: pointer; }

.top-user .user-name { font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.top-user .user-role { font-size: 10.5px; color: var(--ink-3); }

.role-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 168px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  box-shadow: var(--shadow-card);
  padding: 4px;
  z-index: 80;
}

.role-menu[hidden] { display: none; }

.role-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink-2);
  border-radius: 3px;
}

.role-menu button:hover { background: var(--green-50); color: var(--green-800); }

.ai-drawer {
  position: fixed;
  top: 56px;
  right: 16px;
  width: 400px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(64, 52, 28, 0.12);
  padding: 14px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-drawer[hidden] { display: none !important; }

.ai-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ai-drawer-title { font-size: 14px; font-weight: 700; color: var(--green-900); }
.ai-drawer-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.ai-drawer-answer {
  min-height: 72px;
  background: var(--parchment);
  border: 1px solid var(--brass-200);
  border-radius: 4px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-2);
}
.ai-drawer-foot { font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }

.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-suggest-chip {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 11px;
}
.ai-suggest-chip:hover { border-color: var(--brass-400); color: var(--green-800); }

.ai-review {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}
.ai-review input { accent-color: var(--green-700); }

.ai-answer-text { margin-bottom: 8px; }
.ai-source-list {
  margin: 0 0 8px 16px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.ai-meta {
  font-size: 10.5px;
  color: var(--ink-3);
  line-height: 1.5;
  border-top: 1px dashed var(--line);
  padding-top: 7px;
}

.ai-badge-sm {
  font-size: 10.5px;
  color: var(--brass-600);
  border: 1px solid var(--brass-200);
  background: var(--amber-bg);
  border-radius: 3px;
  padding: 1px 6px;
}

.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; }
.page-title { font-size: 19px; font-weight: 700; color: var(--green-950); letter-spacing: 0.02em; }
.page-subtitle { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.page-title-actions { display: flex; gap: 8px; }

/* ============ Cards & panels ============ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--green-900);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title::before {
  content: "";
  width: 3px;
  height: 13px;
  background: var(--brass-400);
  border-radius: 1px;
}

.card-head .head-extra { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.card-body { padding: 12px; }

.link-btn {
  background: none;
  border: none;
  color: var(--green-700);
  font-size: 12px;
}

.link-btn:hover { color: var(--green-900); text-decoration: underline; }

/* ============ Tags ============ */
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 3px;
  padding: 1px 7px;
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
}

.tag-high { background: var(--red-bg); color: var(--red-600); border: 1px solid #EAC5C0; }
.tag-mid { background: var(--amber-bg); color: var(--amber-600); border: 1px solid #EBD9AE; }
.tag-low { background: var(--blue-bg); color: var(--blue-600); border: 1px solid #C9D8E5; }
.tag-green { background: var(--green-50); color: var(--green-700); border: 1px solid #C6D9CB; }
.tag-grey { background: var(--grey-bg); color: var(--ink-3); border: 1px solid var(--line); }
.tag-solid-high { background: var(--red-500); color: #fff; }

/* delta badges */
.delta { font-size: 11px; font-family: var(--mono); }
.delta.up { color: var(--red-500); }
.delta.down { color: var(--green-700); }
.delta.good { color: var(--green-700); }
.delta.bad { color: var(--red-500); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  background: var(--paper);
  border-bottom: 1px double var(--line-strong);
  padding: 7px 10px;
  white-space: nowrap;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #F0ECDD;
  font-size: 12px;
  vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--green-50); cursor: pointer; }
.data-table tbody tr.selected { background: var(--green-100); }

.data-table .cell-main { font-weight: 600; color: var(--ink); }
.data-table .cell-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.data-table td.amount { text-align: right; font-family: var(--mono); font-weight: 600; }
.data-table td.amount.risk { color: var(--red-500); }
.data-table td.amount.warn { color: var(--amber-600); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 4px;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
}

.btn:hover { border-color: var(--brass-400); color: var(--green-800); }

.btn-primary {
  background: var(--green-800);
  border-color: var(--green-800);
  color: #F5EFDD;
}

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

.btn-sm { padding: 2px 9px; font-size: 11.5px; }

.op-btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--green-800);
  border-radius: 3px;
  font-size: 11.5px;
  padding: 2px 9px;
}

.op-btn:hover { border-color: var(--green-700); background: var(--green-50); }

/* ============ Form controls ============ */
.select, .input {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}

.select:focus, .input:focus, textarea.input:focus { border-color: var(--green-700); }

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-item { display: flex; align-items: center; gap: 5px; }
.filter-item label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ============ Pagination ============ */
.pagination {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-2);
}

.pagination .page-btn {
  min-width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #fff;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--ink-2);
}

.pagination .page-btn.current {
  background: var(--green-800);
  border-color: var(--green-800);
  color: #fff;
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--green-900);
  color: #F5EFDD;
  border: 1px solid var(--brass-500);
  border-radius: 4px;
  padding: 8px 18px;
  font-size: 12.5px;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Misc ============ */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot.red { background: var(--red-500); }
.dot.amber { background: var(--brass-400); }
.dot.green { background: var(--green-600); }
.dot.grey { background: #B9B8AC; }

.divider-v { width: 1px; align-self: stretch; background: var(--line); }

.scroll-thin { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

.scroll-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
