:root {
  color-scheme: light;
  --navy: #0f172a;
  --blue: #1e3a8a;
  --blue-soft: #edf2ff;
  --gold: #a16207;
  --gold-soft: #fff7e6;
  --background: #f8fafc;
  --surface: #ffffff;
  --ink: #020617;
  --muted: #475569;
  --line: #e2e8f0;
  --green: #176b4d;
  --green-soft: #e9f7f0;
  --red: #b42318;
  --red-soft: #fff0ee;
  --radius: 14px;
  font-family: "IBM Plex Sans", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  background: var(--background);
  color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--background); line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: #102c70; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 3px solid #b47b16; outline-offset: 3px; }

.app-shell { width: min(1180px, 100%); margin: 0 auto; padding: 0 26px 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 76px; border-bottom: 1px solid var(--line); gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); font-size: 18px; font-weight: 700; text-decoration: none; letter-spacing: -.02em; }
.brand-mark { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: var(--navy); color: #fff; }
.brand-mark svg { width: 21px; height: 21px; }
.top-actions { display: flex; align-items: center; gap: 20px; }
.nav-link, .nav-button { color: var(--muted); font-size: 14px; font-weight: 600; text-decoration: none; }
.nav-link:hover, .nav-button:hover { color: var(--navy); }
.nav-button { min-height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.inline-form { display: inline; }
.main-content { min-height: calc(100vh - 150px); padding-top: 32px; }
.footer { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; color: var(--muted); font-size: 12px; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; color: var(--navy); font-size: clamp(30px, 4vw, 42px); line-height: 1.12; letter-spacing: -.04em; }
h2 { margin-bottom: 7px; color: var(--navy); font-size: 21px; line-height: 1.25; letter-spacing: -.025em; }
h3 { margin-bottom: 7px; color: var(--navy); font-size: 17px; }
.eyebrow { margin-bottom: 8px; color: var(--blue); font-size: 12px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.lead { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.muted { color: var(--muted); }
.small { margin: 18px 0 0; font-size: 13px; }

.hero { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin: 0 0 24px; }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; padding: 10px 17px; border: 1px solid transparent; border-radius: 9px; font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .6; cursor: wait; transform: none; }
.button-primary { background: var(--navy); color: #fff; }
.button-primary:hover { background: #1b2b4d; color: #fff; }
.button-secondary { border-color: #cbd5e1; background: #fff; color: var(--navy); }
.button-secondary:hover { border-color: var(--blue); background: #f8faff; color: var(--blue); }
.button-quiet { border-color: transparent; background: transparent; color: var(--blue); }
.button-quiet:hover { background: var(--blue-soft); color: var(--blue); }
.button-wide { width: 100%; }

.panel { margin-bottom: 20px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 10px rgb(15 23 42 / 3%); }
.notice { margin: 16px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.notice p { margin: 4px 0 0; }
.notice-info { border-color: #c7d2fe; background: #f5f7ff; }
.notice-warning { border-color: #f4d99a; background: var(--gold-soft); }
.notice strong { color: var(--navy); }
.flash { margin: 18px 0 0; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.flash-success { border-color: #b5dfc9; background: var(--green-soft); color: #14543e; }
.flash-error { border-color: #f1c4bf; background: var(--red-soft); color: #8d1c14; }
.flash-info { border-color: #c7d2fe; background: var(--blue-soft); color: var(--blue); }
.inline-error { padding: 12px 14px; border: 1px solid #f1c4bf; border-radius: 9px; background: var(--red-soft); color: #8d1c14; }

.page-heading { margin: 2px 0 24px; }
.auth-layout { display: grid; min-height: 68vh; place-items: center; }
.auth-card { width: min(440px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 12px 40px rgb(15 23 42 / 6%); }
.auth-card-wide { width: min(500px, 100%); }
.stack-form { display: grid; gap: 11px; margin-top: 23px; }
.stack-form label, .field label { color: var(--navy); font-size: 13px; font-weight: 700; }
.stack-form input, .field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); }
.field textarea { min-height: 70px; resize: vertical; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.stack-form input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.field-hint { margin: -5px 0 0; color: var(--muted); font-size: 12px; }

.settings-form { padding: 0; overflow: hidden; }
.form-section { padding: 24px; border-bottom: 1px solid var(--line); }
.form-section h2 { margin-bottom: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field-span { grid-column: 1 / -1; }
.check-field { display: flex; min-height: 46px; align-items: center; gap: 10px; }
.check-field input { width: 18px; min-height: 18px; accent-color: var(--navy); }
.check-field label { font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 24px; }
input[readonly] { background: #f1f5f9; color: #475569; }

.setup-card { display: grid; grid-template-columns: 40px 1fr; align-items: start; gap: 16px; }
.empty-setup { display: flex; align-items: flex-start; gap: 16px; }
.step-number { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.setup-copy > p { margin-bottom: 15px; }
.status-panel { padding: 21px 24px; }
.status-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.status-head h2 { margin-bottom: 0; }
.status-pill { display: inline-flex; min-height: 30px; align-items: center; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.status-waiting { background: var(--gold-soft); color: #7c4a03; }
.status-good { background: var(--green-soft); color: var(--green); }
.status-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.order-details { margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); font-size: 13px; }
.order-details summary, .nested-details summary { cursor: pointer; color: var(--blue); font-weight: 700; }
.order-details ul, .nested-details ul { display: grid; gap: 7px; padding-left: 20px; }
.order-details li { display: flex; justify-content: space-between; gap: 12px; }
.order-details code { color: var(--navy); }

.sync-banner { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.sync-banner strong { color: var(--navy); font-size: 14px; }
.sync-banner p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.sync-dot { width: 10px; height: 10px; flex: 0 0 auto; margin-top: 6px; border-radius: 50%; background: #94a3b8; }
.sync-running { border-color: #c7d2fe; background: #f8faff; }
.sync-running .sync-dot { background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
.sync-success { border-color: #b5dfc9; background: var(--green-soft); }
.sync-success .sync-dot { background: var(--green); }
.sync-error { border-color: #f1c4bf; background: var(--red-soft); }
.sync-error .sync-dot { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.78); } }

.transactions-panel { padding: 22px 0 0; overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 0 24px 14px; }
.panel-head h2 { margin-bottom: 4px; }
.panel-head p { margin-bottom: 0; font-size: 13px; }
.filter-bar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding: 0 24px 18px; }
.filter-bar .field { width: 150px; }
.filter-bar .search-field { width: min(360px, 100%); flex: 1 1 250px; }
.filter-bar .field input { min-height: 43px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 13px 16px; border-bottom: 1px solid #edf0f4; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f8fafc; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:hover { background: #fafcff; }
td strong { display: block; color: var(--navy); font-weight: 650; }
.date-cell { min-width: 118px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-cell span, .table-subtext { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; white-space: normal; }
.table-subtext { max-width: 520px; overflow-wrap: anywhere; }
.reference-cell { max-width: 200px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount-cell { min-width: 140px; font-weight: 750; }
.amount-cell small { color: var(--muted); font-weight: 600; }
.amount-in { color: var(--green); }
.amount-out { color: var(--red); }
.nested-details { margin-top: 7px; font-size: 12px; }
.nested-details ul { padding-left: 17px; }
.nested-details li { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.empty-state { padding: 48px 20px 54px; text-align: center; }
.empty-icon { display: grid; width: 42px; height: 42px; margin: 0 auto 14px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 21px; }
.empty-state p { margin-bottom: 0; }

@media (max-width: 820px) {
  .app-shell { padding: 0 18px 24px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; }
  .form-grid-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar .search-field { flex-basis: 100%; }
}
@media (max-width: 560px) {
  .app-shell { padding: 0 13px 20px; }
  .topbar { min-height: 66px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 33px; height: 33px; }
  .top-actions { gap: 10px; }
  .nav-link, .nav-button { font-size: 12px; }
  .main-content { padding-top: 23px; }
  .footer { flex-direction: column; gap: 2px; }
  .panel { padding: 18px; }
  .settings-form { padding: 0; }
  .form-section { padding: 19px 17px; }
  .form-grid, .form-grid-four { grid-template-columns: 1fr; }
  .field-span { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; padding: 17px; }
  .form-actions .button { width: 100%; }
  .setup-card { grid-template-columns: 32px 1fr; gap: 10px; padding: 17px; }
  .empty-setup { padding: 17px; }
  .step-number { width: 30px; height: 30px; }
  .status-head { flex-direction: column; }
  .status-actions { align-items: stretch; flex-direction: column; }
  .status-actions .button, .status-actions form, .status-actions form button { width: 100%; }
  .transactions-panel { padding: 18px 0 0; }
  .panel-head { flex-direction: column; padding: 0 17px 13px; }
  .filter-bar { align-items: stretch; flex-direction: column; padding: 0 17px 16px; }
  .filter-bar .field, .filter-bar .search-field { width: 100%; }
  .filter-bar .button { width: 100%; }
  th, td { padding: 11px 12px; }
  .table-wrap table { min-width: 660px; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
