*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg-0: #0A0A0A; --bg-1: #111111; --bg-2: #1A1A1A; --bg-3: #222222; --bg-4: #2A2A2A;
  --border: rgba(255,255,255,0.08); --border-hover: rgba(255,255,255,0.14);
  --text-0: #F0F0F0; --text-1: #B0B0B0; --text-2: #6A6A6A;
  --accent: #D4A843; --accent-dim: rgba(212,168,67,0.12); --accent-hover: #E0B850;
  --blue: #4A90D9; --blue-dim: rgba(74,144,217,0.12);
  --green: #4CAF7D; --green-dim: rgba(76,175,125,0.12);
  --red: #E05555; --red-dim: rgba(224,85,85,0.12);
  --orange: #E09040; --orange-dim: rgba(224,144,64,0.12);
  --radius: 10px; --radius-sm: 7px;
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5;
}
body.light-theme {
  --bg-0: #F0F2F5; --bg-1: #FFFFFF; --bg-2: #F5F6FA; --bg-3: #EAECF0; --bg-4: #DDE0E8;
  --border: rgba(0,0,0,0.08); --border-hover: rgba(0,0,0,0.15);
  --text-0: #1A1A2E; --text-1: #4A4A6A; --text-2: #9A9AB0;
  --accent: #C49A2A; --accent-dim: rgba(196,154,42,0.1);
  --blue: #2E7DD4; --blue-dim: rgba(46,125,212,0.1);
  --green: #2E9E60; --green-dim: rgba(46,158,96,0.1);
  --red: #D03030; --red-dim: rgba(208,48,48,0.1);
  --orange: #C07020; --orange-dim: rgba(192,112,32,0.1);
}
body.light-theme .logo-rest { color: #1A1A2E; }
body.light-theme .tb-logo { color: #1A1A2E; }

/* Базовый цвет текста — наследуется и реагирует на тему */
body { color: var(--text-0); }
.page-title, .li-title, .stat-value, .card-header, .modal-header span,
.mm-name, .form-group input, .form-group select, .form-group textarea,
.search-input, .li-sub, td, th, .fin-desc { color: var(--text-0); }

body { background: var(--bg-0); overflow: hidden; height: 100vh; height: 100dvh; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 0; }

/* ── Login ──────────────────────────────────────────── */
#login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg-0); }
.login-card { width: 100%; max-width: 380px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 16px; padding: 36px 28px; }
.login-logo { font-size: 34px; font-weight: 700; letter-spacing: 3px; margin-bottom: 4px; }
.logo-o { color: var(--accent); }
.logo-rest { color: var(--text-0); }
.login-sub { font-size: 12px; color: var(--text-2); margin-bottom: 28px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 7px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 13px 14px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-0); font-size: 16px; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 70px; }
.input-eye { position: relative; }
.input-eye input { padding-right: 44px; }
.eye-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 16px; color: var(--text-2); }
.login-error { min-height: 18px; font-size: 13px; color: var(--red); margin-bottom: 10px; }
.btn-login { width: 100%; padding: 14px; background: var(--accent); color: #0A0A0A; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; letter-spacing: 0.04em; }
.btn-login:active { background: var(--accent-hover); }

/* ── App ────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { height: calc(56px + env(safe-area-inset-top)); background: var(--bg-1); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; padding-top: env(safe-area-inset-top); flex-shrink: 0; }
.tb-logo { font-size: 18px; font-weight: 700; letter-spacing: 2px; color: var(--text-0); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.sync-indicator { font-size: 13px; }
.icon-btn { background: none; border: none; font-size: 22px; color: var(--text-1); padding: 4px 8px; }

.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; padding-bottom: 100px; }

/* ── Bottom nav ─────────────────────────────────────── */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-1); border-top: 1px solid var(--border); display: flex; align-items: flex-start; padding-top: 10px; padding-bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 100; }
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; color: var(--text-2); cursor: pointer; }
.bn-item svg { width: 26px; height: 26px; }
.bn-item span { font-size: 12px; font-weight: 500; }
.bn-item.active { color: var(--accent); }

