:root {
    --green: #123c2b;
    --green-2: #1f6b4a;
    --blue: #17324d;
    --gold: #c9921f;
    --amber: #f4c95d;
    --bg: #f4f7f5;
    --surface: #ffffff;
    --text: #15221c;
    --muted: #68746e;
    --line: #dce4df;
    --danger: #b93d32;
    --shadow: 0 20px 50px rgba(18, 60, 43, .13);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button, .button-link {
    border: 0;
    background: var(--green);
    color: #fff;
    border-radius: 8px;
    padding: .85rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
}

button:hover, .button-link:hover { background: var(--green-2); }
.ghost-form-button {
    background: #f7faf8;
    color: var(--green);
    border: 1px solid var(--line);
}
.ghost-form-button:hover { background: #eef3f0; }

.hidden { display: none !important; }
.eyebrow, .panel-kicker { color: var(--gold); font-weight: 700; margin: 0 0 .5rem; }

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
}

.login-visual {
    padding: 8vw;
    color: #fff;
    background:
        linear-gradient(rgba(18, 60, 43, .90), rgba(23, 50, 77, .88)),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%23123c2b'/%3E%3Cg fill='none' stroke='%23f4c95d' stroke-opacity='.32' stroke-width='3'%3E%3Cpath d='M40 620h1120M80 560h1040M120 500h960M210 210h780v370H210zM260 260h680v260H260z'/%3E%3Cpath d='M260 330h680M260 400h680M360 260v260M500 260v260M640 260v260M780 260v260'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.18'%3E%3Ccircle cx='930' cy='190' r='34'/%3E%3Ccircle cx='1010' cy='220' r='22'/%3E%3Ccircle cx='860' cy='225' r='18'/%3E%3C/g%3E%3C/svg%3E");
    background-size: cover;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-mark, .side-brand span {
    width: 58px;
    height: 58px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--amber);
    color: var(--green);
    font-weight: 900;
}

.login-visual h1 {
    font-size: clamp(2.1rem, 6vw, 4.8rem);
    line-height: 1.15;
    margin: 1rem 0;
    max-width: 900px;
}

.lead { font-size: 1.25rem; line-height: 1.9; max-width: 720px; color: rgba(255,255,255,.86); }
.visual-grid { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: .75rem; max-width: 620px; margin-top: 2rem; }
.visual-grid span { border: 1px solid rgba(255,255,255,.25); padding: 1rem; border-radius: 8px; background: rgba(255,255,255,.08); }

.login-panel {
    background: var(--surface);
    padding: clamp(2rem, 5vw, 4rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
}

.login-panel h2 { font-size: 2rem; margin: 0 0 1rem; line-height: 1.35; }
label { display: grid; gap: .45rem; color: var(--muted); font-weight: 700; }
input, select, textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: .75rem .9rem;
    color: var(--text);
}

textarea { min-height: 96px; resize: vertical; }
select[multiple] { min-height: 132px; }
.form-message { min-height: 24px; color: var(--danger); font-weight: 700; }
.license-box {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f7faf8;
    padding: 1rem;
    display: grid;
    gap: .85rem;
}
.license-box h3 { margin: 0; color: var(--green); }
.license-box p { margin: 0; color: var(--muted); line-height: 1.7; }
.license-box input[readonly] { background: #eef3f0; font-weight: 800; letter-spacing: .05em; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
    background: var(--green);
    color: #fff;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side-brand { display: flex; align-items: center; gap: .8rem; }
.side-nav { display: grid; gap: .45rem; overflow-y: auto; padding-left: .15rem; }
.nav-group { display: grid; gap: .35rem; }
.nav-group-toggle {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .65rem .75rem;
    color: #fff;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 7px;
    font-weight: 800;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.13); }
.nav-chevron {
    width: 8px;
    height: 8px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform .18s ease;
    margin-left: .25rem;
}
.nav-group.is-open .nav-chevron { transform: rotate(135deg); margin-top: .35rem; }
.nav-group-items { display: none; gap: .3rem; padding-right: .45rem; }
.nav-group-items[hidden] { display: none !important; }
.nav-group.is-open .nav-group-items { display: grid; }
.nav-item, .ghost-button {
    width: 100%;
    justify-content: flex-start;
    background: transparent;
    border: 1px solid rgba(255,255,255,.16);
}
.nav-group-items .nav-item { min-height: 39px; padding-right: 1rem; font-size: .92rem; }
.nav-item.active { background: var(--amber); color: var(--green); }
.ghost-button { margin-top: auto; }

.workspace { padding: 1.5rem; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.4rem;
}
.topbar h2 { margin: 0; font-size: clamp(1.3rem, 3vw, 2.15rem); }
.user-chip { border: 1px solid var(--line); border-radius: 8px; padding: .75rem 1rem; background: #fff; display: grid; min-width: 180px; }
.user-chip small { color: var(--muted); }

.view { display: none; }
.view.active { display: grid; gap: 1.2rem; }
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.2rem;
    min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h3, .panel h3 { margin: 0; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; }
.muted-text { color: var(--muted); font-weight: 700; }
.compact-metrics { grid-template-columns: repeat(6, minmax(120px, 1fr)); margin: .8rem 0 1rem; }
.compact-metrics .metric { padding: .8rem; }
.compact-metrics .metric strong { font-size: 1.15rem; }
.panel-lite {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8faf9;
    padding: 1rem;
    min-width: 0;
}
.panel-lite h3 { margin: 0 0 .8rem; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .9rem; }
.metric {
    background: #fff;
    border: 1px solid var(--line);
    border-right: 5px solid var(--green);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(18,60,43,.08);
}
.metric.blue { border-right-color: var(--blue); }
.metric.success, .metric.green { border-right-color: var(--green-2); }
.metric.gold { border-right-color: var(--gold); }
.metric.danger { border-right-color: var(--danger); }
.metric.gray { border-right-color: #87938d; }
.metric strong { display: block; font-size: 1.55rem; margin-top: .4rem; }
.insight-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; margin: 1rem 0; }
.insight-card {
    border: 1px solid var(--line);
    border-right: 5px solid var(--blue);
    border-radius: 8px;
    background: #fff;
    padding: 1rem;
    display: grid;
    gap: .65rem;
}
.insight-card.ok { border-right-color: var(--green); }
.insight-card.warn { border-right-color: var(--gold); }
.insight-card.danger { border-right-color: var(--danger); }
.insight-card div { display: flex; justify-content: space-between; gap: .75rem; align-items: start; }
.insight-card h4 { margin: 0; color: var(--blue); }
.insight-card span { color: var(--muted); font-weight: 800; }
.insight-card strong { font-size: 1.25rem; color: var(--green); }
.insight-card p { margin: 0; }
.insight-card small { color: var(--muted); line-height: 1.7; }
.my-halls-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.my-hall-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 1rem;
    display: grid;
    gap: .9rem;
}
.my-hall-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.my-hall-head strong { display: block; font-size: 1.2rem; color: var(--green); }
.my-hall-head span { color: var(--muted); }
.my-hall-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.my-hall-metrics span { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; color: var(--muted); }
.my-hall-metrics b { display: block; color: var(--blue); font-size: 1.15rem; }
.my-hall-meta { display: grid; gap: .35rem; color: var(--muted); }
.status-pill.ok { border-color: #cfe8d9; background: #eef8f1; color: var(--green); }
.status-pill.warn { border-color: #f2d38b; background: #fff7df; color: #7b5510; }
.danger-text { color: var(--danger) !important; font-weight: 800; }

.alerts { display: grid; gap: .6rem; }
.alert { border: 1px solid #f2d38b; background: #fff7df; color: #7b5510; padding: .8rem 1rem; border-radius: 8px; font-weight: 700; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.wide-form { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.full { grid-column: 1 / -1; }
.ledger-entry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.ledger-entry-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    background: #fbfdfc;
    box-shadow: none;
}
.ledger-entry-card h3 { color: var(--green); }
.ledger-entry-card.income-card { border-right: 5px solid var(--green-2); }
.ledger-entry-card.expense-card { border-right: 5px solid var(--danger); }
.accounting-report-panel { border-top: 4px solid var(--blue); }
.ledger-report-filter {
    background: #f8faf9;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.ledger-report-list { display: grid; gap: .85rem; margin: 1rem 0; }
.ledger-account-group {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.ledger-group-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: .9rem 1rem;
    background: #eef5f1;
    cursor: pointer;
}
.ledger-group-head strong { display: block; color: var(--green); font-size: 1.05rem; }
.ledger-group-head span { color: var(--muted); font-weight: 800; }
.ledger-group-balances { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; }
.ledger-group-balances b {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .45rem .7rem;
}
.ledger-list-head, .ledger-list-row {
    display: grid;
    grid-template-columns: .8fr 2fr 1.25fr 1.25fr 1fr;
    gap: .75rem;
    align-items: center;
    padding: .75rem 1rem;
    border-top: 1px solid var(--line);
}
.ledger-list-head { color: var(--muted); font-weight: 900; background: #fbfdfc; }
.ledger-list-row strong { color: var(--blue); }
.ledger-list-row button { min-height: 34px; padding: .45rem .7rem; }
.muted-row { color: var(--muted); }
.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 1rem;
    color: var(--muted);
    font-weight: 800;
    background: #fbfdfc;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(18, 34, 28, .52);
}
.modal-card {
    width: min(760px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.2rem;
    box-shadow: 0 30px 80px rgba(18, 60, 43, .28);
}
.customer-modal-card { width: min(980px, 100%); }
.ledger-account-modal {
    width: min(1180px, calc(100vw - 32px));
    height: min(880px, calc(100dvh - 32px));
    max-height: calc(100dvh - 32px);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: .9rem;
}
.ledger-account-modal-head {
    flex: 0 0 auto;
    margin: 0;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #f8fbf9;
}
.ledger-account-modal-head h3 { font-size: 1.2rem; line-height: 1.35; color: var(--blue); }
.ledger-account-modal-head .panel-kicker { margin-bottom: 2px; font-size: .78rem; }
.ledger-account-modal-head button { min-height: 36px; padding: .45rem .8rem; font-size: .84rem; }
.ledger-account-editor {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    align-items: end;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: #fff;
}
.ledger-account-editor-title { align-self: center; display: grid; gap: 4px; }
.ledger-account-editor-title strong { color: var(--green); font-size: .96rem; }
.ledger-account-editor-title span { color: var(--muted); font-size: .76rem; line-height: 1.6; }
.ledger-account-fields {
    display: grid;
    grid-template-columns: minmax(170px, 1.2fr) minmax(120px, .7fr) minmax(190px, 1.3fr) auto auto;
    gap: 10px;
    align-items: end;
}
.ledger-account-fields label { gap: 5px; font-size: .8rem; }
.ledger-account-fields input,
.ledger-account-fields select { min-height: 38px; padding: .5rem .7rem; font-size: .88rem; }
.ledger-account-active { align-self: end; min-height: 38px; padding: 0 8px; white-space: nowrap; }
.ledger-account-form-actions { display: flex; align-items: end; gap: 7px; }
.ledger-account-form-actions button { min-height: 38px; padding: .5rem .75rem; white-space: nowrap; font-size: .82rem; }
.ledger-transactions-modal {
    width: min(1380px, 100%);
    max-height: 94vh;
}
.sales-management-modal {
    width: min(1420px, 100%);
    max-height: 94vh;
}
.sale-management-editor {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-right: 5px solid var(--gold);
    border-radius: 8px;
    background: #fffaf0;
}
.sales-management-table { max-height: 54vh; overflow: auto; }
.sales-management-table table { min-width: 1280px; }
.sales-management-table thead { position: sticky; top: 0; z-index: 2; }
.sales-management-table th { background: #f4f7f5; }
.ledger-transaction-editor {
    margin: 1rem 0;
    padding: 1rem;
    border: 1px solid var(--line);
    border-right: 5px solid var(--gold);
    border-radius: 8px;
    background: #fffaf0;
}
.ledger-modal-table { max-height: 52vh; overflow: auto; }
.ledger-modal-table table { min-width: 1050px; }
.ledger-modal-table thead { position: sticky; top: 0; z-index: 2; }
.ledger-modal-table th { background: #f4f7f5; }
.customer-list-view { margin-top: 1rem; }
.customer-list-view h3 { margin: 0 0 .8rem; color: var(--green); }
.checklist { border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; padding: 1rem; }
.checklist legend { padding: 0 .5rem; font-weight: 800; }
.checklist label { display: flex; align-items: center; gap: .5rem; color: var(--text); }
.checklist input { width: auto; min-height: auto; }
.check-line {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
}
.check-line input { width: auto; min-height: auto; }
.status-pill { border-radius: 999px; border: 1px solid var(--line); padding: .3rem .75rem; color: var(--green); background: #eef8f1; font-weight: 700; }
.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.report-launch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .75rem;
    margin: 1rem 0;
}

.report-launcher {
    min-height: 52px;
    text-align: right;
    background: #fff;
    color: var(--blue);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 700;
}

.report-launcher.active,
.report-launcher:hover {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.report-panel[hidden] { display: none !important; }

.inventory-command-center {
    padding: 1.25rem;
    background: #f5f8f6;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.inventory-command-center h3 { margin: .2rem 0 1rem; }
.inventory-command-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.inventory-command { min-height: 74px; text-align: right; background: #fff; color: var(--blue); border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }
.inventory-command:hover { color: #fff; background: var(--green); border-color: var(--green); }
.accounting-command-center { padding: 1.25rem; background: #f5f8f6; }
.accounting-command-center h3 { margin: .2rem 0 1rem; }
.accounting-command-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.accounting-command-group { padding: 1rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.accounting-command-group h4 { margin: 0 0 .8rem; color: var(--green); font-size: 1rem; }
.accounting-command-group.expense-group h4 { color: var(--danger); }
.accounting-command-group.reports-group h4 { color: var(--blue); }
.accounting-command-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.accounting-command { min-height: 74px; text-align: right; background: #fff; color: var(--blue); border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }
.accounting-command:hover { color: #fff; background: var(--green); border-color: var(--green); }
.inventory-managed { display: none !important; }
.inventory-workspace-modal { width: min(1120px, 96vw); max-height: 92vh; overflow: auto; }
.inventory-workspace-modal [data-inventory-workspace-content] { display: grid; gap: 1rem; }
.expense-category-group { margin: 1rem 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.expense-category-group h4 { margin: 0; padding: .7rem 1rem; background: #f2f6f3; color: var(--green); }
.pack-preview {
    border: 1px solid #f2d38b;
    background: #fff8e7;
    color: #714f12;
    border-radius: 8px;
    padding: .8rem 1rem;
    font-weight: 800;
}
.formula-lines, .formula-entry {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: .8rem;
    align-items: end;
}

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { border-bottom: 1px solid var(--line); padding: .85rem; text-align: right; white-space: nowrap; }
th { color: var(--blue); background: #f8faf9; }
.monthly-legend { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0; }
.month-state { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .7rem; font-weight: 700; }
.month-state.registered, .month-cell.registered { background: #e9f6ee; color: var(--green); border-color: #bcdcc9; }
.month-state.missing, .month-cell.missing { background: #fff0ee; color: var(--danger); border-color: #efc2bd; }
.month-state.future, .month-cell.future { background: #f1f3f2; color: #87938d; border-color: #dce2df; }
.monthly-grid table { min-width: 1500px; }
.monthly-grid th, .monthly-grid td { padding: .45rem; text-align: center; }
.monthly-grid th:first-child, .monthly-grid th:nth-child(2), .monthly-grid td:first-child, .monthly-grid td:nth-child(2) { text-align: right; position: sticky; background: #fff; z-index: 1; }
.monthly-grid th:first-child, .monthly-grid td:first-child { right: 0; min-width: 170px; }
.monthly-grid th:nth-child(2), .monthly-grid td:nth-child(2) { right: 170px; min-width: 130px; }
.month-cell { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid; border-radius: 6px; font-weight: 900; }
button.month-cell { cursor: pointer; }
.report-detail-notes { margin-top: 1rem; display: grid; gap: .4rem; }
.report-detail-notes p { margin: 0; padding: .65rem .8rem; background: #f8faf9; border-right: 3px solid var(--green); }

.bars { display: grid; gap: .7rem; }
.bar-row { display: grid; grid-template-columns: 105px 1fr 82px; gap: .6rem; align-items: center; }
.bar-track { background: #eef3f0; border-radius: 999px; overflow: hidden; height: 13px; }
.bar-fill { height: 100%; background: var(--green-2); border-radius: inherit; min-width: 2px; }
.danger-bars .bar-fill { background: var(--danger); }
.compact { margin-top: .6rem; }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .my-halls-grid { grid-template-columns: 1fr; }
    .my-hall-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wide-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ledger-entry-grid { grid-template-columns: 1fr; }
    .accounting-command-groups { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
    .login-shell, .app-shell, .grid-two { grid-template-columns: 1fr; }
    .login-visual { min-height: 42vh; padding: 2rem; }
    .sidebar { position: static; height: auto; }
    .side-nav { grid-template-columns: 1fr; overflow: visible; }
    .topbar { align-items: stretch; flex-direction: column; }
    .metric-grid, .form-grid, .wide-form, .checklist { grid-template-columns: 1fr; }
    .insight-grid { grid-template-columns: 1fr; }
    .my-hall-head { display: grid; }
    .my-hall-metrics { grid-template-columns: 1fr; }
    .formula-lines, .formula-entry { grid-template-columns: 1fr; }
    .ledger-list-head { display: none; }
    .ledger-list-row { grid-template-columns: 1fr; }
    .ledger-group-head { align-items: stretch; flex-direction: column; }
    .ledger-group-balances { justify-content: flex-start; }
    .workspace { padding: 1rem; }
}

@media print {
    .sidebar, .topbar button, .nav-item, .ghost-button { display: none !important; }
    .app-shell { display: block; }
    .workspace { padding: 0; }
    .panel, .metric { box-shadow: none; }
}

/* Numeric values are entered deliberately with the keyboard, not changed by spinner controls. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.ledger-account-manager {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 14px 18px 18px;
    background: #f3f7f5;
}
.ledger-account-list-toolbar {
    position: sticky;
    top: -14px;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -14px -18px 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
}
.ledger-account-list-toolbar h4 { margin: 0; color: var(--blue); font-size: 1rem; }
.ledger-account-list-toolbar p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.ledger-account-counts { display: flex; gap: 8px; }
.ledger-account-counts span {
    min-width: 100px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 10px;
    background: #fff;
    color: var(--muted);
    text-align: center;
    font-size: .75rem;
}
.ledger-account-counts strong { display: block; color: var(--green); font-size: 1rem; }
.ledger-account-manager-group {
    overflow: hidden;
    border: 1px solid #d8e2dc;
    border-radius: 7px;
    margin: 0 0 10px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(18, 60, 43, .05);
}
.ledger-manager-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 11px; background: #eaf2ed; }
.ledger-manager-main > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ledger-manager-main strong { color: #123c2b; font-size: .94rem; }
.ledger-manager-main small,
.ledger-account-type {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 7px;
    background: #fff;
    color: #68746e;
    font-size: .7rem;
    font-weight: 800;
}
.ledger-manager-main b { font-size: .8rem; color: var(--blue); }
.ledger-account-manager table { margin: 0; min-width: 760px; font-size: .79rem; }
.ledger-account-manager th,
.ledger-account-manager td { padding: .62rem .7rem; }
.ledger-account-manager th { background: #f9fbfa; color: var(--muted); font-size: .72rem; }
.ledger-account-manager button {
    min-height: 31px;
    padding: .35rem .58rem;
    border-radius: 6px;
    font-size: .74rem;
}
.ledger-account-manager button + button { background: #fff; color: var(--danger); border: 1px solid #e4c5c1; }
.ledger-account-manager button:disabled { cursor: not-allowed; opacity: .48; }
.ledger-account-status { font-weight: 800; color: var(--green-2); }
.ledger-account-status.inactive { color: var(--muted); }

@media (max-width: 1080px) {
    .ledger-account-editor { grid-template-columns: 1fr; align-items: start; }
    .ledger-account-editor-title { display: none; }
    .ledger-account-fields { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
    .ledger-account-name-field { grid-column: auto; }
}

@media (max-width: 760px) {
    .modal-overlay { padding: 0; }
    .ledger-account-modal { width: 100%; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
    .ledger-account-modal-head,
    .ledger-account-editor,
    .ledger-account-manager { padding-left: 12px; padding-right: 12px; }
    .ledger-account-fields { grid-template-columns: 1fr 1fr; }
    .ledger-account-name-field { grid-column: 1 / -1; }
    .ledger-account-form-actions { grid-column: 1 / -1; }
    .ledger-account-form-actions button { flex: 1; }
    .ledger-account-list-toolbar { position: static; align-items: flex-start; flex-direction: column; margin: -14px -12px 10px; padding: 10px 12px; }
    .ledger-account-counts { width: 100%; }
    .ledger-account-counts span { flex: 1; min-width: 0; }
    .ledger-manager-main { align-items: flex-start; flex-direction: column; }
    .ledger-account-manager table { min-width: 0; display: block; }
    .ledger-account-manager thead { display: none; }
    .ledger-account-manager tbody { display: grid; }
    .ledger-account-manager tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px 12px;
        padding: 10px;
        border-bottom: 1px solid var(--line);
    }
    .ledger-account-manager tr:last-child { border-bottom: 0; }
    .ledger-account-manager td {
        display: grid;
        gap: 2px;
        min-width: 0;
        padding: 0;
        border: 0;
        white-space: normal;
    }
    .ledger-account-manager td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .66rem;
        font-weight: 700;
    }
    .ledger-account-manager td:nth-child(2),
    .ledger-account-manager td:last-child { grid-column: 1 / -1; }
    .ledger-account-manager td:last-child { display: flex; align-items: center; gap: 6px; }
}
