/* ============================================================
   АВАЛОГИСТИК — UI v3.0  |  Redesign 2026
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ---------- VARIABLES ---------- */
:root {
  --sidebar-w: 240px;
  --header-h:  60px;

  /* Brand */
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-soft:  #eff6ff;
  --primary-ring:  rgba(59,130,246,.18);

  /* Sidebar — глубокий сине-угольный */
  --sb-bg:         #0d1424;
  --sb-bg2:        #111827;
  --sb-border:     rgba(255,255,255,.07);
  --sb-item:       #6b7fa3;
  --sb-active:     #93c5fd;
  --sb-active-bg:  rgba(147,197,253,.12);
  --sb-hover:      rgba(255,255,255,.06);

  /* Content surfaces */
  --bg:            #f0f4fa;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --border-soft:   #f1f5f9;

  /* Text */
  --text:          #0f172a;
  --text-2:        #334155;
  --muted:         #64748b;
  --muted-2:       #94a3b8;

  /* KPI card accents */
  --c-revenue:     #3b82f6;
  --c-expenses:    #ef4444;
  --c-fuel:        #f97316;
  --c-profit:      #10b981;
  --c-paid:        #8b5cf6;
  --c-debt:        #f59e0b;

  /* Status */
  --green:         #059669;
  --green-bg:      #d1fae5;
  --red:           #dc2626;
  --red-bg:        #fee2e2;
  --amber:         #d97706;
  --amber-bg:      #fef3c7;
  --blue-bg:       #dbeafe;
  --cyan:          #0891b2;
  --cyan-bg:       #cffafe;
  --slate-bg:      #f1f5f9;

  /* Misc */
  --r:         8px;
  --r-lg:      12px;
  --r-xl:      16px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.09);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.15);
  --t:         .16s ease;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 10% 40%, rgba(37,99,235,.22) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 70%, rgba(8,145,178,.14) 0%, transparent 55%),
    #080e1c;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

/* Animated grid background */
.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(59,130,246,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59,130,246,.05) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255,255,255,.97);
  padding: 44px 38px 38px;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 1;
  animation: card-in .4s cubic-bezier(.22,1,.36,1);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.login-logo {
  text-align: center;
  font-size: 42px;
  margin-bottom: -4px;
  filter: drop-shadow(0 4px 12px rgba(59,130,246,.3));
}

.login-card h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  text-align: center;
  letter-spacing: -.4px;
}

.login-card > p {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin-top: -6px;
}

.login-card input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  width: 100%;
  color: var(--text);
  background: var(--surface-2);
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}

.login-card input::placeholder { color: var(--muted-2); }

.login-card button {
  padding: 13px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: var(--r);
  font-size: 15px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--t), transform var(--t), box-shadow var(--t);
  letter-spacing: .01em;
  box-shadow: 0 3px 12px rgba(37,99,235,.4);
}
.login-card button:hover  { opacity: .9; transform: translateY(-1px); box-shadow: 0 5px 18px rgba(37,99,235,.45); }
.login-card button:active { transform: scale(.98); }

.error { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; font-weight: 500; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
  border-right: 1px solid var(--sb-border);
}

/* Subtle noise texture overlay */
.sidebar::after {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: -1;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 4px; }

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
}

.brand-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(59,130,246,.4));
}

.brand-text {
  font-size: 15px;
  font-weight: 800;
  color: #f1f5f9;
  letter-spacing: -.3px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--sb-item);
  margin-top: 2px;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Nav */
.sidebar nav {
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 2px;
  flex: 1;
  border: none;
  background: none;
}

.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  color: var(--sb-item);
  border: none;
  border-radius: var(--r);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background var(--t), color var(--t);
  white-space: nowrap;
  min-height: 38px;
  position: relative;
}

.sidebar nav button:hover {
  background: var(--sb-hover);
  color: #cbd5e1;
}

.sidebar nav button.active {
  background: var(--sb-active-bg);
  color: var(--sb-active);
  font-weight: 600;
}

.sidebar nav button.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--sb-active);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }

.sidebar-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 8px;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}

#userInfo {
  color: #3d5270;
  font-size: 11.5px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  letter-spacing: .02em;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 49;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 12px;
  box-shadow: 0 1px 0 var(--border), var(--shadow-xs);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.sidebar-toggle {
  display: none !important;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--r);
  line-height: 1;
}
.sidebar-toggle:hover { background: var(--border); }

h1, #pageTitle {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  letter-spacing: -.2px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

#status {
  padding: 4px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  letter-spacing: .02em;
}
#status.ok  { color: var(--green); border-color: var(--green-bg); background: var(--green-bg); }
#status.err { color: var(--red);   border-color: var(--red-bg);   background: var(--red-bg);   }

/* ============================================================
   BUTTONS
   ============================================================ */
button {
  padding: 7px 16px;
  border: none;
  border-radius: var(--r);
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  transition: opacity var(--t), transform var(--t), background var(--t), box-shadow var(--t);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.4;
}
button:hover  { opacity: .87; }
button:active { transform: scale(.97); }

