:root {
    color-scheme: light;
    --navy-950: #0c1524;
    --navy-900: #101d31;
    --navy-800: #182942;
    --ink: #162033;
    --muted: #6b778c;
    --muted-2: #94a0b2;
    --canvas: #f1f4f8;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --line: #dfe5ec;
    --line-strong: #cbd4df;
    --blue: #2563eb;
    --blue-dark: #194fc4;
    --blue-soft: #eaf1ff;
    --teal: #0b8177;
    --teal-soft: #e6f7f4;
    --amber: #c66a12;
    --amber-soft: #fff3df;
    --red: #c74242;
    --red-soft: #fff0f0;
    --green: #167653;
    --green-soft: #e9f7f0;
    --shadow-sm: 0 1px 2px rgba(12, 21, 36, .05), 0 4px 14px rgba(12, 21, 36, .04);
    --shadow-lg: 0 22px 70px rgba(12, 21, 36, .2);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --sidebar: 244px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 15px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
img, svg { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: .75rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.eyebrow.light { color: #80aaff; }

/* Sign in */
.auth-page { min-height: 100vh; background: var(--navy-950); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.2fr) minmax(430px, .8fr); }
.auth-story { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 52px 7vw; color: #fff; background: radial-gradient(circle at 18% 18%, rgba(45, 105, 235, .3), transparent 32%), linear-gradient(145deg, #101d31 0%, #0b1422 70%); }
.auth-story::after { content: ""; position: absolute; width: 520px; height: 520px; right: -230px; bottom: -250px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); }
.auth-brand, .mobile-auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1rem; }
.auth-brand > span, .mobile-auth-brand > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; background: var(--blue); font-weight: 850; box-shadow: 0 8px 22px rgba(37,99,235,.28); }
.auth-story-copy { position: relative; z-index: 1; max-width: 670px; margin: auto 0; }
.auth-story-copy h1 { margin: 0; max-width: 650px; font-size: clamp(2.6rem, 5vw, 5.2rem); line-height: .98; letter-spacing: -.055em; }
.auth-story-copy > p:last-child { max-width: 600px; margin: 28px 0 0; color: #b8c5d7; font-size: 1.08rem; line-height: 1.7; }
.auth-route { position: relative; z-index: 1; display: flex; align-items: center; max-width: 670px; color: #b9c8da; }
.auth-route span { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: .82rem; font-weight: 700; }
.auth-route i { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #fff; background: rgba(255,255,255,.09); font-size: .65rem; font-style: normal; }
.auth-route b { width: 56px; height: 1px; margin: 0 13px; background: rgba(255,255,255,.18); }
.auth-panel { display: grid; place-items: center; padding: 40px; background: #f6f8fb; }
.auth-card { width: min(100%, 430px); padding: 42px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.auth-card h2 { margin: 0; font-size: 2rem; letter-spacing: -.04em; }
.auth-intro { margin: 9px 0 28px; color: var(--muted); line-height: 1.55; }
.mobile-auth-brand { display: none; margin-bottom: 34px; font-weight: 800; }
.field-label, .form-grid label, .form-section label { display: grid; gap: 7px; color: #344157; font-size: .86rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; color: var(--ink); background: #fff; transition: border-color .18s, box-shadow .18s; }
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #6c95ee; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.auth-card .field-label + .field-label { margin-top: 16px; }
.primary-button, .secondary-button, .ghost-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 15px; border-radius: 9px; font-size: .9rem; font-weight: 750; transition: transform .15s, background .15s, border-color .15s, box-shadow .15s; }
.primary-button { border: 1px solid var(--blue); color: #fff; background: var(--blue); box-shadow: 0 8px 18px rgba(37,99,235,.18); }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--line-strong); color: var(--ink); background: #fff; }
.secondary-button:hover { border-color: #a9b5c4; background: var(--surface-2); }
.ghost-button { border: 1px solid transparent; color: var(--muted); background: transparent; }
.ghost-button:hover { color: var(--ink); background: #eef2f7; }
.danger-button { border: 1px solid #f0caca; color: var(--red); background: #fff; }
.auth-submit { width: 100%; margin-top: 24px; }
.auth-submit span { margin-left: auto; }
.secure-note { margin: 18px 0 0; color: var(--muted-2); font-size: .77rem; text-align: center; }
.form-alert { margin: 0 0 18px; padding: 11px 13px; border: 1px solid #f1c3c3; border-radius: 9px; color: #a22f2f; background: var(--red-soft); font-size: .84rem; }
.hash-page { display: grid; place-items: center; padding: 30px; }
.hash-page .auth-shell { display: block; min-height: auto; width: min(100%, 540px); }
.hash-page .auth-panel { display: block; padding: 0; background: transparent; }
.hash-shell { width: min(100%, 540px); }
.hash-card { width: 100%; }
.hash-card .mobile-auth-brand { display: flex; }
.hash-output { min-height: 98px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all; }
.hash-help { margin: 8px 0 20px; color: var(--muted); font-size: .8rem; line-height: 1.5; }

/* App shell */
.app-loading { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot-mark, .brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; background: var(--blue); font-weight: 850; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar); display: flex; flex-direction: column; padding: 24px 17px 18px; color: #d9e3f0; background: linear-gradient(180deg, var(--navy-900), var(--navy-950)); }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.sidebar-brand strong { display: block; color: #fff; font-size: .94rem; }
.sidebar-brand span:last-child { display: block; margin-top: 2px; color: #8291a8; font-size: .72rem; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid transparent; border-radius: 10px; color: #aab8ca; background: transparent; text-align: left; font-size: .89rem; font-weight: 650; }
.nav-button svg { width: 19px; height: 19px; stroke-width: 1.8; }
.nav-button:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-button.active { border-color: rgba(100,149,255,.2); color: #fff; background: rgba(37,99,235,.2); }
.nav-button.active svg { color: #75a2ff; }
.sidebar-bottom { margin-top: auto; }
.sidebar-summary { margin-bottom: 12px; padding: 13px; border: 1px solid rgba(255,255,255,.08); border-radius: 11px; background: rgba(255,255,255,.04); }
.sidebar-summary span { display: block; color: #8fa0b5; font-size: .72rem; }
.sidebar-summary strong { display: block; margin-top: 5px; color: #fff; font-size: .92rem; }
.logout-button { color: #9eadc0; }
.app-main { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 0 30px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(14px); }
.topbar-left { display: flex; align-items: center; gap: 15px; }
.menu-button { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.page-name { margin: 0; font-size: 1.15rem; letter-spacing: -.02em; }
.today { display: block; margin-top: 3px; color: var(--muted); font-size: .76rem; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fff; }
.icon-button svg, .button-icon { width: 18px; height: 18px; }
.admin-avatar { display: grid; place-items: center; width: 39px; height: 39px; margin-left: 4px; border-radius: 50%; color: #fff; background: var(--navy-800); font-size: .8rem; font-weight: 800; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: 28px 30px 46px; }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.view-header h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.2rem); letter-spacing: -.045em; }
.view-header p { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }
.view-actions { display: flex; gap: 9px; }

/* Dashboard */
.target-grid { display: grid; grid-template-columns: minmax(220px,.72fr) minmax(220px,.72fr) minmax(360px,1.55fr); gap: 14px; }
.target-grid .metric-card { min-height: 178px; }
.metric-card.accent { color: #fff; border-color: transparent; background: linear-gradient(145deg, var(--blue), #172554); }
.metric-card.accent .metric-label, .metric-card.accent .metric-note { color: rgba(255,255,255,.76); }
.metric-card.accent .metric-icon { color: #fff; background: rgba(255,255,255,.15); }
.target-card { min-height: 178px; padding: 21px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.target-card-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.target-card-head span { display: block; color: var(--muted); font-size: .79rem; font-weight: 700; }
.target-card-head strong { display: block; margin-top: 7px; font-size: 1.7rem; letter-spacing: -.045em; }
.target-ring { display: grid; place-items: center; width: 68px; height: 68px; flex: 0 0 auto; border-radius: 50%; background: conic-gradient(var(--blue) var(--progress), #e9edf3 0); }
.target-ring::before { content: ""; grid-area: 1/1; width: 50px; height: 50px; border-radius: 50%; background: #fff; }
.target-ring b { z-index: 1; grid-area: 1/1; font-size: .76rem; }
.progress-track { height: 8px; margin-top: 18px; overflow: hidden; border-radius: 20px; background: #edf1f5; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--blue),#7c9df1); }
.target-foot { display: flex; justify-content: space-between; gap: 16px; margin-top: 11px; color: var(--muted); font-size: .72rem; }
.finance-metrics { margin-top: 14px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { position: relative; overflow: hidden; min-height: 142px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.metric-card::after { content: ""; position: absolute; width: 78px; height: 78px; right: -26px; bottom: -34px; border: 15px solid currentColor; border-radius: 50%; opacity: .045; }
.metric-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .81rem; font-weight: 700; }
.metric-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--blue); background: var(--blue-soft); }
.metric-icon svg { width: 17px; height: 17px; }
.metric-card.teal .metric-icon { color: var(--teal); background: var(--teal-soft); }
.metric-card.amber .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-card.green .metric-icon { color: var(--green); background: var(--green-soft); }
.metric-value { display: block; margin-top: 20px; font-size: 1.55rem; letter-spacing: -.04em; }
.metric-note { display: block; margin-top: 6px; color: var(--muted-2); font-size: .76rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, .65fr); gap: 16px; margin-top: 17px; }
.panel-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 65px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1rem; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: .76rem; }
.text-button { padding: 4px 0; border: 0; color: var(--blue); background: none; font-size: .8rem; font-weight: 750; }
.attention-list { padding: 7px; }
.attention-item { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; align-items: center; gap: 11px; width: 100%; padding: 11px; border: 0; border-radius: 10px; color: inherit; background: transparent; text-align: left; }
.attention-item:hover { background: var(--surface-2); }
.attention-symbol { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--amber); background: var(--amber-soft); font-weight: 850; }
.attention-copy strong, .activity-copy strong { display: block; font-size: .84rem; }
.attention-copy span, .attention-copy small, .activity-copy span { display: block; margin-top: 3px; color: var(--muted); font-size: .74rem; }
.attention-symbol.vendor { color: var(--teal); background: var(--teal-soft); }
.amount { white-space: nowrap; font-size: .84rem; font-weight: 800; }
.money-flow { padding: 18px; }
.flow-row + .flow-row { margin-top: 19px; }
.flow-label { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .78rem; }
.flow-label strong { color: var(--ink); }
.flow-track { height: 8px; margin-top: 8px; overflow: hidden; border-radius: 20px; background: #edf1f5; }
.flow-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #6d91e9); }
.flow-track.teal i { background: linear-gradient(90deg, var(--teal), #4ab6a8); }
.flow-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.mini-stat { padding: 12px; border-radius: 10px; background: var(--surface-2); }
.mini-stat span { display: block; color: var(--muted); font-size: .7rem; }
.mini-stat strong { display: block; margin-top: 5px; font-size: .9rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 25px 0 12px; }
.section-title h2 { margin: 0; font-size: 1rem; }
.section-title span { color: var(--muted); font-size: .75rem; }
.cash-snapshot { display: grid; gap: 1px; padding: 8px; }
.cash-snapshot > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 11px; border-radius: 9px; }
.cash-snapshot > div:hover { background: var(--surface-2); }
.cash-snapshot span { color: var(--muted); font-size: .8rem; }
.cash-snapshot strong { font-size: .88rem; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.kanban-column { min-height: 245px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #edf1f6; transition: border-color .15s, background .15s; }
.kanban-column.drag-over { border-color: var(--blue); background: var(--blue-soft); }
.kanban-head { display: flex; justify-content: space-between; align-items: center; padding: 7px 6px 12px; color: #4d5a6e; font-size: .77rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.count-pill { display: grid; place-items: center; min-width: 23px; height: 23px; border-radius: 20px; color: var(--muted); background: #fff; font-size: .68rem; }
.kanban-stack { display: grid; gap: 8px; }
.order-card { padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 2px 7px rgba(15,28,48,.04); cursor: grab; }
.order-card:active { cursor: grabbing; }
.order-card.dragging { opacity: .45; }
.order-card-top { display: flex; justify-content: space-between; align-items: center; gap: 9px; }
.order-card-ref { color: var(--blue); font-size: .7rem; font-weight: 800; letter-spacing: .03em; }
.order-card-date { color: var(--muted-2); font-size: .67rem; }
.order-card h3 { margin: 11px 0 3px; font-size: .88rem; }
.order-card p { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.45; }
.order-card-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 13px; padding-top: 10px; border-top: 1px solid #edf0f4; }
.order-card-bottom span { color: var(--muted); font-size: .69rem; }
.order-card-bottom strong { font-size: .79rem; }
.empty-column { padding: 30px 10px; color: #9aa5b5; font-size: .75rem; text-align: center; }

/* Tables and lists */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.search-box { position: relative; width: min(370px, 100%); }
.search-box svg { position: absolute; left: 13px; top: 13px; width: 17px; height: 17px; color: var(--muted-2); }
.search-box input { padding-left: 39px; background: #fff; }
.filter-row { display: flex; gap: 8px; }
.filter-chip { min-height: 36px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 30px; color: var(--muted); background: #fff; font-size: .77rem; font-weight: 700; }
.filter-chip.active { border-color: #a9c1f4; color: var(--blue); background: var(--blue-soft); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { padding: 12px 15px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f8fafc; font-size: .7rem; font-weight: 800; letter-spacing: .055em; text-align: left; text-transform: uppercase; }
.data-table td { padding: 14px 15px; border-bottom: 1px solid #edf0f4; font-size: .82rem; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfe; }
.cell-main { display: block; font-weight: 750; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 20px; color: #566278; background: #eef1f5; font-size: .68rem; font-weight: 800; text-transform: capitalize; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #8793a5; }
.status-reserved { color: #9a5b0a; background: var(--amber-soft); }
.status-reserved::before { background: #db8a25; }
.status-dispatched { color: #2457b5; background: var(--blue-soft); }
.status-dispatched::before { background: var(--blue); }
.status-delivered { color: var(--teal); background: var(--teal-soft); }
.status-delivered::before { background: var(--teal); }
.status-settled { color: var(--green); background: var(--green-soft); }
.status-settled::before { background: var(--green); }
.empty-state { padding: 64px 24px; color: var(--muted); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 13px; border-radius: 15px; color: var(--blue); background: var(--blue-soft); }
.empty-icon svg { width: 25px; height: 25px; }
.empty-state h3 { margin: 0; color: var(--ink); font-size: 1rem; }
.empty-state p { max-width: 440px; margin: 7px auto 17px; font-size: .82rem; line-height: 1.55; }
.account-grid, .product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.account-card, .product-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; color: inherit; background: #fff; box-shadow: var(--shadow-sm); text-align: left; }
.account-card { width: 100%; }
.account-card:hover, .product-card:hover { border-color: #bac6d6; transform: translateY(-1px); }
.account-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.account-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: var(--blue); background: var(--blue-soft); font-weight: 850; }
.account-avatar.vendor { color: var(--teal); background: var(--teal-soft); }
.account-card h3, .product-card h3 { margin: 13px 0 4px; font-size: .92rem; }
.account-card p, .product-card p { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.account-balance { margin-top: 16px; padding-top: 13px; border-top: 1px solid #edf0f4; }
.account-balance span { color: var(--muted); font-size: .7rem; }
.account-balance strong { display: block; margin-top: 4px; font-size: 1.05rem; }
.account-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; color: var(--muted); font-size: .68rem; }
.product-top { display: flex; align-items: center; justify-content: space-between; }
.product-package { display: inline-flex; padding: 5px 8px; border-radius: 7px; color: var(--blue); background: var(--blue-soft); font-size: .69rem; font-weight: 800; }
.price-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.price-pair span { padding: 9px; border-radius: 8px; color: var(--muted); background: var(--surface-2); font-size: .68rem; }
.price-pair b { display: block; margin-top: 4px; color: var(--ink); font-size: .75rem; }
.split-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 27px 0 12px; }
.split-heading:first-of-type { margin-top: 0; }
.split-heading h2 { margin: 0; font-size: 1rem; }
.split-heading span { color: var(--muted); font-size: .73rem; }
.segment-control { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.segment-control button { min-height: 34px; padding: 6px 13px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: .78rem; font-weight: 750; }
.segment-control button.active { color: var(--ink); background: #edf1f6; }

/* Reports */
.report-filter { display: flex; align-items: end; gap: 11px; margin-bottom: 15px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.report-filter label { display: grid; gap: 5px; color: var(--muted); font-size: .7rem; font-weight: 750; }
.report-filter input { min-height: 38px; padding: 7px 9px; }
.report-period { margin: 0 0 10px auto; color: var(--muted); font-size: .76rem; }
.report-summary { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.report-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 16px; }
.compact-ledger { padding: 7px; }
.compact-ledger button { display: flex; align-items: center; justify-content: space-between; gap: 15px; width: 100%; padding: 12px; border: 0; border-radius: 9px; color: inherit; background: transparent; text-align: left; }
.compact-ledger button:hover { background: var(--surface-2); }
.compact-ledger span { font-size: .8rem; font-weight: 750; }
.compact-ledger small { display: block; margin-top: 3px; color: var(--muted); font-size: .69rem; font-weight: 500; }
.compact-ledger strong { white-space: nowrap; font-size: .82rem; }
.data-table tfoot th { padding: 13px 15px; border-top: 2px solid var(--line-strong); color: var(--ink); background: #f6f8fb; text-align: left; }
.money-account-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.money-account-card, .add-tile { min-height: 150px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: var(--shadow-sm); }
.money-account-card > span { color: var(--muted); font-size: .67rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.money-account-card h3 { margin: 12px 0 4px; font-size: .9rem; }
.money-account-card p { margin: 0; color: var(--muted); font-size: .7rem; }
.money-account-card strong { display: block; margin-top: 20px; font-size: 1.08rem; }
.add-tile { display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--blue); border-style: dashed; background: rgba(255,255,255,.55); font-size: .75rem; font-weight: 750; }
.add-tile svg { width: 23px; height: 23px; }
.settings-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-card { overflow: hidden; }
.settings-save { grid-column: 1/-1; display: flex; justify-content: flex-end; }
.color-input { padding: 5px; }
.statement-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 17px; }
.statement-summary > div { padding: 14px; border-radius: 10px; background: var(--surface-2); }
.statement-summary span, .statement-summary small { display: block; color: var(--muted); font-size: .69rem; }
.statement-summary strong { display: block; margin: 7px 0 5px; font-size: 1rem; }
.detail-hero { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.detail-hero > div { padding: 12px; border-radius: 9px; background: var(--surface-2); }
.detail-hero span, .detail-hero strong { display: block; }
.detail-hero > div > span:first-child { margin-bottom: 6px; color: var(--muted); font-size: .68rem; }
.detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; color: var(--muted); font-size: .78rem; }
.detail-actions a { text-decoration: none; }

/* Diagnostic error state */
.fatal-error-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 10%, #f8faff 0, var(--canvas) 52%); }
.fatal-error-card { width: min(100%, 620px); padding: 34px; border: 1px solid var(--line); border-radius: 20px; background: #fff; box-shadow: var(--shadow-lg); }
.fatal-error-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 22px; border-radius: 14px; color: #fff; background: var(--red); font-size: 1.25rem; font-weight: 900; box-shadow: 0 10px 25px rgba(199,66,66,.2); }
.fatal-error-card h1 { margin: 0; font-size: clamp(1.65rem,4vw,2.25rem); letter-spacing: -.04em; }
.fatal-error-message { margin: 10px 0 22px; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.fatal-error-help { padding: 17px 18px; border: 1px solid #f0d4d4; border-radius: 12px; background: #fff7f7; }
.fatal-error-help > strong { font-size: .9rem; }
.fatal-error-help ol { margin: 11px 0 0; padding-left: 20px; color: #5f6878; line-height: 1.6; }
.fatal-error-help li + li { margin-top: 7px; }
.diagnostic-code { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 15px; padding: 11px 13px; border-radius: 9px; background: var(--surface-2); }
.diagnostic-code span { color: var(--muted); font-size: .75rem; font-weight: 700; }
.diagnostic-code code { overflow-wrap: anywhere; color: #374151; font-family: ui-monospace,SFMono-Regular,Menlo,monospace; font-size: .76rem; font-weight: 750; }
.fatal-error-actions { display: flex; gap: 9px; margin-top: 20px; }
.fatal-error-actions a { text-decoration: none; }
.fatal-error-safe { margin: 18px 0 0; color: var(--muted-2); font-size: .72rem; line-height: 1.5; }
.report-grid { display: grid; grid-template-columns: minmax(0,1.1fr) minmax(300px,.9fr); gap: 16px; }
.profit-card { min-height: 310px; padding: 22px; color: #fff; background: linear-gradient(145deg, #162943, #0f1b2d); }
.profit-card .eyebrow { color: #81a9ff; }
.profit-number { display: block; margin-top: 22px; font-size: clamp(2.3rem, 6vw, 4.2rem); letter-spacing: -.06em; }
.profit-caption { color: #9eb0c6; font-size: .85rem; }
.profit-bars { display: grid; align-items: end; grid-template-columns: repeat(12,1fr); gap: 7px; height: 100px; margin-top: 32px; }
.profit-bars i { min-height: 8px; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #5b8df7, #285fcf); opacity: .95; }
.report-list { padding: 8px; }
.report-line { display: flex; justify-content: space-between; gap: 14px; padding: 14px 10px; border-bottom: 1px solid #edf0f4; }
.report-line:last-child { border: 0; }
.report-line span { color: var(--muted); font-size: .8rem; }
.report-line strong { font-size: .82rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; background: rgba(6,14,25,.62); backdrop-filter: blur(4px); }
.modal-card { width: min(100%, 570px); max-height: min(90vh, 880px); overflow: auto; border: 1px solid rgba(255,255,255,.35); border-radius: 18px; background: #fff; box-shadow: var(--shadow-lg); }
.modal-card.wide { width: min(100%, 900px); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 21px 22px 17px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.modal-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.03em; }
.modal-head p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.modal-body { padding: 21px 22px; }
.modal-actions { position: sticky; bottom: 0; z-index: 2; display: flex; justify-content: flex-end; gap: 9px; padding: 15px 22px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
.close-button { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #fff; font-size: 1.15rem; }
.form-section + .form-section { margin-top: 22px; padding-top: 21px; border-top: 1px solid var(--line); }
.form-section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.form-section-title i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-size: .72rem; font-style: normal; font-weight: 850; }
.form-section-title strong { font-size: .84rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-help { margin: 7px 0 0; color: var(--muted); font-size: .72rem; font-weight: 500; line-height: 1.45; }
.calculation-strip { display: grid; grid-template-columns: repeat(5,1fr); gap: 1px; margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--line); }
.calc-item { min-height: 74px; padding: 12px; background: #f8fafc; }
.calc-item span { display: block; color: var(--muted); font-size: .67rem; }
.calc-item strong { display: block; margin-top: 8px; font-size: .83rem; }
.calc-item.profit { background: var(--green-soft); }
.calc-item.profit strong { color: var(--green); }

/* Notifications */
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 9px; width: min(370px, calc(100vw - 40px)); }
.toast { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 16px 48px rgba(12,21,36,.18); animation: toast-in .25s ease-out; }
.toast-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: var(--green); background: var(--green-soft); font-weight: 900; }
.toast.error .toast-icon { color: var(--red); background: var(--red-soft); }
.toast strong { display: block; font-size: .82rem; }
.toast span { display: block; margin-top: 3px; color: var(--muted); font-size: .73rem; line-height: 1.4; }
.busy-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(13,22,38,.38); backdrop-filter: blur(2px); }
.busy-card { display: flex; align-items: center; gap: 13px; padding: 15px 18px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-lg); font-size: .85rem; font-weight: 750; }
.spinner { width: 20px; height: 20px; border: 2px solid #cfdaea; border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; }
.mobile-overlay { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(2,1fr); }
    .dashboard-grid, .report-grid, .target-grid { grid-template-columns: 1fr 1fr; }
    .target-card { grid-column: span 2; }
    .report-summary, .money-account-grid { grid-template-columns: repeat(2,1fr); }
    .account-grid, .product-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 820px) {
    :root { --sidebar: 270px; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-story { display: none; }
    .auth-panel { min-height: 100vh; padding: 24px; }
    .mobile-auth-brand { display: flex; }
    .app-shell { display: block; }
    .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: 15px 0 50px rgba(0,0,0,.25); }
    .app-shell.menu-open .sidebar { transform: translateX(0); }
    .mobile-overlay { position: fixed; inset: 0; z-index: 25; display: none; background: rgba(5,12,22,.5); }
    .app-shell.menu-open .mobile-overlay { display: block; }
    .app-main { grid-column: auto; }
    .menu-button { display: grid; place-items: center; }
    .topbar { height: 68px; padding: 0 17px; }
    .today { display: none; }
    .topbar-actions .secondary-button { display: none; }
    .content { padding: 22px 17px 40px; }
    .view-header { align-items: flex-start; }
    .view-header p { max-width: 440px; }
    .form-grid.three { grid-template-columns: repeat(2,1fr); }
    .span-3 { grid-column: span 2; }
    .calculation-strip { grid-template-columns: repeat(2,1fr); }
    .calc-item:last-child { grid-column: span 2; }
    .report-columns, .settings-layout { grid-template-columns: 1fr; }
    .detail-hero, .statement-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 580px) {
    .auth-panel, .hash-page { padding: 15px; }
    .auth-card { padding: 28px 22px; }
    .metric-grid, .account-grid, .product-grid, .target-grid, .report-summary, .money-account-grid { grid-template-columns: 1fr; }
    .target-card { grid-column: auto; }
    .metric-card { min-height: 125px; }
    .view-header { display: block; }
    .view-actions { margin-top: 14px; }
    .view-actions .primary-button, .view-actions .secondary-button { flex: 1; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .search-box { width: 100%; }
    .filter-row { overflow-x: auto; padding-bottom: 3px; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: auto; }
    .modal-backdrop { align-items: end; padding: 0; }
    .modal-card, .modal-card.wide { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
    .modal-body, .modal-head { padding-left: 17px; padding-right: 17px; }
    .modal-actions { padding: 13px 17px calc(13px + env(safe-area-inset-bottom)); }
    .modal-actions button { flex: 1; }
    .calculation-strip { grid-template-columns: 1fr 1fr; }
    .calc-item:last-child { grid-column: span 2; }
    .topbar .primary-button .button-label { display: none; }
    .report-filter { align-items: stretch; flex-direction: column; }
    .report-period { margin: 0; }
    .detail-hero, .statement-summary { grid-template-columns: 1fr; }
    .detail-actions, .split-heading { align-items: flex-start; flex-direction: column; }
    .fatal-error-page { padding: 14px; }
    .fatal-error-card { padding: 25px 20px; border-radius: 16px; }
    .diagnostic-code { align-items: flex-start; flex-direction: column; }
    .fatal-error-actions { flex-direction: column; }
}

.order-lines, .journal-lines { display: grid; gap: 10px; margin-bottom: 12px; }
.order-line { display: grid; grid-template-columns: 1.5fr 1.3fr .8fr auto; gap: 9px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); }
.order-line select, .order-line input { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-dark); border-radius: 8px; background: #fff; font: inherit; }
.journal-edit-row { display: grid; grid-template-columns: 1.25fr 1.6fr .65fr .65fr; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--soft); }
.journal-edit-row label { display: grid; gap: 6px; }
.journal-edit-row label span { color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.journal-edit-row input, .journal-edit-row select { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line-dark); border-radius: 8px; background: #fff; }
.data-table tr[data-action] { cursor: pointer; }
.data-table tr[data-action]:hover { background: var(--soft); }
.diagnostic-card { width: min(900px,100%); }
.diagnostic-table { display: grid; margin: 22px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #f8fafc; }
.diagnostic-table div { display: grid; grid-template-columns: 170px minmax(0,1fr); border-bottom: 1px solid var(--line); }
.diagnostic-table div:last-child { border-bottom: 0; }
.diagnostic-table span { padding: 11px 13px; color: var(--muted); background: #f1f5f9; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.diagnostic-table code { padding: 11px 13px; overflow-wrap: anywhere; color: #7f1d1d; background: transparent; white-space: pre-wrap; }
@media (max-width: 760px) { .order-line, .journal-edit-row { grid-template-columns: 1fr; } }
@media (max-width: 580px) { .diagnostic-table div { grid-template-columns: 1fr; } }

@media print {
    body { background: #fff; font-size: 11px; }
    .sidebar, .topbar, .view-header .view-actions, .report-filter, .toast-region, .modal-backdrop { display: none !important; }
    .app-shell { display: block; }
    .app-main { display: block; }
    .content { width: 100%; padding: 0; }
    .view-header { margin-bottom: 16px; }
    .view-header h1 { font-size: 22px; }
    .panel-card, .metric-card, .table-wrap { box-shadow: none; break-inside: avoid; }
    .report-summary { grid-template-columns: repeat(4,1fr); }
    .report-columns { grid-template-columns: 1fr 1fr; }
    .data-table th, .data-table td { padding: 7px 8px; }
    .report-table { overflow: visible; }
}
