:root {
    --sidebar:#4e5a6d;
    --sidebar2:#445063;
    --bg:#ebeff4;
    --panel:#ffffff;
    --line:#d6dce6;
    --text:#243041;
    --muted:#627087;
    --green:#0b7f16;
    --red:#b21226;
    --btn:#2d4f86;
}
* { box-sizing:border-box; }
body { margin:0; font-family:'Open Sans', Arial, sans-serif; background:var(--bg); color:var(--text); }
a { color:inherit; text-decoration:none; }
.shell { min-height:100vh; display:block; }
.sidebar {
    background:linear-gradient(180deg,#3f4b61 0%, #4f5d75 55%, #445168 100%);
    color:#fff;
    padding:14px 12px;
    border-right:1px solid rgba(255,255,255,.15);
    box-shadow:inset -1px 0 0 rgba(0,0,0,.15);
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    width:300px;
    overflow:auto;
    z-index:100;
}
.sidebar h1 {
    margin:0 0 14px;
    font-size:38px;
    letter-spacing:.5px;
    font-weight:700;
}
.menu,
.menu ul {
    margin:0;
    padding:0;
    list-style:none;
}
.menu > li {
    margin:4px 0;
}
.menu a {
    display:block;
    padding:8px 10px;
    font-size:var(--fs-menu, 12px);
    border:1px solid transparent;
    background:transparent;
    color:#eef3fb;
    transition:background .15s ease, border-color .15s ease, transform .1s ease;
}
.menu a.mi {
    position:relative;
    padding-left:36px;
}
.menu a.mi::before {
    position:absolute;
    left:10px;
    top:50%;
    transform:translateY(-50%);
    width:18px;
    height:18px;
    border:1px solid rgba(255,255,255,.35);
    background:rgba(255,255,255,.08);
    display:flex;
    align-items:center;
    justify-content:center;
    color:#ffffff;
    content:"";
    background-repeat:no-repeat;
    background-position:center;
    background-size:14px 14px;
    background-image:var(--mi-icon);
}
.menu a.mi-dashboard { --mi-icon:url("icons/menu/dashboard.svg"); }
.menu a.mi-ledger { --mi-icon:url("icons/menu/ledger.svg"); }
.menu a.mi-bookings { --mi-icon:url("icons/menu/bookings.svg"); }
.menu a.mi-receipts { --mi-icon:url("icons/menu/receipts.svg"); }
.menu a.mi-partners { --mi-icon:url("icons/menu/partners.svg"); }
.menu a.mi-consumers { --mi-icon:url("icons/menu/consumers.svg"); }
.menu a.mi-docs { --mi-icon:url("icons/menu/docs.svg"); }
.menu a.mi-import { --mi-icon:url("icons/menu/import.svg"); }
.menu a.mi-articles { --mi-icon:url("icons/menu/articles.svg"); }
.menu a.mi-settings { --mi-icon:url("icons/menu/settings.svg"); }
.menu > li > a {
    font-weight:700;
    letter-spacing:.2px;
}
.menu > li > a.active,
.menu > li > a:hover {
    background:rgba(255,255,255,.13);
    border-color:rgba(255,255,255,.22);
}
.menu ul {
    margin-top:3px;
    margin-left:8px;
    border-left:2px solid rgba(255,255,255,.15);
    padding-left:8px;
}
.menu ul li {
    margin:2px 0;
}
.menu ul a {
    font-weight:600;
    color:#e3ebf8;
    padding:6px 8px;
}
.menu ul a.active,
.menu ul a:hover {
    background:rgba(255,255,255,.11);
    border-color:rgba(255,255,255,.2);
}
.content { padding:12px; margin-left:300px; min-height:100vh; }
.notice { padding:10px; margin-bottom:8px; border:1px solid transparent; }
.notice.ok { background:#dcfce7; border-color:#86efac; color:#14532d; }
.notice.err { background:#fee2e2; border-color:#fca5a5; color:#991b1b; }
.cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-bottom:10px; }
.card, .edit-panel, .ledger, .top { background:var(--panel); border:1px solid var(--line); }
.card { padding:10px; }
.card h3 { margin:0 0 8px; font-size:13px; color:#4f5f77; }
.value { font-size:24px; font-weight:700; }
.green { color:var(--green); }
.red { color:var(--red); }
.toolbar { display:flex; justify-content:space-between; align-items:end; gap:8px; margin-bottom:8px; }
.toolbar-actions { display:flex; gap:8px; align-items:center; }
.inline-actions { display:flex; gap:6px; align-items:center; }
.inline-actions form { margin:0; }
.filterbar { display:flex; gap:8px; flex-wrap:wrap; align-items:end; }
label { display:flex; flex-direction:column; gap:4px; font-size:12px; font-weight:600; }
input, select, textarea, button, .btn { border:1px solid #c7d0dd; padding:7px 9px; font-size:var(--fs-input, 12px); border-radius:0; font-family:'Open Sans', Arial, sans-serif; }
button, .btn { background:var(--btn); color:#fff; cursor:pointer; }
.btn.danger { background:#9b1c31; border-color:#9b1c31; }
.grid4 { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; align-items:end; }
.grid4 .span-2 { grid-column: span 2; }
table { width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--line); }
th, td { border-bottom:1px solid #e6ecf3; padding:7px; text-align:left; vertical-align:top; }
th { font-size:var(--fs-table-head, 14px); }
td { font-size:var(--fs-table-body, 14px); }
.amount { text-align:right; white-space:nowrap; font-weight:700; }
.actions { display:flex; gap:6px; align-items:center; }
.actions form { margin:0; }
.actions .btn {
    display:inline-flex;
    align-items:center;
    gap:0;
    width:34px;
    height:34px;
    min-width:34px;
    padding:0;
    justify-content:center;
    font-weight:700;
    color:#fff;
}
.actions .btn::before {
    font-size:13px;
    line-height:1;
}
.actions .btn:not(.danger)::before {
    content:"\270E";
}
.actions .btn:not(.danger) {
    background:var(--btn);
    border-color:var(--btn);
}
.actions .btn.receipt::before {
    content:"\1F9FE";
}
.actions .btn.receipt {
    background:#4a5669;
    border-color:#4a5669;
}
.actions .btn.receipt.linked {
    background:#0f7f47;
    border-color:#0f7f47;
}
.actions .btn.danger::before {
    content:"\2716";
}
.actions .btn.confirm::before {
    content:"\2714";
}
.actions .btn.confirm {
    background:#0f7f47;
    border-color:#0f7f47;
}
.actions .btn.skip::before {
    content:"\23F8";
}
.actions .btn.skip {
    background:#9a6f14;
    border-color:#9a6f14;
}
.actions .btn.danger {
    background:#9b1c31;
    border-color:#9b1c31;
}
.actions .btn:active {
    transform:translateY(1px);
    filter:brightness(.95);
}
.selected td { background:#fff9d8; }
.edit-panel { margin-top:10px; padding:10px; }
.edit-panel h3 { margin:0 0 8px; font-size:16px; }
.edit-panel {
    background:#fff;
    border:1px solid var(--line);
    box-shadow:0 1px 0 rgba(0,0,0,.03);
    padding:14px;
}
.edit-panel h3 {
    margin:0 0 12px;
    padding:0;
    background:none;
    border:0;
    color:#1f3357;
    font-size:24px;
    font-weight:700;
}
.panel-head {
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:8px;
    cursor:move;
    user-select:none;
}
.panel-head h3 {
    margin:0;
}
.panel-close {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:28px;
    height:28px;
    border:1px solid #c7d0dd;
    background:#fff;
    color:#2d4f86;
    font-weight:700;
    text-decoration:none;
}
.panel-close:hover {
    background:#f3f6fb;
}
.modal-overlay {
    position:fixed;
    inset:0;
    background:rgba(17, 24, 39, .45);
    display:block;
    z-index:1200;
}
.modal-window {
    position:absolute;
    top:40px;
    left:50%;
    transform:translateX(-50%);
    width:min(1200px, 96vw);
    min-width:520px;
    min-height:260px;
    max-width:96vw;
    max-height:88vh;
    background:#fff;
    border:1px solid var(--line);
    box-shadow:0 12px 30px rgba(0,0,0,.22);
    padding:14px;
    overflow:auto;
    resize:both;
    font-size:var(--fs-edit-dialog, 14px);
}
.booking-modal {
    padding:0;
    overflow:hidden auto;
}
.modal-titlebar {
    background:#1e3760;
    color:#fff;
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    gap:14px;
    padding:8px 12px;
}
.modal-titlebar .title-left {
    font-size:24px;
    font-weight:700;
    line-height:1;
}
.modal-titlebar .title-main {
    font-size:32px;
    font-weight:400;
    line-height:1.1;
    opacity:.95;
}
.booking-modal .panel-close {
    background:transparent;
    color:#fff;
    border-color:rgba(255,255,255,.45);
}
.booking-modal .panel-close:hover {
    background:rgba(255,255,255,.15);
}
.booking-edit-form {
    padding:12px;
    display:grid;
    gap:10px;
}
.booking-edit-form .row-top {
    display:grid;
    grid-template-columns:190px 1fr 170px 190px;
    gap:12px;
    align-items:start;
}
.booking-edit-form .row-full {
    display:grid;
    grid-template-columns:1fr;
    gap:4px;
}
.booking-edit-form .cell {
    display:grid;
    grid-template-columns:1fr;
    gap:4px;
}
.booking-edit-form .cell.wide {
    min-width:0;
}
.booking-edit-form input,
.booking-edit-form select {
    height:42px;
    border:1px solid #c7d0dd;
    background:#fff;
}
.booking-edit-form .field-label {
    color:#445168;
    font-size:calc(var(--fs-edit-dialog, 14px) * 0.95);
    font-weight:600;
}
.booking-edit-form .type-radio {
    border:1px solid #d7deea;
    background:#f7f9fd;
    padding:6px 10px;
}
.booking-edit-form .type-radio label {
    display:flex;
    flex-direction:row;
    gap:8px;
    align-items:center;
    margin:4px 0;
    font-weight:600;
}
.booking-edit-form .actions-row {
    display:flex;
    align-items:end;
    justify-content:flex-end;
}
.booking-edit-form .actions-row .btn {
    min-width:240px;
}
.edit-panel .grid4 {
    grid-template-columns:repeat(4, minmax(180px, 1fr));
    gap:12px 10px;
    align-items:end;
}
.edit-panel .grid4 label {
    display:flex;
    flex-direction:column;
    align-items:stretch;
    gap:5px;
    background:transparent;
    border:0;
    padding:0;
    font-weight:600;
}
.edit-panel .grid4 label:focus-within {
    outline:none;
    box-shadow:none;
}
.edit-panel .grid4 input,
.edit-panel .grid4 select {
    height:34px;
    background:#ffffff;
    border:1px solid #c7d0dd;
}
.edit-panel .btn {
    min-width:200px;
}
.edit-panel .grid4 > div {
    align-self:end;
}
.edit-panel,
.edit-panel label,
.edit-panel input,
.edit-panel select,
.edit-panel textarea,
.edit-panel .btn,
.modal-window label,
.modal-window input,
.modal-window select,
.modal-window textarea,
.modal-window .btn {
    font-size:var(--fs-edit-dialog, 14px);
}
.modern-form {
    display:grid;
    grid-template-columns:repeat(2, minmax(280px, 1fr));
    gap:14px 14px;
    align-items:end;
}
.modern-form .span-2 {
    grid-column:1 / -1;
}
.modern-form label {
    display:flex;
    flex-direction:column;
    gap:6px;
    padding:8px;
    border:1px solid #dde4ef;
    background:#f9fbff;
}
.modern-form .btn {
    min-width:220px;
}
.add-form { display:none; }
body.show-add-booking .add-booking,
body.show-add-partner .add-partner,
body.show-add-consumer .add-consumer,
body.show-add-document .add-document,
body.show-add-category .add-category,
body.show-add-recurring .add-recurring {
    display:block;
}
@media (max-width:1400px) {
    .edit-panel .grid4 {
        grid-template-columns:repeat(3, minmax(180px, 1fr));
    }
}
@media (max-width:1100px) {
    .edit-panel .grid4 {
        grid-template-columns:repeat(2, minmax(180px, 1fr));
    }
    .modern-form {
        grid-template-columns:1fr;
    }
    .modern-form .span-2 {
        grid-column:1;
    }
    .booking-edit-form .row-top {
        grid-template-columns:1fr;
    }
    .modal-titlebar {
        grid-template-columns:1fr auto;
    }
    .modal-titlebar .title-left {
        display:none;
    }
    .modal-titlebar .title-main {
        font-size:22px;
    }
}
.ledger-wrap { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.ledger-head { padding:4px; text-align:center; color:#fff; font-weight:700; letter-spacing:2px; }
.receipt-items-table input {
    width:100%;
    min-width:80px;
}
.receipt-items-table td:first-child input {
    max-width:56px;
}
.receipt-items-table {
    table-layout: fixed;
}
.receipt-items-table th:nth-child(1),
.receipt-items-table td:nth-child(1) { width:64px; }
.receipt-items-table th:nth-child(2),
.receipt-items-table td:nth-child(2) { width:56%; }
.receipt-items-table th:nth-child(3),
.receipt-items-table td:nth-child(3),
.receipt-items-table th:nth-child(4),
.receipt-items-table td:nth-child(4),
.receipt-items-table th:nth-child(5),
.receipt-items-table td:nth-child(5) { width:10%; }
.receipt-items-table th:nth-child(6),
.receipt-items-table td:nth-child(6) { width:120px; }
.receipt-items-table input[type="number"]::-webkit-outer-spin-button,
.receipt-items-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.receipt-items-table input[type="number"] {
    -moz-appearance: textfield;
}
.line-actions {
    display:flex;
    gap:6px;
    align-items:center;
}
.line-actions .btn {
    min-width:36px;
    height:32px;
    padding:0 8px;
}
.income-box .ledger-head { background:var(--green); }
.expense-box .ledger-head { background:var(--red); }
.panel, .top { border:1px solid var(--line); background:#fff; padding:8px; margin-bottom:8px; }
.muted-block { color:var(--muted); font-size:12px; }
.calendar-month h3 {
    margin:0 0 8px;
}
.calendar-grid {
    display:grid;
    grid-template-columns:repeat(7, minmax(0, 1fr));
    border:1px solid var(--line);
    background:#fff;
}
.cal-head {
    padding:8px;
    border-bottom:1px solid var(--line);
    background:#f3f6fb;
    font-weight:700;
    font-size:12px;
    text-align:center;
}
.cal-cell {
    min-height:130px;
    border-right:1px solid #e6ecf3;
    border-bottom:1px solid #e6ecf3;
    padding:6px;
}
.cal-cell:nth-child(7n) {
    border-right:0;
}
.cal-cell.empty {
    background:#f8fafc;
}
.cal-day {
    font-size:12px;
    font-weight:700;
    color:#334155;
    margin-bottom:6px;
}
.cal-events {
    display:flex;
    flex-direction:column;
    gap:5px;
}
.cal-item {
    border:1px solid #cfd8e6;
    padding:4px 6px;
    font-size:11px;
    display:flex;
    flex-direction:column;
    gap:3px;
}
.cal-item strong {
    text-align:right;
}
.cal-item.book.inc,
.cal-item.rec.inc {
    border-left:4px solid #0b7f16;
}
.cal-item.book.exp,
.cal-item.rec.exp {
    border-left:4px solid #b21226;
}
@media (max-width:1200px) {
    .shell { display:block; }
    .sidebar {
        position:static;
        width:auto;
        max-height:none;
    }
    .content {
        margin-left:0;
    }
    .cards, .grid4, .ledger-wrap { grid-template-columns:1fr; }
    .toolbar { flex-direction:column; align-items:stretch; }
}

