:root {
  --ink: #1b1b19;
  --muted: #76756f;
  --line: #e9e6df;
  --canvas: #f5f3ee;
  --paper: #fffefa;
  --paper-strong: #ffffff;
  --gold: #b58b46;
  --gold-soft: #f4ead7;
  --sage: #718276;
  --sage-soft: #e9efea;
  --danger: #a8584f;
  --danger-soft: #f7e9e6;
  --shadow: 0 18px 48px rgba(34, 31, 24, 0.07);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 248px;
  flex-direction: column;
  padding: 28px 18px 20px;
  color: #eeeae0;
  background:
    radial-gradient(circle at 25% 8%, rgba(181, 139, 70, 0.12), transparent 28%),
    #1a1a18;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 8px 42px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(214, 180, 116, 0.7);
  border-radius: 50%;
  color: #d7b578;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-style: italic;
}

.brand-mark.large { width: 54px; height: 54px; margin: 0 auto 20px; font-size: 28px; }
.brand-copy { display: flex; flex-direction: column; letter-spacing: 0.01em; }
.brand-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 21px; font-weight: 500; }
.brand-copy small { color: #8f8d86; font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase; }

.nav-list { display: grid; gap: 6px; }
.nav-link {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #a9a79f;
  text-decoration: none;
  transition: 160ms ease;
}
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.045); }
.nav-link.is-active { color: #fff; border-color: rgba(215, 181, 120, 0.12); background: rgba(255, 255, 255, 0.075); }
.nav-icon { display: grid; width: 22px; place-items: center; color: #d3af70; font-size: 18px; }
.nav-badge { min-width: 23px; margin-left: auto; padding: 2px 7px; border-radius: 999px; color: #d9e5db; background: rgba(113, 130, 118, 0.26); font-size: 11px; text-align: center; }
.nav-badge.is-warm { color: #e9d4ad; background: rgba(181, 139, 70, 0.22); }

.sidebar-spacer { flex: 1; }
.system-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 6px 14px;
  padding: 13px 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #82a68c; box-shadow: 0 0 0 4px rgba(130, 166, 140, 0.12); }
.system-card div, .profile-button span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.system-card strong, .profile-button strong { font-size: 11px; font-weight: 600; }
.system-card small, .profile-button small { overflow: hidden; color: #77766f; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.profile-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border: 0;
  border-radius: 12px;
  color: #eeece6;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.profile-button:hover { background: rgba(255, 255, 255, 0.04); }
.profile-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; color: #e7d7ba; background: #3c372f; font-size: 10px; }
.profile-more { margin-left: auto; color: #66655f; letter-spacing: 0.1em; }

.main-area { min-height: 100vh; margin-left: 248px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  height: 74px;
  align-items: center;
  justify-content: center;
  padding: 0 42px;
  border-bottom: 1px solid rgba(222, 219, 211, 0.8);
  background: rgba(245, 243, 238, 0.9);
  backdrop-filter: blur(18px);
}
.mobile-brand { display: none; }
.search-box {
  display: flex;
  width: min(480px, 52vw);
  height: 42px;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #85837c;
  background: rgba(255, 255, 255, 0.72);
}
.search-box:focus-within { border-color: #cab17f; box-shadow: 0 0 0 3px rgba(181, 139, 70, 0.08); }
.search-box input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-box input::placeholder { color: #aaa8a1; }
kbd { padding: 2px 6px; border: 1px solid #dedbd4; border-radius: 5px; color: #99978f; background: #f7f6f2; font-family: inherit; font-size: 10px; }
.topbar-actions { position: absolute; right: 42px; display: flex; align-items: center; gap: 10px; }
.live-pill { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border-radius: 999px; color: #647668; background: var(--sage-soft); font-size: 11px; font-weight: 600; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: #789681; box-shadow: 0 0 0 3px rgba(120, 150, 129, 0.13); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; color: #6e6c66; background: var(--paper); cursor: pointer; font-size: 17px; transition: 150ms ease; }
.icon-button:hover { transform: translateY(-1px); color: var(--ink); box-shadow: 0 6px 18px rgba(34, 31, 24, 0.08); }
.icon-button.is-loading { animation: rotate 800ms linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.content-view { display: none; max-width: 1480px; margin: 0 auto; padding: 42px; }
.content-view.is-active { display: block; animation: view-in 220ms ease; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 2px 0 5px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 3vw, 43px); font-weight: 500; letter-spacing: -0.035em; line-height: 1.05; }
.page-heading p { margin: 0; color: var(--muted); }
.page-heading .eyebrow { color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.compact-heading { align-items: center; }
.sync-copy { padding-bottom: 5px; color: #99978f; font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card {
  position: relative;
  min-height: 144px;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 5px 20px rgba(34, 31, 24, 0.025);
}
.metric-card.metric-primary { color: #f3efe6; border-color: #242421; background: #1c1c1a; }
.metric-label { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.03em; }
.metric-primary .metric-label { color: #aaa79f; }
.metric-card > strong { display: block; margin: 10px 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 42px; font-weight: 500; line-height: 1; }
.metric-note { color: #929088; font-size: 11px; }
.metric-note b { color: var(--ink); }
.metric-note.is-danger { color: var(--danger); }
.metric-note.is-warm { color: #9a7439; }
.metric-glyph { position: absolute; right: 20px; bottom: 17px; display: grid; width: 35px; height: 35px; place-items: center; border-radius: 50%; color: #99783f; background: var(--gold-soft); font-family: Georgia, serif; font-size: 17px; }
.metric-primary .metric-glyph { color: #d8b675; background: rgba(216, 182, 117, 0.12); }
.metric-glyph.is-danger { color: var(--danger); background: var(--danger-soft); font-family: inherit; font-weight: 700; }
.metric-glyph.is-warm { color: #967138; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(310px, 0.8fr); gap: 16px; margin-bottom: 16px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 5px 22px rgba(34, 31, 24, 0.025); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 21px 22px 14px; }
.panel-header h2 { margin: 0 0 3px; font-family: Georgia, "Times New Roman", serif; font-size: 20px; font-weight: 500; }
.panel-header p { margin: 0; color: #96938c; font-size: 11px; }
.panel-header a { color: #96713a; font-size: 11px; text-decoration: none; }
.count-bubble { display: grid; min-width: 28px; height: 28px; place-items: center; border-radius: 50%; color: var(--danger); background: var(--danger-soft); font-size: 11px; font-weight: 700; }

.stage-chart { display: grid; gap: 14px; padding: 11px 22px 23px; }
.stage-row { display: grid; grid-template-columns: 106px minmax(100px, 1fr) 28px; align-items: center; gap: 12px; }
.stage-name { overflow: hidden; color: #56544f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.stage-track { height: 8px; overflow: hidden; border-radius: 999px; background: #efede8; }
.stage-bar { height: 100%; min-width: 8px; border-radius: 999px; background: linear-gradient(90deg, #c4a266, #ad8341); transform-origin: left; animation: grow 600ms ease both; }
.stage-bar.has-overdue { background: linear-gradient(90deg, #c78372, #a8584f); }
.stage-value { color: #4e4c47; font-family: Georgia, serif; font-size: 16px; text-align: right; }
@keyframes grow { from { transform: scaleX(0); } }

.attention-list { padding: 4px 12px 14px; }
.attention-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 10px; border-top: 1px solid #f0eee9; }
.attention-item:first-child { border-top: 0; }
.jewel-thumb { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #e6dfd1; border-radius: 10px; color: #9a773c; background: linear-gradient(145deg, #fffdf8, #eee7da); font-family: Georgia, serif; font-size: 12px; }
.attention-copy { min-width: 0; }
.attention-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.attention-copy small { display: block; overflow: hidden; color: #99968f; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.due-label { color: var(--danger); font-size: 9px; font-weight: 700; text-transform: uppercase; }

.activity-panel { overflow: hidden; }
.confirmed-label { color: #718276; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.activity-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 2px 12px 16px; }
.activity-item { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 13px 10px; border-top: 1px solid #f0eee9; }
.activity-item:nth-child(1), .activity-item:nth-child(2) { border-top: 0; }
.activity-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: #76603c; background: var(--gold-soft); font-size: 11px; }
.activity-copy { min-width: 0; }
.activity-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.activity-copy small { display: block; color: #95928b; font-size: 10px; }
.activity-time { color: #aaa79f; font-size: 9px; }

.filter-group { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, 0.55); }
.filter-button { padding: 7px 11px; border: 0; border-radius: 8px; color: #85827b; background: transparent; cursor: pointer; font-size: 11px; }
.filter-button.is-active { color: var(--ink); background: var(--paper-strong); box-shadow: 0 2px 8px rgba(34, 31, 24, 0.07); }
.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 15px 18px; border-bottom: 1px solid var(--line); color: #9b9891; font-size: 9px; font-weight: 700; letter-spacing: 0.09em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 18px; border-bottom: 1px solid #efede8; color: #5d5b55; font-size: 11px; vertical-align: middle; }
tbody tr { transition: 140ms ease; }
tbody tr:hover { background: #faf8f3; }
tbody tr:last-child td { border-bottom: 0; }
.product-cell { display: flex; min-width: 170px; align-items: center; gap: 10px; }
.product-copy strong, .client-cell strong { display: block; color: var(--ink); font-size: 11px; }
.product-copy small, .client-cell small { color: #99968f; font-size: 9px; }
.stage-chip, .status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; color: #5f7465; background: var(--sage-soft); font-size: 9px; font-weight: 700; }
.stage-chip.blocked { color: var(--danger); background: var(--danger-soft); }
.progress-cell { min-width: 110px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 5px; color: #8c8982; font-size: 9px; }
.progress-track { height: 4px; overflow: hidden; border-radius: 99px; background: #eceae5; }
.progress-fill { height: 100%; border-radius: inherit; background: #b59050; }
.deadline { white-space: nowrap; }
.deadline.is-overdue { color: var(--danger); font-weight: 700; }
.table-empty { padding: 55px; color: #96938c; text-align: center; }

.reviewer-select { display: grid; gap: 4px; color: #96938c; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.reviewer-select select { min-width: 190px; padding: 9px 30px 9px 11px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: var(--paper); text-transform: none; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.review-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.review-card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid #efede8; }
.review-card-head span:first-child { color: #92703a; font-size: 9px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.confidence { padding: 5px 8px; border-radius: 999px; color: #76603c; background: var(--gold-soft); font-size: 9px; font-weight: 700; }
.review-message { margin: 0; padding: 20px 20px 16px; color: #44423e; font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.5; }
.review-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 20px 18px; }
.review-fact { padding: 11px; border: 1px solid #ebe7de; border-radius: 11px; background: #faf8f3; }
.review-fact small { display: block; margin-bottom: 3px; color: #a09d95; font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase; }
.review-fact strong { font-size: 12px; }
.review-meta { display: flex; justify-content: space-between; padding: 0 20px 18px; color: #9a978f; font-size: 9px; }
.review-actions { display: flex; gap: 8px; padding: 15px 20px; border-top: 1px solid #efede8; background: #fbfaf6; }
.action-button { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: #66635d; background: var(--paper-strong); cursor: pointer; font-size: 10px; font-weight: 700; transition: 140ms ease; }
.action-button:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(34, 31, 24, 0.07); }
.action-button.confirm { color: #55705d; border-color: #dce8de; background: #edf4ee; }
.action-button.reject { color: #98534b; }
.action-button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.review-empty { padding: 90px 20px; color: #8c8982; text-align: center; }
.review-empty > span { display: grid; width: 56px; height: 56px; margin: 0 auto 14px; place-items: center; border-radius: 50%; color: #6f8374; background: var(--sage-soft); font-size: 20px; }
.review-empty h2 { margin: 0 0 4px; color: var(--ink); font-family: Georgia, serif; font-weight: 500; }
.review-empty p { margin: 0; font-size: 11px; }

.access-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(20, 20, 18, 0.78); backdrop-filter: blur(14px); }
.access-overlay[hidden] { display: none; }
.access-dialog { width: min(420px, 100%); padding: 36px; border: 1px solid rgba(181, 139, 70, 0.3); border-radius: 22px; background: #fffefa; box-shadow: 0 40px 100px rgba(0, 0, 0, 0.32); text-align: center; }
.access-dialog h2 { margin: 5px 0 8px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.access-dialog > p:not(.eyebrow):not(.form-error) { margin: 0 auto 22px; color: #77746d; font-size: 11px; }
.access-dialog code { padding: 1px 4px; border-radius: 4px; background: #f1eee7; font-size: 9px; }
.access-dialog label { display: grid; gap: 6px; color: #77746d; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
.access-dialog input { width: 100%; height: 45px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #fff; }
.access-dialog input:focus { border-color: #ba9556; box-shadow: 0 0 0 3px rgba(181, 139, 70, 0.09); }
.primary-button { width: 100%; margin-top: 12px; padding: 12px; border: 0; border-radius: 10px; color: #fff; background: #1c1c1a; cursor: pointer; font-weight: 700; }
.access-dialog > small { display: block; margin-top: 12px; color: #aaa79f; font-size: 9px; }
.form-error { min-height: 16px; margin: 5px 0 0 !important; color: var(--danger) !important; text-align: left; }

.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 120; display: grid; gap: 8px; }
.toast { min-width: 240px; padding: 12px 14px; border: 1px solid #dfe8e0; border-radius: 11px; color: #516656; background: #f4faf5; box-shadow: var(--shadow); font-size: 11px; animation: toast-in 180ms ease; }
.toast.error { color: #8f4d47; border-color: #eedbd7; background: #fff5f3; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.empty-copy { padding: 42px 10px; color: #9b9891; font-size: 11px; text-align: center; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .activity-list { grid-template-columns: 1fr; }
  .activity-item:nth-child(2) { border-top: 1px solid #f0eee9; }
}

@media (max-width: 760px) {
  .sidebar { inset: auto 0 0; width: auto; height: 64px; flex-direction: row; padding: 7px 12px; border-top: 1px solid #32322f; }
  .brand, .sidebar-spacer, .system-card, .profile-button { display: none; }
  .nav-list { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .nav-link { min-height: 50px; flex-direction: column; justify-content: center; gap: 1px; padding: 3px; font-size: 9px; }
  .nav-icon { height: 20px; font-size: 15px; }
  .nav-badge { position: absolute; margin: -25px 0 0 32px; }
  .main-area { margin-left: 0; padding-bottom: 64px; }
  .topbar { height: 64px; justify-content: space-between; padding: 0 16px; }
  .mobile-brand { display: flex; align-items: center; gap: 8px; font-family: Georgia, serif; }
  .mobile-brand .brand-mark { width: 30px; height: 30px; flex-basis: 30px; font-size: 16px; }
  .search-box { width: 42px; padding: 0 12px; border-radius: 50%; }
  .search-box input, .search-box kbd { display: none; }
  .search-box:focus-within { position: absolute; inset: 10px 62px 10px 12px; width: auto; border-radius: 12px; background: #fff; }
  .search-box:focus-within input { display: block; }
  .topbar-actions { position: static; }
  .live-pill { display: none; }
  .content-view { padding: 28px 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .sync-copy { display: none; }
  .page-heading h1 { font-size: 34px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .metric-card { min-height: 125px; padding: 17px; }
  .metric-card > strong { font-size: 34px; }
  .metric-glyph { right: 14px; bottom: 13px; width: 30px; height: 30px; }
  .stage-row { grid-template-columns: 88px minmax(80px, 1fr) 25px; }
  .review-grid { grid-template-columns: 1fr; }
  .filter-group { width: 100%; }
  .filter-button { flex: 1; }
  .reviewer-select { width: 100%; }
  .reviewer-select select { width: 100%; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 116px; }
  .metric-label { max-width: 100px; }
  .metric-glyph { display: none; }
  .review-facts { grid-template-columns: 1fr; }
  .access-dialog { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
