:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2530;
  --muted: #6b7785;
  --border: #e3e7ed;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

[data-theme="dark"] {
  --bg: #0f1520;
  --surface: #161e2b;
  --text: #e6e9ef;
  --muted: #93a0b3;
  --border: #263042;
  --primary: #4f8cff;
  --primary-hover: #6ea0ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); flex-wrap: wrap; gap: 8px; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn { background: none; border: none; padding: 12px 16px; cursor: pointer; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

main { padding: 20px 24px 60px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 12px; }
.panel-header h2, .panel-header h3 { margin: 0; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.card .card-title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card .card-value { font-size: 26px; font-weight: 700; }
.card .card-delta { font-size: 13px; margin-top: 4px; }
.delta-up { color: var(--ok); }
.delta-down { color: var(--danger); }
.badge-missing { display: inline-block; margin-top: 6px; padding: 2px 8px; border-radius: 12px; background: rgba(220,38,38,0.12); color: var(--danger); font-size: 12px; }

.filters-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 18px; }
.filters-bar label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.filters-bar input, .filters-bar select { padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 13px; }

.btn-primary, .btn-secondary, .btn-icon { border: none; border-radius: 6px; padding: 8px 14px; font-size: 13px; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.btn-icon { background: transparent; font-size: 16px; }

.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; margin-bottom: 10px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.chart-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { cursor: pointer; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.text-cell { white-space: normal; max-width: 280px; }

.pct-red { color: var(--danger); font-weight: 700; }
.pct-yellow { color: var(--warn); font-weight: 700; }
.pct-green { color: var(--ok); font-weight: 700; }

.search-input { width: 100%; max-width: 320px; padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

.list-block { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.list-item { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.list-item.delay { border-left-color: var(--danger); }
.list-item .item-meta { color: var(--muted); font-size: 12px; margin-bottom: 4px; }

.upload-box { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.warnings-block { background: rgba(217,119,6,0.12); border: 1px solid var(--warn); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 12px 18px; border-radius: 8px; font-size: 13px; z-index: 100; }

/* Логин */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 320px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; text-align: left; }
.login-card label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.login-card input { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }

@media (max-width: 640px) {
  main { padding: 14px; }
  .topbar h1 { font-size: 15px; }
  table { font-size: 12px; }
}
