:root {
  --ink: #172420;
  --muted: #5f6e68;
  --line: #dce4df;
  --line-strong: #c7d3cd;
  --paper: #ffffff;
  --canvas: #f4f6f3;
  --forest: #173a34;
  --forest-2: #24594f;
  --mint: #dcece5;
  --mint-2: #eef7f2;
  --gold: #d6a94d;
  --gold-soft: #f6ead1;
  --red: #9b3b34;
  --red-soft: #f7e4e1;
  --blue: #255f86;
  --blue-soft: #e5f0f7;
  --shadow: 0 10px 30px rgba(28, 54, 46, .08);
  --radius: 16px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--forest-2); }

.skip-link { position: fixed; z-index: 1000; left: 16px; top: -80px; padding: 10px 14px; background: var(--paper); color: var(--ink); border-radius: 8px; }
.skip-link:focus { top: 12px; }

.demo-banner { height: 34px; padding: 0 22px; display: flex; align-items: center; justify-content: center; gap: 12px; background: #f0ddb2; color: #573b09; font-size: 12px; letter-spacing: .01em; }
.demo-banner strong { letter-spacing: .08em; font-size: 11px; }

.app-shell { min-height: calc(100vh - 34px); display: grid; grid-template-columns: 250px 1fr; }
.sidebar { position: sticky; top: 0; height: calc(100vh - 34px); padding: 24px 16px 18px; display: flex; flex-direction: column; background: var(--forest); color: #fff; overflow: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 25px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; font-family: Georgia, serif; font-size: 19px; }
.brand strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 22px; font-weight: 600; }
.brand small { display: block; margin-top: 2px; color: #bcd0c8; font-size: 11px; }
.nav-label { margin: 18px 11px 7px; color: #8eaaa0; font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: #dce9e4; text-align: left; font-size: 14px; transition: background .15s ease, color .15s ease; }
.nav-item:hover, .nav-item:focus-visible { background: rgba(255,255,255,.08); color: #fff; outline: none; }
.nav-item.active { background: #fff; color: var(--forest); font-weight: 700; box-shadow: 0 8px 18px rgba(0,0,0,.12); }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-badge { margin-left: auto; min-width: 21px; padding: 2px 6px; border-radius: 99px; background: var(--gold); color: #422e07; font-size: 10px; font-weight: 800; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.source-dot { display: flex; align-items: center; gap: 8px; color: #c9dbd4; font-size: 11px; }
.source-dot i { width: 8px; height: 8px; border-radius: 50%; background: #78d3a7; box-shadow: 0 0 0 4px rgba(120,211,167,.12); }
.link-button { border: 0; padding: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.sidebar-footer .link-button { margin-top: 12px; color: #fff; font-size: 12px; }

.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); }
.breadcrumbs { color: var(--muted); font-size: 13px; }
.breadcrumbs strong { color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { position: relative; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); }
.icon-button:hover { border-color: var(--forest-2); }
.notification-count { position: absolute; right: -4px; top: -5px; width: 18px; height: 18px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: var(--red); color: #fff; font-size: 9px; font-weight: 800; }
.role-switcher { display: flex; align-items: center; gap: 7px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--muted); font-size: 11px; }
.role-switcher select { max-width: 175px; border: 0; padding: 6px 24px 6px 4px; background: transparent; color: var(--ink); font-weight: 700; outline: none; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--forest); color: #fff; font-size: 12px; font-weight: 800; }
.mobile-menu { display: none; }

main { padding: 32px 34px 60px; }
.page { max-width: 1450px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.eyebrow { margin: 0 0 7px; color: var(--forest-2); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(30px, 3vw, 43px); line-height: 1.05; font-weight: 600; letter-spacing: -.025em; }
h2 { margin-bottom: 14px; font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 600; }
h3 { margin-bottom: 8px; font-size: 15px; }
.lead { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 13px; text-decoration: none; box-shadow: 0 1px 0 rgba(0,0,0,.02); }
.button:hover { border-color: var(--forest-2); }
.button.primary { border-color: var(--forest); background: var(--forest); color: #fff; }
.button.primary:hover { background: var(--forest-2); }
.button.danger { border-color: #d9a19b; color: var(--red); }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 11px; }
.button:disabled { cursor: not-allowed; opacity: .5; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card, .card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.stat-card { position: relative; min-height: 137px; padding: 20px; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; width: 110px; height: 110px; right: -55px; bottom: -55px; border-radius: 50%; background: var(--mint-2); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { display: block; margin: 10px 0 6px; font-family: Georgia, serif; font-size: 32px; font-weight: 600; }
.stat-trend { color: var(--forest-2); font-size: 11px; }
.stat-trend.warn { color: #8d5e0a; }
.stat-trend.danger { color: var(--red); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 18px; }
.grid-even { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.card { padding: 21px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.card-head h2, .card-head h3 { margin-bottom: 3px; }
.card-head p { margin: 0; color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.cell-title { display: block; color: var(--ink); font-weight: 750; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.text-right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; background: var(--mint); color: var(--forest); font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.warn { background: var(--gold-soft); color: #795008; }
.badge.danger { background: var(--red-soft); color: var(--red); }
.badge.info { background: var(--blue-soft); color: var(--blue); }
.badge.neutral { background: #edf0ee; color: #58625e; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }

.progress { height: 7px; overflow: hidden; border-radius: 999px; background: #e7ece9; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--forest-2); }
.progress-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; }
.progress-line small { color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; margin-left: 7px; padding: 0 0 18px 25px; border-left: 1px solid var(--line-strong); }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 2px; width: 9px; height: 9px; border: 2px solid var(--paper); border-radius: 50%; background: var(--forest-2); box-shadow: 0 0 0 1px var(--forest-2); }
.timeline strong { display: block; font-size: 12px; }
.timeline small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }

.notice { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid #c7ddd4; border-radius: 12px; background: var(--mint-2); color: #254d43; font-size: 12px; line-height: 1.5; }
.notice.warn { border-color: #e8d19c; background: #fff8e8; color: #6d4b0b; }
.notice.danger { border-color: #e7bbb6; background: #fff1ef; color: #7e312b; }
.notice strong { display: block; margin-bottom: 2px; }

.filters { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, .3fr)); gap: 10px; margin-bottom: 16px; }
.field { display: grid; gap: 6px; }
.field label, .field > span { color: var(--muted); font-size: 11px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--paper); color: var(--ink); outline: none; }
input, select { min-height: 40px; padding: 8px 11px; }
textarea { min-height: 110px; padding: 10px 11px; line-height: 1.5; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--forest-2); box-shadow: 0 0 0 3px rgba(36,89,79,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.input-action { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.help { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.module-cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.module-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); text-align: left; }
.module-card:hover { border-color: var(--forest-2); box-shadow: var(--shadow); }
.module-card-icon { width: 36px; height: 36px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 10px; background: var(--mint); color: var(--forest); font-weight: 800; }
.module-card strong { display: block; margin-bottom: 5px; }
.module-card small { color: var(--muted); line-height: 1.4; }

.steps { display: flex; gap: 4px; margin: 0 0 24px; padding: 0; list-style: none; overflow-x: auto; }
.steps li { min-width: 128px; flex: 1; padding: 11px 10px; border-bottom: 3px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; text-align: center; }
.steps li.done { border-color: #77b39c; color: var(--forest-2); }
.steps li.active { border-color: var(--gold); color: var(--ink); }
.check-list { display: grid; gap: 8px; }
.check-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 10px; }
.check-item strong { font-size: 12px; }
.check-item small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.check { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--mint); color: var(--forest-2); font-size: 12px; font-weight: 900; }
.check.todo { background: var(--gold-soft); color: #815706; }

.integration-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.integration { min-height: 145px; padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.integration-top { display: flex; justify-content: space-between; gap: 8px; }
.integration h3 { margin: 13px 0 5px; }
.integration p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.status-light { width: 10px; height: 10px; border-radius: 50%; background: #58ad82; box-shadow: 0 0 0 4px rgba(88,173,130,.12); }
.status-light.simulated { background: var(--gold); box-shadow: 0 0 0 4px rgba(214,169,77,.16); }

.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.empty strong { display: block; margin-bottom: 6px; color: var(--ink); }
.metric-list { display: grid; gap: 10px; }
.metric { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.metric:last-child { padding-bottom: 0; border-bottom: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 13px; }
.amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

.detail-hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 20px; margin-bottom: 18px; border-radius: var(--radius); background: linear-gradient(120deg, var(--forest), #295e53); color: #fff; }
.detail-hero .eyebrow { color: #bcd4ca; }
.detail-hero h1 { font-size: 32px; }
.detail-hero p { margin: 0; color: #d5e4de; }
.hero-metric { align-self: center; text-align: right; }
.hero-metric strong { display: block; font-family: Georgia, serif; font-size: 30px; }
.hero-metric small { color: #c8dcd4; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(10,27,23,.58); backdrop-filter: blur(4px); }
.modal { width: min(720px, 100%); max-height: min(820px, 90vh); overflow: auto; border-radius: 18px; background: var(--paper); box-shadow: 0 24px 80px rgba(0,0,0,.28); }
.modal.wide { width: min(980px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.modal-head h2 { margin: 0 0 4px; }
.modal-head p { margin: 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 22px; }
.modal-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 15px 22px; border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }

#toast-root { position: fixed; z-index: 200; right: 24px; bottom: 24px; display: grid; gap: 10px; }
.toast { max-width: 380px; padding: 13px 16px; border-radius: 11px; background: var(--forest); color: #fff; box-shadow: 0 15px 45px rgba(0,0,0,.22); font-size: 12px; animation: toast-in .2s ease-out; }
.toast.error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton { position: relative; overflow: hidden; min-height: 18px; border-radius: 7px; background: #edf1ef; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.25s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.source-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.source-note::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #58ad82; }

@media (max-width: 1150px) {
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .integration-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .module-cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 860px) {
  .demo-banner { min-height: 40px; height: auto; padding: 7px 12px; text-align: center; }
  .demo-banner span { display: none; }
  .app-shell { grid-template-columns: 1fr; min-height: calc(100vh - 40px); }
  .sidebar { position: fixed; z-index: 50; top: 40px; left: 0; width: 270px; height: calc(100vh - 40px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 15px 0 45px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; place-items: center; }
  .topbar { padding: 0 16px; }
  .breadcrumbs { display: none; }
  .role-switcher span { display: none; }
  main { padding: 24px 16px 50px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid-2, .grid-even { grid-template-columns: minmax(0,1fr); }
  .grid-3 { grid-template-columns: minmax(0,1fr); }
  .filters { grid-template-columns: 1fr; }
  .integration-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .stats, .module-cards, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .role-switcher select { max-width: 125px; }
  .avatar, .notification-button { display: none; }
  .detail-hero { grid-template-columns: 1fr; }
  .hero-metric { text-align: left; }
  h1 { font-size: 32px; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: 96vh; border-radius: 14px; }
}

@media print {
  .demo-banner, .sidebar, .topbar, .actions, .button, #toast-root { display: none !important; }
  .app-shell { display: block; }
  main { padding: 0; }
  .card, .stat-card { box-shadow: none; break-inside: avoid; }
}
