:root {
  --bg: #0f1117; --surface: #1a1d27; --border: #2a2d3e;
  --text: #e2e8f0; --muted: #64748b;
  --green: #22c55e; --red: #ef4444; --blue: #3b82f6;
  --accent: #6366f1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.6 system-ui, sans-serif; }

nav {
  display: flex; align-items: center; gap: 4px;
  padding: 0 20px; height: 48px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 6px; font-weight: 500; }
nav a:hover, nav a.active { color: var(--text); background: var(--border); }
nav .brand { color: var(--text); font-weight: 700; margin-right: 12px; font-size: 15px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
section { margin-bottom: 28px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 28px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; }
.card.green { border-color: var(--green); }
.card.green .value { color: var(--green); }
.card.red { border-color: var(--red); }
.card.red .value { color: var(--red); }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 10px; overflow: hidden; }
thead { background: var(--border); }
th { padding: 10px 12px; text-align: left; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
td { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-red { background: rgba(239,68,68,.08); }
.row-green { background: rgba(34,197,94,.06); }
.muted-row { opacity: .5; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
tr:hover td { background: rgba(255,255,255,.02); }

.badge { background: var(--border); padding: 2px 8px; border-radius: 12px; font-size: 11px; white-space: nowrap; }
.muted { color: var(--muted); font-weight: 400; }

.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
input, select, textarea {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 7px 10px; border-radius: 6px; font-size: 13px; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.btn { background: var(--accent); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn:hover { opacity: .88; }
.btn-sm { background: var(--border); color: var(--text); border: none; padding: 4px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; }
.btn-sm:hover { background: var(--accent); color: #fff; }

.page-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.page-header h1 { margin-bottom: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.card-partner { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.card-partner h2 { color: var(--text); font-size: 16px; margin-bottom: 10px; }
.card-partner p { margin-bottom: 6px; color: var(--muted); }
.green-text { color: var(--green) !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* МСК время */
.msk-time { font-size: 13px; color: var(--muted); margin-left: auto; }
.page-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

/* Умный календарь — полная страница */
.cal-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; }
.cal-nav-title { font-size:20px; font-weight:700; }
.cal-nav-btn { background:var(--surface); border:1px solid var(--border); color:var(--text);
               padding:6px 16px; border-radius:7px; text-decoration:none; font-size:14px; }
.cal-nav-btn:hover { background:var(--border); text-decoration:none; }

.cal-legend { display:flex; gap:14px; margin-bottom:16px; font-size:12px; color:var(--muted); flex-wrap:wrap; align-items:center; }
.leg-dot { width:9px; height:9px; border-radius:50%; display:inline-block; margin-right:3px; vertical-align:middle; }
.leg-dot.income-received { background:#22c55e; }
.leg-dot.income-pending  { background:#fbbf24; }
.leg-dot.income-overdue  { background:#ef4444; }
.leg-dot.expense-dot     { background:#64748b; }
.leg-dot.recurring-dot   { background:#8b5cf6; }

.cal-full-wrap { overflow-x:auto; }
.cal-full { width:100%; border-collapse:separate; border-spacing:4px; table-layout:fixed; }
.cal-full thead th { text-align:center; font-size:11px; color:var(--muted); text-transform:uppercase;
                     padding:8px 0; font-weight:600; }
.cal-empty { background:transparent !important; border:none !important; }
.cal-cell { background:var(--surface); border:1px solid var(--border); border-radius:8px;
            vertical-align:top; padding:8px; min-height:88px; transition:border-color .15s; }
.cal-cell:hover { border-color:var(--accent); }
.cal-is-today { border-color:var(--accent) !important; background:rgba(99,102,241,.1) !important; }
.cell-top { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:4px; }
.cell-num { font-size:14px; font-weight:600; }
.today-num { color:var(--accent); }
.cell-dots { display:flex; gap:3px; flex-wrap:wrap; justify-content:flex-end; }
.dot { width:7px; height:7px; border-radius:50%; display:inline-block; }
.dot-overdue  { background:#ef4444; }
.dot-pending  { background:#fbbf24; }
.dot-received { background:#22c55e; }
.dot-expense  { background:#64748b; }
.dot-recurring { background:#8b5cf6; }
.cell-events { display:flex; flex-direction:column; gap:2px; }
.ev-tag { font-size:10px; border-radius:3px; padding:2px 5px; white-space:nowrap;
          overflow:hidden; text-overflow:ellipsis; max-width:100%; }
.ev-overdue  { background:rgba(239,68,68,.25);  color:#fca5a5; }
.ev-pending  { background:rgba(251,191,36,.2);  color:#fde68a; }
.ev-received { background:rgba(34,197,94,.2);   color:#86efac; }
.ev-expense  { background:rgba(100,116,139,.2); color:#94a3b8; }

/* Попап деталей дня */
.day-popup { position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:100;
             display:flex; align-items:center; justify-content:center; padding:16px; }
.day-popup.hidden { display:none; }
.popup-box { background:var(--surface); border:1px solid var(--border); border-radius:14px;
             width:100%; max-width:480px; max-height:80vh; overflow-y:auto; }
.popup-header { display:flex; justify-content:space-between; align-items:center;
                padding:16px 20px 12px; border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface); }
.popup-header h3 { font-size:16px; font-weight:700; }
.popup-close { background:none; border:none; color:var(--muted); font-size:18px; cursor:pointer; padding:0 4px; }
.popup-close:hover { color:var(--text); }
.popup-section { padding:14px 20px; border-bottom:1px solid var(--border); }
.popup-section:last-child { border-bottom:none; }
.popup-section-title { font-size:11px; text-transform:uppercase; color:var(--muted); letter-spacing:.5px; margin-bottom:10px; font-weight:600; }
.pop-item { background:var(--bg); border-radius:8px; padding:10px 12px; margin-bottom:8px; border-left:3px solid transparent; }
.pop-item:last-child { margin-bottom:0; }
.pop-received { border-color:#22c55e; }
.pop-overdue  { border-color:#ef4444; }
.pop-pending  { border-color:#fbbf24; }
.pop-expense  { border-color:#64748b; }
.pop-main { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:4px; }
.pop-who  { font-weight:600; font-size:13px; }
.pop-amount { font-weight:700; font-size:14px; color:#22c55e; white-space:nowrap; margin-left:8px; }
.pop-neg  { color:#ef4444; }
.pop-sub  { font-size:11px; color:var(--muted); }
.pop-status { font-weight:600; }
.btn-receive { background:rgba(34,197,94,.2); color:#86efac; border:1px solid #22c55e55; padding:5px 12px; border-radius:5px; cursor:pointer; font-size:12px; }
.btn-receive:hover { background:rgba(34,197,94,.35); }
.card.orange { border-color:#fbbf24; }
.card.orange .value { color:#fbbf24; }

/* Мини-календарь (старый, для обратной совместимости стилей) */
.cal-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow-x: auto; }
.cal { width: 100%; border-collapse: separate; border-spacing: 3px; }
.cal thead th { text-align: center; font-size: 11px; color: var(--muted); text-transform: uppercase;
                padding: 6px 0; font-weight: 600; }
.cal-day { width: 14.28%; vertical-align: top; min-width: 60px; min-height: 64px;
           background: var(--bg); border-radius: 6px; padding: 5px 6px;
           border: 1px solid transparent; cursor: default; }
.cal-empty { background: transparent !important; border: none !important; }
.cal-num { font-size: 13px; font-weight: 600; display: block; margin-bottom: 3px; }
.cal-today { border-color: var(--accent) !important; background: rgba(99,102,241,.1) !important; }
.cal-today .cal-num { color: var(--accent); }
.cal-overdue  { background: rgba(239,68,68,.12) !important; }
.cal-pending  { background: rgba(251,191,36,.1)  !important; }
.cal-received { background: rgba(34,197,94,.08)  !important; }
.cal-ev { font-size: 10px; border-radius: 3px; padding: 1px 4px; margin-top: 2px;
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-overdue  { background: rgba(239,68,68,.35);  color: #fca5a5; }
.ev-pending  { background: rgba(251,191,36,.3);  color: #fde68a; }
.ev-received { background: rgba(34,197,94,.25);  color: #86efac; }
.cal-legend  { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); align-items: center; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.leg-dot.overdue  { background: #ef4444; }
.leg-dot.pending  { background: #fbbf24; }
.leg-dot.received { background: #22c55e; }

@media (max-width: 600px) {
  .two-col { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  nav a:not(.brand) { font-size: 12px; padding: 5px 8px; }
  .cal-day { min-width: 40px; min-height: 48px; padding: 3px 4px; }
  .cal-ev  { display: none; }
  .cal-num { font-size: 12px; }
}
