:root {
  --ink: #1f2d3d; --muted: #5b6b7b; --line: #e3e9ee; --bg: #e9eef2; --card: #ffffff;
  --blue: #0f6fc6; --blue-dark: #0a4f8f; --blue-bg: #e3f0fc;
  --green: #1f9d57; --green-bg: #e6f6ec; --green-line: #b5e0c4; --green-ink: #0e4a2b;
  --red: #c9372c; --red-bg: #fde3e1; --red-line: #eaa7a2; --red-ink: #6e130e;
  --ice: #7fb2e5; --ice-bg: #dbe9f7; --ice-line: #a9c6e6; --ice-ink: #082f57;
  --amber-bg: #fff1c9; --amber-line: #e0b43c; --amber-ink: #5a3b00;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--ink); background: var(--bg); font-size: 14px; }
button, input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
#app { padding: 20px 24px 32px; max-width: 1400px; }
.hidden { display: none !important; }

.card { background: var(--card); border-radius: 12px; padding: 22px; box-shadow: 0 1px 2px rgba(31, 45, 61, .08); }
.title { font-size: 20px; font-weight: 700; margin: 0; }
.sub { color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.row.center { align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.gap { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .lbl { font-size: 13px; font-weight: 600; color: #3b4a5a; }
.inp { height: 44px; border: 1px solid #b9c5d0; border-radius: 8px; padding: 0 14px; background: #fff; width: 100%; font-size: 15px; }
.inp:focus-visible, .btn:focus-visible, textarea:focus-visible { outline: 3px solid #9cc9f2; outline-offset: 1px; }
textarea.inp { height: 84px; padding: 10px 14px; resize: none; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

.btn { height: 44px; padding: 0 22px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { background: var(--blue-dark); }
.btn.line { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.line:hover { background: var(--blue-bg); }
.btn.grey { background: #fff; color: #3b4a5a; border: 1.5px solid #8a99a8; }
.btn:disabled { background: #d9e0e6; color: #6a7886; cursor: not-allowed; border-color: transparent; }
.btn.wide { width: 100%; justify-content: center; height: 48px; }

.table { margin-top: 18px; }
.th, .tr { display: flex; align-items: center; padding: 8px 14px; gap: 8px; }
.th { background: #f2f5f8; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tr { border-bottom: 1px solid #edf1f4; min-height: 46px; }
.c-n { width: 44px; color: var(--muted); } .c-grow { flex: 1; min-width: 0; }
.c-date { width: 150px; } .c-sum { width: 130px; text-align: right; } .c-paid { width: 110px; text-align: center; }
.c-status { width: 170px; } .c-delay { width: 90px; text-align: right; }
.c-amount { width: 200px; } .c-tag { width: 100px; text-align: right; }
.tr .inp { height: 38px; text-align: right; font-size: 14px; }
.tr.edited .inp { border: 2px solid #c98a00; background: #fff6dc; font-weight: 600; }
.tr.overdue { background: var(--red-bg); color: var(--red-ink); font-weight: 600; }
.tr.frozen { background: #eef5fc; color: #0b3f73; }
.old { font-size: 12px; color: var(--muted); text-decoration: line-through; font-weight: 400; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #e3e9ee; color: #3b4a5a; white-space: nowrap; }
.chip.paid { background: #d3f0dd; color: var(--green-ink); }
.chip.overdue { background: #f6b9b4; color: var(--red-ink); }
.chip.frozen { background: #bcd8f2; color: var(--ice-ink); }
.chip.edited { background: #ffe9b0; color: #6b4700; }
.chip.user { background: var(--blue-bg); color: var(--blue-dark); font-size: 13px; font-weight: 600; }
.chip.dept { background: #e9e3fa; color: #3f2a82; font-size: 13px; font-weight: 600; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 14px; color: inherit; padding: 0 0 0 2px; }

.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { border-radius: 12px; padding: 16px 18px; background: #fff; box-shadow: 0 1px 2px rgba(31, 45, 61, .08); border: 1px solid transparent; }
.kpi .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 8px; }
.kpi .s { font-size: 12px; margin-top: 4px; color: var(--muted); }
.kpi.green { background: var(--green-bg); border-color: var(--green-line); } .kpi.green .k, .kpi.green .s { color: #14633a; } .kpi.green .v { color: var(--green-ink); }
.kpi.red { background: var(--red-bg); border-color: var(--red-line); } .kpi.red .k, .kpi.red .s { color: #8f1d17; } .kpi.red .v { color: var(--red-ink); }
.kpi.ice { background: var(--ice-bg); border-color: var(--ice-line); } .kpi.ice .k, .kpi.ice .s { color: #0b3f73; } .kpi.ice .v { color: var(--ice-ink); }

.bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > div { height: 100%; background: var(--green); border-radius: 999px; }

.banner { border-radius: 10px; padding: 14px 18px; display: flex; gap: 12px; align-items: flex-start; }
.banner.red { background: var(--red-bg); border: 1px solid var(--red-line); color: var(--red-ink); }
.banner.ice { background: var(--ice-bg); border: 1px solid var(--ice-line); color: var(--ice-ink); }
.banner.amber { background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber-ink); }
.banner b { font-weight: 700; }

.side { width: 340px; flex: none; }
.sumrow { display: flex; justify-content: space-between; margin-top: 10px; color: #3b4a5a; }
.sumrow b { color: var(--ink); }
.neg { color: #b3261e !important; }

.overlay { position: fixed; inset: 0; background: rgba(20, 35, 50, .58); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 600px; max-width: 100%; padding: 26px 28px; box-shadow: 0 20px 60px rgba(10, 20, 30, .35); }
.preview { background: #eef5fc; border: 1px solid #c5daf0; border-radius: 10px; padding: 14px 16px; margin-top: 16px; color: #0b3f73; font-size: 13px; }
.preview div { display: flex; justify-content: space-between; margin-top: 6px; }

.filters { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.ms { position: relative; flex: 1; min-width: 280px; }
.ms-box { min-height: 44px; border: 1px solid #b9c5d0; border-radius: 8px; padding: 6px 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #fff; }
.ms-add { background: none; border: 0; color: var(--blue); font-weight: 600; cursor: pointer; padding: 4px 6px; }
.ms-pop { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px; background: #fff; border: 1px solid #b9c5d0; border-radius: 10px; box-shadow: 0 10px 30px rgba(10, 20, 30, .2); padding: 10px; }
.ms-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.ms-tab { border: 0; background: #f2f5f8; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-weight: 600; color: #3b4a5a; }
.ms-tab.on { background: var(--blue); color: #fff; }
.ms-list { max-height: 240px; overflow: auto; margin-top: 8px; }
.ms-item { display: flex; gap: 8px; align-items: center; padding: 6px 4px; cursor: pointer; }
.ms-item input { width: 16px; height: 16px; }

.chart { display: flex; margin-top: 12px; }
.yax { width: 44px; position: relative; height: 286px; font-size: 11px; color: var(--muted); flex: none; }
.yax span { position: absolute; right: 8px; transform: translateY(50%); }
.plot { flex: 1; min-width: 0; position: relative; height: 286px; overflow-x: auto; }
.plot-inner { position: relative; height: 286px; min-width: 100%; display: flex; justify-content: space-around; }
.gl { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.gl.base { border-top-color: #b9c5d0; }
.mon { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 104px; position: relative; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 264px; }
.col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 28px; }
.col i { display: block; width: 28px; border-radius: 4px 4px 0 0; }
.col em { font-style: normal; font-size: 10px; font-weight: 600; margin-bottom: 3px; }
.mlabel { height: 22px; line-height: 22px; font-size: 12px; font-weight: 600; color: #3b4a5a; }
.legend { display: flex; gap: 16px; font-size: 13px; color: #3b4a5a; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2d3d; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 60; max-width: 90%; }
.toast.err { background: #8f1d17; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.tabs { display: flex; gap: 8px; margin: 12px 0 0; }
@media (max-width: 760px) { .grid3 { grid-template-columns: 1fr; } .side { width: 100%; } }