button.secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover { background: var(--surface-2); opacity: 1; }

button.danger, .del {
  background: var(--red);
  color: white;
  border: none;
}
button.danger:hover { opacity: .85; }

button.edit {
  background: var(--cyan);
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  color: white;
}

.del {
  padding: 3px 9px;
  font-size: 11.5px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

/* ============================================================
   MAIN
   ============================================================ */
main { padding: 24px 28px; flex: 1; }

.page { display: none; animation: page-in .18s ease; }
.page.active { display: block; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page > h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 20px;
  letter-spacing: -.3px;
}

/* ============================================================
   FORMS
   ============================================================ */
.entry-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  background: var(--surface);
  padding: 18px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

input, select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  outline: none;
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--surface);
}

input::placeholder { color: var(--muted-2); }
select { cursor: pointer; }

/* Submit button */
.entry-form > button,
.entry-form > button[type=submit] {
  grid-column: 1 / -1;
  justify-self: start;
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
  border-radius: var(--r);
}
.entry-form > button:hover { opacity: .9; box-shadow: 0 4px 14px rgba(37,99,235,.4); transform: translateY(-1px); }

/* ============================================================
   FILTERS
   ============================================================ */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.filters input[type=search] {
  flex: 1;
  min-width: 200px;
  padding: 8px 13px;
  background: var(--surface);
}
.filters select { min-width: 150px; }
.filters button { flex-shrink: 0; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; }

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1.5px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th:hover { background: #eef2f8; color: var(--text-2); }
th .sort-arrow { font-size: 10px; color: var(--muted-2); margin-left: 4px; }

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text-2);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f7f9ff; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .02em;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--blue-bg);   color: var(--primary); }
.badge-cyan   { background: var(--cyan-bg);   color: var(--cyan); }
.badge-slate  { background: var(--slate-bg);  color: var(--muted); }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}
.dash-head h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -.3px;
}

.period-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 7px 13px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.period-filter label { color: var(--muted); font-size: 13px; font-weight: 500; }
.period-filter select, .period-filter input { padding: 5px 9px; min-width: 0; }

/* ── KPI Cards — цветные акценты ── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  padding: 20px 20px 17px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
  cursor: default;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Цветная полоска сверху по ID карточки */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, var(--c-revenue), #60a5fa);
}

/* Цветной фон-пятно в углу */
.card::after {
  content: '';
  position: absolute;
  right: -18px; top: -18px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--c-revenue);
  opacity: .06;
  pointer-events: none;
}