/* ── Page header ────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-title { font-size: 22px; font-weight: 600; }

/* ── Buttons ────────────────────────────────────────── */
.btn-primary { padding: 11px 18px; background: var(--accent); color: #0A0A0A; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; }
.btn-primary:active { background: var(--accent-hover); }
.btn-secondary { padding: 11px 18px; background: var(--bg-3); color: var(--text-0); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.btn-add { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #0A0A0A; border: none; font-size: 24px; display: flex; align-items: center; justify-content: center; }

/* ── Stats ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat-clickable:active { transform: scale(0.97); border-color: var(--accent); }
.stat-label { font-size: 11px; color: var(--text-2); text-transform: uppercase; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-accent { color: var(--accent); } .stat-blue { color: var(--blue); } .stat-green { color: var(--green); } .stat-orange { color: var(--orange); } .stat-red { color: var(--red); }

/* ── Cards / list items ─────────────────────────────── */
.card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; }

.list-item { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.li-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.li-title { font-size: 15px; font-weight: 600; }
.li-sub { font-size: 13px; color: var(--text-1); margin-bottom: 3px; }
.li-meta { font-size: 12px; color: var(--text-2); }
.li-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.li-amount { font-size: 16px; font-weight: 600; color: var(--accent); }
.li-actions { display: flex; gap: 8px; }
.icon-action { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg-3); border: 1px solid var(--border); color: var(--text-1); font-size: 15px; display: flex; align-items: center; justify-content: center; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.b-new { background: var(--blue-dim); color: var(--blue); } .b-work { background: var(--orange-dim); color: var(--orange); }
.b-done { background: var(--green-dim); color: var(--green); } .b-wait { background: rgba(180,140,60,0.15); color: #C8A84B; }
.b-cancel { background: var(--red-dim); color: var(--red); } .b-high { background: var(--red-dim); color: var(--red); }
.b-med { background: var(--orange-dim); color: var(--orange); } .b-low { background: var(--green-dim); color: var(--green); }
.b-ok { background: var(--green-dim); color: var(--green); } .b-low-s { background: var(--orange-dim); color: var(--orange); } .b-out { background: var(--red-dim); color: var(--red); }

/* ── Tabs (horizontal scroll) ───────────────────────── */
.tab-bar { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; padding-bottom: 4px; }
.tab { padding: 8px 16px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px; font-size: 13px; color: var(--text-1); white-space: nowrap; }
.tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 500; }

/* ── Search ─────────────────────────────────────────── */
.search-input { width: 100%; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-0); font-size: 16px; margin-bottom: 14px; }
.search-input:focus { outline: none; border-color: var(--accent); }

/* ── Mobile menu ────────────────────────────────────── */
.menu-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; }
.mobile-menu { position: absolute; right: 0; top: 0; bottom: 0; width: 270px; background: var(--bg-1); border-left: 1px solid var(--border); padding: 20px; padding-top: calc(env(safe-area-inset-top) + 20px); animation: slideIn 0.2s ease; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.mm-user { padding-bottom: 16px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.mm-name { font-size: 16px; font-weight: 600; }
.mm-role { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.mm-item { padding: 14px 8px; font-size: 15px; border-radius: var(--radius-sm); }
.mm-item:active { background: var(--bg-2); }
.mm-logout { color: var(--red); margin-top: 8px; border-top: 1px solid var(--border); }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; justify-content: center; z-index: 300; }
.modal { background: var(--bg-1); border-radius: 16px 16px 0 0; width: 100%; max-height: 90vh; display: flex; flex-direction: column; animation: slideUp 0.25s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header span { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--text-2); padding: 4px; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; padding-bottom: calc(env(safe-area-inset-bottom) + 14px); border-top: 1px solid var(--border); display: flex; gap: 10px; }
.modal-footer button { flex: 1; }

/* ── Toast ──────────────────────────────────────────── */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); padding: 12px 22px; background: var(--bg-3); border: 1px solid var(--border-hover); border-radius: var(--radius); font-size: 14px; z-index: 400; }
.toast-success { color: var(--green); border-color: rgba(76,175,125,0.4); }
.toast-error { color: var(--red); border-color: rgba(224,85,85,0.4); }

/* ── Finance rows ───────────────────────────────────── */
.fin-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.fin-row:last-child { border-bottom: none; }
.fin-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-right: 12px; flex-shrink: 0; }
.fin-in { background: var(--green-dim); color: var(--green); } .fin-out { background: var(--red-dim); color: var(--red); }
.fin-meta { flex: 1; } .fin-desc { font-size: 14px; } .fin-date { font-size: 12px; color: var(--text-2); }
.fin-amount { font-weight: 600; } .fin-plus { color: var(--green); } .fin-minus { color: var(--red); }

