:root {
--navy: #071B3B;
--navy-2: #0d2852;
--blue: #1455A3;
--blue-2: #1b67c4;
--blue-soft: #e8f0fb;
--bg: #F5F7FA;
--card: #fff;
--text: #13213a;
--muted: #64748b;
--line: #e3e8ef;
--green: #15803d;  --green-bg: #e7f6ec;
--amber: #b45309;  --amber-bg: #fdf3e2;
--red: #b91c1c;    --red-bg: #fdecec;
--purple: #6d28d9; --purple-bg: #f1ebfd;
--gray-bg: #eef1f5;
--radius: 12px;
--shadow: 0 1px 2px rgba(7,27,59,.05), 0 2px 8px rgba(7,27,59,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
color: var(--text); background: var(--bg);
-webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
.btn {
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap;
transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); }
.btn-danger { color: var(--red); border-color: #f3c6c6; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-ghost-light { background: transparent; border-color: rgba(255,255,255,.2); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.08); }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn {
border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1;
width: 38px; height: 38px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--gray-bg); }
.login-wrap {
min-height: 100vh; display: grid; place-items: center; padding: 20px;
background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, var(--blue) 140%);
}
.login-card {
width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 30px 28px;
box-shadow: 0 20px 50px rgba(0,0,0,.25); display: grid; gap: 14px;
}
.login-card h1 { font-size: 20px; margin-top: 6px; }
.app { display: flex; min-height: 100vh; }
.sidebar {
width: 240px; flex-shrink: 0; background: var(--navy); color: #fff;
display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-logo { width: 36px; height: 36px; }
.brand strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand span { display: block; font-size: 12px; opacity: .7; }
.brand-dark { padding: 0; color: var(--navy); }
.brand-dark span { opacity: 1; color: var(--muted); }
.nav { display: grid; gap: 2px; }
.nav a {
display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.78);
padding: 9px 12px; border-radius: 9px; font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.today-pill { font-size: 12px; opacity: .7; padding: 0 6px; }
.scrim { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
position: sticky; top: 0; z-index: 5; background: rgba(245,247,250,.92); backdrop-filter: blur(8px);
display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; flex: 1; }
.menu-btn { display: none; }
.page { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
display: block; padding: 16px 18px; color: inherit; position: relative; overflow: hidden;
transition: transform .12s, box-shadow .12s;
}
.stat:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(7,27,59,.08); }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue); }
.stat.s-green::before { background: var(--green); }
.stat.s-gray::before { background: #94a3b8; }
.stat.s-purple::before { background: var(--purple); }
.stat.s-red::before { background: var(--red); }
.stat.s-amber::before { background: var(--amber); }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 4px 0 10px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-top: 1px solid var(--line); }
.mini-list li:first-child { border-top: 0; }
.mini-list .who { flex: 1; min-width: 0; }
.mini-list .who a { font-weight: 600; color: var(--text); }
.mini-list .who small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.bars { display: grid; gap: 10px; padding: 16px 20px; }
.bar-row { display: grid; grid-template-columns: 80px 1fr 36px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { height: 8px; background: var(--gray-bg); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; width: 0; height: 100%; background: var(--blue); border-radius: 99px; }
.badge {
display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px;
font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-bg); color: #475569;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-active { background: var(--green-bg); color: var(--green); }
.b-trial { background: var(--purple-bg); color: var(--purple); }
.b-inactive { background: var(--red-bg); color: var(--red); }
.b-none { background: var(--gray-bg); color: #64748b; }
.pkg { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 600; white-space: nowrap; }
.when { font-size: 12px; font-weight: 600; white-space: nowrap; }
.when.ok { color: var(--green); } .when.warn { color: var(--amber); } .when.bad { color: var(--red); } .when.muted { color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 260px; }
.toolbar label { font-size: 12px; color: var(--muted); font-weight: 600; }
.chips label.lbl > input { margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 20px; border-bottom: 1px solid var(--line); align-items: center; }
.chip {
border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px;
font-weight: 500; cursor: pointer; color: #334155;
}
.chip:hover { border-color: #c4cfdd; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chips .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.chips .lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.result-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px; font-size: 14px; color: var(--muted); }
.result-bar strong { color: var(--text); }
.highlight { background: var(--blue-soft); color: var(--navy); border-radius: 9px; padding: 8px 12px; font-size: 14px; }
input, select, textarea {
width: 100%; padding: 9px 12px; border: 1px solid #d5dce6; border-radius: 9px; background: #fff;
outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20,85,163,.15); }
input[type="date"] { min-height: 40px; }
textarea { min-height: 80px; resize: vertical; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; background: #fafbfd; border-top: 0; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tbody tr:hover { background: #fafcff; }
td .name { font-weight: 600; color: var(--text); }
td .sub { display: block; font-size: 13px; color: var(--muted); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; color: #334155; }
label > input, label > select, label > textarea { display: block; margin-top: 5px; }
label > .check { margin-top: 6px; }
.card h2 { font-size: 17px; }
.exp-cell { display: grid; gap: 1px; }
.opt { font-weight: 400; color: var(--muted); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.form-error { color: var(--red); background: var(--red-bg); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin: 0; }
.help { font-size: 12px; color: var(--muted); font-weight: 400; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.calc { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--blue-soft); border-radius: 10px; padding: 12px 14px; }
.calc .big { font-size: 18px; font-weight: 700; color: var(--navy); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.detail { display: grid; grid-template-columns: 1fr 1.35fr; gap: 18px; align-items: start; }
.status-hero { padding: 20px; display: grid; gap: 12px; }
.status-hero .exp { font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(7,27,59,.45); display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 20px 20px; }
.modal-body .form-grid { grid-template-columns: 1fr 1fr; }
.toast {
position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
max-width: calc(100vw - 32px);
}
.toast.err { background: var(--red); }
.loading { padding: 40px; text-align: center; color: var(--muted); }
@media (max-width: 1100px) {
.stats { grid-template-columns: repeat(2, 1fr); }
.grid-2, .detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
.sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
.app.nav-open .sidebar { transform: none; }
.app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(7,27,59,.4); }
.menu-btn { display: inline-flex; }
.topbar { padding: 12px 14px; }
.topbar h1 { font-size: 18px; }
.topbar-add span { display: none; }
.page { padding: 16px 12px 40px; }
.stat .value { font-size: 26px; }
.form-grid, .modal-body .form-grid { grid-template-columns: 1fr; }
.toolbar, .chips, .result-bar { padding-left: 14px; padding-right: 14px; }
table.responsive thead { display: none; }
table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
table.responsive tr { border-top: 1px solid var(--line); padding: 12px 14px; }
table.responsive td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex-shrink: 0; }
table.responsive .exp-cell { justify-items: end; }
table.responsive td.primary { display: block; text-align: left; padding-bottom: 6px !important; }
table.responsive td.primary::before { display: none; }
table.responsive td.actions { justify-content: flex-start; padding-top: 8px !important; }
table.responsive td.actions::before { display: none; }
.kv { grid-template-columns: 110px 1fr; }
}
@media (max-width: 420px) {
.stats { gap: 10px; }
.stat { padding: 13px 14px; }
}

/* ---- payments / P&L (added) ---- */
.money-box{grid-column:1/-1;border:1px solid #e3e8ef;border-radius:12px;padding:14px;background:#f8fafc}
.money-title{font-weight:700;margin-bottom:10px}
.money-sum{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-top:12px;padding-top:10px;border-top:1px dashed #d5dce6}
.money-sum strong{font-size:1.1rem;margin-left:6px}
.pos{color:#15803d}.neg{color:#b91c1c}
.pay-cell{display:flex;flex-direction:column;gap:2px;font-size:.9em;white-space:nowrap}
.pay-cell small{color:#64748b}
.cred-title{grid-column:1/-1;font-weight:700;margin-top:8px;padding-top:12px;border-top:1px solid #e3e8ef}
.pnl-filters{display:flex;flex-wrap:wrap;gap:10px 18px;align-items:center}
.pnl-chips{display:flex;flex-wrap:wrap;gap:6px}
.pnl-custom{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.pnl-custom input{margin-left:4px}
.pnl-range{margin-top:10px}
.pnl-stats{margin-top:14px}
.pnl-stats .value.money{font-size:1.6rem}
.pnl-details{margin-top:14px}
.pnl-details summary{cursor:pointer;font-weight:600;padding:6px 0}
#pnl-box{margin-bottom:6px}