/* Индивидуальные цвета через nth-child */
.cards .card:nth-child(1)::before { background: linear-gradient(90deg, var(--c-revenue), #93c5fd); }
.cards .card:nth-child(1)::after  { background: var(--c-revenue); }
.cards .card:nth-child(2)::before { background: linear-gradient(90deg, var(--c-expenses), #fca5a5); }
.cards .card:nth-child(2)::after  { background: var(--c-expenses); }
.cards .card:nth-child(3)::before { background: linear-gradient(90deg, var(--c-fuel), #fdba74); }
.cards .card:nth-child(3)::after  { background: var(--c-fuel); }
.cards .card:nth-child(4)::before { background: linear-gradient(90deg, var(--c-profit), #6ee7b7); }
.cards .card:nth-child(4)::after  { background: var(--c-profit); }
.cards .card:nth-child(5)::before { background: linear-gradient(90deg, var(--c-paid), #c4b5fd); }
.cards .card:nth-child(5)::after  { background: var(--c-paid); }
.cards .card:nth-child(6)::before { background: linear-gradient(90deg, var(--c-debt), #fcd34d); }
.cards .card:nth-child(6)::after  { background: var(--c-debt); }

.card b {
  font-size: 22px;
  font-weight: 800;
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -.5px;
  font-family: 'JetBrains Mono', monospace;
}
.card span { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }

.card.negative::before { background: linear-gradient(90deg, var(--red), #f87171) !important; }
.card.negative b      { color: var(--red); }
.card.positive::before { background: linear-gradient(90deg, var(--green), #34d399) !important; }
.card.positive b      { color: var(--green); }

/* Dash blocks */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.dash-block {
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.dash-block h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  margin-top: 0;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border-soft);
  letter-spacing: .02em;
  text-transform: uppercase;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty {
  color: var(--muted);
  padding: 40px 20px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--border);
  font-size: 14px;
  font-weight: 500;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8,14,28,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--surface);
  padding: 28px 30px;
  border-radius: var(--r-xl);
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,0,0,.06);
  animation: modal-in .2s cubic-bezier(.22,1,.36,1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(12px); }
  to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.modal-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--text);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.2px;
}

#editForm {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
#editForm label { display: block; }
#editForm label span {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
#editForm input, #editForm select { width: 100%; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.menu-grid button {
  justify-content: center;
  padding: 13px 10px;
  font-size: 13px;
  border-radius: var(--r-lg);
  font-weight: 600;
}

/* ============================================================
   MAINTENANCE ALERTS
   ============================================================ */
#maintenanceAlerts .alert-warn {
  background: var(--amber-bg);
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 11px 15px;
  border-radius: var(--r);
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 500;
}

/* ============================================================
   DRIVER SUMMARY
   ============================================================ */
#driverSummary {
  background: var(--primary-soft);
  border: 1px solid var(--blue-bg);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 500;
}

/* ============================================================
   INNER DASH TABLES
   ============================================================ */
#tripProfitBlock table,
#profitabilityTable table,
#fuelEfficiency table,
#carsSummary table,
#debtsSummary table {
  border-radius: var(--r);
  overflow: hidden;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .content-area { margin-left: 0; }
  .sidebar-toggle { display: flex !important; }
}

@media (max-width: 640px) {
  main { padding: 16px; }
  header { padding: 0 16px; }
  .dash-grid { grid-template-columns: 1fr; }
  .menu-grid { grid-template-columns: 1fr; }
  th, td { font-size: 12.5px; padding: 8px 11px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .header-actions button.secondary:nth-child(1) { display: none; }
  .modal-card { padding: 22px 18px; }
  .entry-form { padding: 14px; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .sidebar, header, .filters, .entry-form,
  .dash-head .period-filter, .modal,
  button, .sidebar-overlay { display: none !important; }
  .content-area { margin-left: 0 !important; }
  body { background: white; font-family: sans-serif; }
  main { padding: 0; }
  .table-wrap { box-shadow: none; overflow: visible; border: none; }
  .card { break-inside: avoid; }
}


/* ============================================================
   A11Y / UX TOUCH-UPS
   ============================================================ */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

/* Skeleton placeholder для дашборд-карточек, пока state не загружен */
.cards .card b.skeleton {
  color: var(--muted-2);
  opacity: .6;
}

/* SVG-иконки в sidebar nav (заменили эмодзи) */
.sidebar nav .nav-icon { display: inline-flex; align-items: center; justify-content: center; }
.sidebar nav .nav-icon svg { color: currentColor; opacity: .85; }
.sidebar nav button:hover .nav-icon svg,
.sidebar nav button.active .nav-icon svg { opacity: 1; }

/* SVG-иконки в header/brand */
.sidebar-brand .brand-icon { display: inline-flex; align-items: center; }
.sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
.sidebar-toggle svg { display: block; }

/* Login form SVG-logo (вместо эмодзи) */
.login-logo svg { color: var(--primary); display: block; margin: 0 auto; }

/* Кнопка focus-стиль (для клавиатурной доступности) */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Disable-стиль для кнопок логина и пагинации */
button:disabled { opacity: .55; cursor: not-allowed; }

/* ============================================================
   PACK D — Mobile responsive tables + UX helpers
   ============================================================ */

/* Bulk checkboxes */
.bulk-check, .bulk-check-all { width: 16px; height: 16px; cursor: pointer; }

/* Mobile: таблицы → карточки на узких экранах */
@media (max-width: 640px) {
  .table-wrap table thead { display: none; }
  .table-wrap table tr {
    display: block;
    margin-bottom: 10px;
    background: var(--surface, #fff);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border, #e2e8f0);
  }
  .table-wrap table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none !important;
    text-align: right;
  }
  .table-wrap table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted, #64748b);
    text-align: left;
    margin-right: 8px;
  }
}

/* CSV import button — добавляем в меню если нужно */
#csvImportModal pre { background: #f8fafc; padding: 8px; border-radius: 6px; }

/* Gantt heatmap improvements */
#ganttBody table th { user-select: none; }
#ganttBody table td:hover { outline: 2px solid #2563eb; outline-offset: -2px; }

/* ============================================================
   PACK G — Dark mode auto через prefers-color-scheme
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0f172a;
    --surface:       #1e293b;
    --surface-2:     #283448;
    --border:        #334155;
    --border-soft:   #243046;
    --text:          #e2e8f0;
    --text-2:        #cbd5e1;
    --muted:         #94a3b8;
    --muted-2:       #64748b;
  }
  body { background: var(--bg); color: var(--text); }
  .card, .dash-block, .modal-card, #cmdkModal > div,
  .login-card, .table-wrap table tr,
  #onbOverlay > div:last-child { background: var(--surface) !important; color: var(--text) !important; }
  .dash-block h3 { color: var(--text-2) !important; }
  th { background: var(--surface-2) !important; color: var(--text-2) !important; }
  td { border-color: var(--border-soft) !important; }
  input, select, textarea { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
  .skeleton { color: var(--muted) !important; }
  /* skeleton placeholder для дашборд карточек */
  .cards .card b.skeleton { color: var(--muted-2) !important; }
  /* Сохраняем sidebar в "ночном" виде — он и так тёмный */
}

/* Drag-n-drop overlay highlight */
body.dnd-over::after {
  content: 'Перетащи CSV сюда';
  position: fixed; inset: 0;
  background: rgba(37, 99, 235, .25);
  border: 4px dashed #2563eb;
  z-index: 99990;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #1e40af;
  pointer-events: none;
}