.empty { text-align: center; color: var(--text-2); padding: 40px 20px; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.alert-warn { background: var(--orange-dim); color: var(--orange); }
.alert-info { background: var(--blue-dim); color: var(--blue); }
.form-divider { font-size: 11px; color: var(--text-2); text-transform: uppercase; margin: 18px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }

/* ── Print overlay ───────────────────────────────────── */
#print-overlay { display: none; position: fixed; inset: 0; background: #fff; color: #000; z-index: 500; overflow-y: auto; }
.print-topbar { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: #f5f5f5; border-bottom: 1px solid #ddd; }
.print-back { background: none; border: none; color: #2E7DD4; font-size: 17px; font-weight: 500; }
.print-do { background: #D4A843; border: none; color: #000; padding: 8px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.print-paper { padding: 24px 20px; font-family: 'Times New Roman', serif; line-height: 1.6; }
.print-paper h4 { margin: 14px 0 6px; }
.print-paper ol { margin: 0 0 8px 20px; }
.print-paper p { margin: 8px 0; }

@media print {
  body > *:not(#print-overlay) { display: none !important; }
  #print-overlay { position: absolute; display: block !important; }
  .no-print { display: none !important; }
  .print-paper { padding: 0; }
}

/* ── PIN screen ──────────────────────────────────────── */
#pin-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg-0); z-index: 50; }
.pin-card { width: 100%; max-width: 340px; text-align: center; }
.pin-title { font-size: 18px; font-weight: 600; margin: 24px 0 4px; color: var(--text-0); }
.pin-user { font-size: 14px; color: var(--accent); margin-bottom: 24px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin-bottom: 16px; height: 18px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--text-2); transition: all 0.15s; }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-error { min-height: 20px; font-size: 13px; color: var(--red); margin-bottom: 12px; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 280px; margin: 0 auto; }
.pin-key { aspect-ratio: 1; max-height: 72px; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-0); font-size: 26px; font-weight: 500; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; transition: background 0.1s; }
.pin-key:active { background: var(--bg-4); }
.pin-key.pin-action { background: none; border: none; font-size: 14px; color: var(--text-2); }
.pin-other { margin-top: 28px; background: none; border: none; color: var(--text-2); font-size: 14px; text-decoration: underline; }

/* ── Face ID ─────────────────────────────────────────── */
.pin-faceid { display: block; margin: 20px auto 0; background: var(--accent-dim); border: 1px solid var(--accent); color: var(--accent); padding: 12px 24px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; }
.pin-faceid:active { background: var(--accent); color: #000; }
#bio-offer { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg-0); z-index: 60; }
.bio-card { width: 100%; max-width: 340px; text-align: center; }
.bio-title { font-size: 20px; font-weight: 600; color: var(--text-0); margin-bottom: 8px; }
.bio-sub { font-size: 14px; color: var(--text-2); line-height: 1.5; }

/* ── Календарь мобильный ─────────────────────────────── */
.mcal-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mcal-title { font-size: 17px; font-weight: 600; color: var(--text-0); }
.mcal-day { margin-bottom: 16px; }
.mcal-daynum { font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border); text-transform: capitalize; }
.mcal-event { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.mcal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mcal-time { font-weight: 600; color: var(--text-0); font-size: 14px; }
.mcal-car { flex: 1; font-size: 13px; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcal-num { font-size: 11px; color: var(--text-2); }

/* ── Отчёты (мобильная) ──────────────────────────────── */
.mtab-bar { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.mtab { padding: 8px 14px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 20px; font-size: 13px; white-space: nowrap; color: var(--text-2); cursor: pointer; }
.mtab.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.mrep-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.mrep-card { background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.mrep-label { font-size: 11px; color: var(--text-2); margin-bottom: 6px; }
.mrep-value { font-size: 18px; font-weight: 700; }
.li-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; font-size: 14px; color: var(--text-0); }
