:root {
  --ink: #17312a;
  --muted: #68766f;
  --forest: #173f35;
  --forest-2: #245c4c;
  --sage: #dce8df;
  --cream: #f5f2e9;
  --paper: #fffdf8;
  --line: #dfe4dd;
  --copper: #b86d43;
  --gold: #c69a54;
  --red: #a13d3d;
  --amber: #b77520;
  --green: #2c7a55;
  --shadow: 0 18px 50px rgba(21, 49, 41, 0.08);
  --radius: 18px;
  --sidebar: 256px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(184, 109, 67, 0.35); outline-offset: 2px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; padding: .75rem 1rem; color: white; background: var(--forest); border-radius: 10px; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 22px;
  color: #eef5f0;
  background: var(--forest);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark { display: inline-grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; color: white; font-family: Georgia, serif; font-size: 13px; letter-spacing: .12em; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 16px; font-weight: 500; }
.brand small { margin-top: 3px; color: #adcbc0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.nav-list { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: baseline; justify-content: space-between; padding: 13px 14px; border: 0; border-radius: 12px; color: #c9ddd5; background: transparent; text-align: left; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-item:hover { color: white; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.is-active { color: white; background: rgba(255,255,255,.12); box-shadow: inset 3px 0 var(--gold); }
.nav-item span { font-weight: 700; }
.nav-item small { color: inherit; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; opacity: .7; }
.sidebar-foot { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot p { margin: 10px 0 0; color: #9fc0b4; font-size: 11px; line-height: 1.55; }
.system-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(183,117,32,.14); }
.status-dot.is-good { background: #70c996; box-shadow: 0 0 0 4px rgba(112,201,150,.14); }
.status-dot.is-bad { background: #f08b85; box-shadow: 0 0 0 4px rgba(240,139,133,.15); }

.workspace { min-height: 100vh; margin-left: var(--sidebar); padding: 36px clamp(24px, 3.5vw, 58px) 64px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 7px; color: var(--copper); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin: 0; font-size: clamp(30px, 3vw, 44px); line-height: 1.05; }
h2 { margin: 0; font-size: 24px; }
.page-subtitle, .section-head p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box input { width: min(28vw, 280px); min-height: 42px; padding: 0 58px 0 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: rgba(255,255,255,.7); }
.search-box kbd { position: absolute; right: 10px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--paper); font: 10px ui-monospace, monospace; }
.account { display: flex; align-items: center; gap: 9px; min-width: 150px; padding-left: 7px; }
.account-avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: white; background: var(--copper); font-family: Georgia, serif; }
.account strong, .account small { display: block; max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account strong { font-size: 12px; }
.account small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 11px; font-size: 12px; font-weight: 800; text-decoration: none; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { display: inline-flex; align-items: center; color: white; background: var(--forest); }
.button-secondary { border-color: var(--line); color: var(--ink); background: var(--paper); }
.button-danger { color: white; background: var(--red); }
.button-small { min-height: 32px; padding: 0 10px; font-size: 11px; }
.text-button { padding: 5px 0; border: 0; color: var(--copper); background: transparent; font-size: 12px; font-weight: 800; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--paper); font-size: 24px; line-height: 1; }

.notice { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; padding: 17px 19px; border: 1px solid #ead4b0; border-radius: 14px; background: #fff7e9; }
.notice strong { font-size: 14px; }
.notice p { margin: 3px 0 0; color: #715d3b; font-size: 12px; }
.notice.is-error { border-color: #edc5c5; background: #fff1f1; }

.view { display: none; animation: reveal .24s ease both; }
.view.is-active { display: block; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.metric-card { min-height: 145px; padding: 22px; border: 1px solid rgba(23,63,53,.08); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.metric-card p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 16px 0 8px; font-family: Georgia, serif; font-size: 37px; font-weight: 500; }
.metric-card small { color: var(--muted); font-size: 11px; }
.metric-card-accent { color: white; background: var(--forest); }
.metric-card-accent p, .metric-card-accent small { color: #bad1c8; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 18px; }
.panel { min-height: 280px; padding: 23px; border: 1px solid rgba(23,63,53,.08); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.updated-time { color: var(--muted); font-size: 11px; }

.pipeline { display: grid; grid-template-columns: repeat(4, minmax(95px, 1fr)); gap: 10px; }
.pipeline-stage { position: relative; min-height: 105px; padding: 15px 13px; border: 1px solid var(--line); border-radius: 13px; background: #fbfaf5; }
.pipeline-stage::after { content: ""; position: absolute; left: 13px; bottom: 0; width: var(--stage-width, 0%); max-width: calc(100% - 26px); height: 3px; border-radius: 2px; background: var(--copper); }
.pipeline-stage strong { display: block; margin-bottom: 8px; font-family: Georgia, serif; font-size: 27px; font-weight: 500; }
.pipeline-stage span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }

.health-list { display: grid; gap: 9px; }
.health-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.health-item:last-child { border-bottom: 0; }
.health-item strong { font-size: 13px; }
.health-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.health-state { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: 10px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.health-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.health-state.is-warning { color: var(--amber); }
.health-state.is-error { color: var(--red); }

.record-list { display: grid; gap: 2px; }
.record-row { display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 1fr) auto; align-items: center; gap: 14px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.record-row:last-child { border-bottom: 0; }
.record-row strong, .record-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-row strong { font-size: 13px; }
.record-row span, .record-row time { color: var(--muted); font-size: 11px; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 8px 0 20px; }
.section-head h2 { font-size: 32px; }
.section-head select { min-width: 190px; min-height: 42px; padding: 0 36px 0 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: var(--paper); }
.table-card { min-height: 300px; overflow: hidden; border: 1px solid rgba(23,63,53,.08); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #faf9f4; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: #fbfaf6; }
.table-primary { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.table-secondary { display: block; max-width: 340px; margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 14px 16px; color: var(--muted); font-size: 11px; }
.pagination div { display: flex; gap: 7px; }
.empty-state { margin: 0; padding: 38px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.loading-bar { height: 3px; overflow: hidden; background: var(--sage); }
.loading-bar::after { content: ""; display: block; width: 38%; height: 100%; background: var(--copper); animation: load 1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-110%); } to { transform: translateX(360%); } }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 9px; border-radius: 999px; color: #35584c; background: var(--sage); font-size: 9px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.badge.is-warning { color: #7b5317; background: #f7e8c9; }
.badge.is-danger { color: #883b3b; background: #f7dede; }
.badge.is-success { color: #256443; background: #dcefe3; }
.badge.is-neutral { color: #5f6864; background: #e9ece9; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; }

dialog { padding: 0; border: 0; color: var(--ink); background: transparent; }
dialog::backdrop { background: rgba(9,28,22,.52); backdrop-filter: blur(3px); }
.detail-dialog { width: min(720px, calc(100vw - 30px)); max-height: calc(100vh - 30px); }
.dialog-shell, .confirm-shell { overflow: hidden; border-radius: 20px; background: var(--paper); box-shadow: 0 28px 80px rgba(7,30,23,.28); }
.dialog-shell header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.dialog-body { max-height: 72vh; overflow-y: auto; padding: 22px 24px 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.detail-field { padding: 13px; border: 1px solid var(--line); border-radius: 12px; }
.detail-field dt { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.detail-field dd { margin: 0; overflow-wrap: anywhere; font-size: 12px; line-height: 1.45; }
.dialog-section { margin-top: 24px; }
.dialog-section h3 { margin: 0 0 10px; font-family: Georgia, serif; font-size: 19px; font-weight: 500; }
.message-list { display: grid; gap: 9px; }
.message { max-width: 86%; padding: 11px 13px; border-radius: 13px 13px 13px 3px; background: #edf2ed; }
.message.is-outbound { margin-left: auto; border-radius: 13px 13px 3px 13px; background: #e5efe9; }
.message p { margin: 0; white-space: pre-wrap; font-size: 12px; line-height: 1.45; }
.message small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; }
.confirm-dialog { width: min(460px, calc(100vw - 30px)); }
.confirm-shell { padding: 25px; }
.confirm-shell h2 { font-size: 25px; }
.confirm-shell > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; max-width: 360px; padding: 13px 16px; border-radius: 12px; color: white; background: var(--forest); box-shadow: 0 14px 40px rgba(10,35,28,.2); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: none; }
.toast.is-error { background: var(--red); }

.payment-return { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--forest); }
.payment-return-card { width: min(570px, 100%); padding: clamp(30px, 6vw, 58px); border-radius: 24px; background: var(--paper); box-shadow: 0 28px 80px rgba(0,0,0,.22); text-align: center; }
.payment-return-card .brand-mark { margin-bottom: 24px; color: var(--forest); border-color: var(--forest); }
.payment-return-card h1 { font-size: 46px; }
.payment-return-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.payment-return-card .security-note { margin-top: 24px; padding: 14px; border-radius: 12px; background: var(--sage); font-size: 11px; }

@media (max-width: 1120px) {
  :root { --sidebar: 215px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
  .account { display: none; }
}

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { position: sticky; inset: 0; width: 100%; height: auto; padding: 13px 14px 10px; }
  .brand { padding: 0 2px 10px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 10px; }
  .brand small, .sidebar-foot { display: none; }
  .nav-list { grid-template-columns: repeat(7, minmax(86px, 1fr)); overflow-x: auto; padding-bottom: 4px; }
  .nav-item { display: block; padding: 9px 10px; text-align: center; }
  .nav-item small { display: none; }
  .nav-item.is-active { box-shadow: inset 0 -3px var(--gold); }
  .workspace { margin-left: 0; padding: 24px 16px 45px; }
  .topbar { display: block; }
  .topbar-actions { margin-top: 18px; }
  .search-box { flex: 1; }
  .search-box input { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 125px; padding: 17px; }
  .metric-card strong { font-size: 31px; }
  .pipeline { grid-template-columns: 1fr 1fr; }
  .section-head { display: block; }
  .section-head select { width: 100%; margin-top: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .topbar-actions { flex-wrap: wrap; }
  .search-box { flex-basis: 100%; }
  .pipeline { grid-template-columns: 1fr; }
  .record-row { grid-template-columns: 1fr auto; }
  .record-row > :nth-child(2) { display: none; }
}

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