:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --sidebar: #111827;
  --sidebar-ink: #d1d5db;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 13px; margin: 6px 0; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }

/* ---------- login (визуал Travel Connect) ---------- */
#login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
  padding: 20px;
}
.login-card2 {
  display: flex; width: 100%; max-width: 56rem;
  border-radius: 1rem; overflow: hidden; background: #fff;
  box-shadow: 0 25px 60px -15px rgba(30, 58, 138, .25);
  animation: lcpop .5s ease-out both;
}
.lc-left {
  display: none; position: relative; width: 50%; height: 600px;
  border-right: 1px solid #f3f4f6;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff); overflow: hidden;
}
.lc-left canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.lc-overlay {
  position: absolute; inset: 0; z-index: 10; padding: 2rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.lc-logo {
  width: 3rem; height: 3rem; border-radius: 9999px; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 20px -5px rgba(59, 130, 246, .4);
  margin-bottom: 1.5rem;
}
.lc-logo svg { width: 1.5rem; height: 1.5rem; }
.lc-title {
  margin: 0 0 .5rem; font-size: 1.875rem; line-height: 2.25rem; font-weight: 700;
  background: linear-gradient(90deg, #2563eb, #4f46e5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lc-sub { margin: 0; font-size: .875rem; color: #4b5563; max-width: 20rem; }
.lc-right {
  width: 100%; padding: 2rem 1.5rem;
  display: flex; flex-direction: column; justify-content: center;
}
.lc-form h1 { margin: 0 0 .25rem; font-size: 1.875rem; font-weight: 700; color: #1f2937; }
.lc-lead { margin: 0 0 2rem; color: #6b7280; }
.lc-form label { display: block; font-size: .875rem; font-weight: 500; color: #374151; margin-bottom: 1.25rem; }
.lc-form label > span { color: #3b82f6; }
.lc-form input {
  width: 100%; height: 2.5rem; margin-top: .25rem; padding: .5rem .75rem;
  border: 1px solid #e5e7eb; border-radius: .5rem; background: #f9fafb;
  color: #1f2937; font-size: .875rem; font-family: inherit;
}
.lc-form input::placeholder { color: #9ca3af; }
.lc-form input:focus {
  outline: none; border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); background: #fff;
}
.lc-pass { position: relative; }
.lc-pass input { padding-right: 2.5rem; }
.lc-pass button {
  position: absolute; right: 0; top: .25rem; bottom: 0;
  display: flex; align-items: center; padding: 0 .75rem;
  background: none; border: none; color: #6b7280; cursor: pointer;
}
.lc-pass button:hover { color: #374151; }
.lc-pass button svg { width: 1.125rem; height: 1.125rem; }
.lc-submit {
  position: relative; overflow: hidden; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .625rem 1rem; margin-top: .5rem; border: none; border-radius: .5rem;
  background: linear-gradient(90deg, #3b82f6, #4f46e5); color: #fff;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: transform .15s, box-shadow .3s, filter .3s;
}
.lc-submit span { display: flex; align-items: center; justify-content: center; gap: .5rem; }
.lc-submit svg { width: 1rem; height: 1rem; }
.lc-submit:hover { transform: scale(1.01); box-shadow: 0 10px 25px -5px rgba(59, 130, 246, .45); filter: brightness(1.05); }
.lc-submit:active { transform: scale(.98); }
.lc-submit .shine {
  position: absolute; top: 0; bottom: 0; left: -20%; width: 5rem; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .3), transparent);
  filter: blur(8px);
}
.lc-submit:hover .shine { animation: lcshine 1s ease-in-out; }
.lc-hint { margin: 1.5rem 0 0; font-size: .75rem; color: #9ca3af; line-height: 1.5; }

@keyframes lcpop { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
@keyframes lcrise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes lcdrop { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }
@keyframes lcshine { from { left: -20%; } to { left: 120%; } }
.lc-overlay .a1 { animation: lcdrop .5s .2s ease-out both; }
.lc-overlay .a2 { animation: lcdrop .5s .3s ease-out both; }
.lc-overlay .a3 { animation: lcdrop .5s .4s ease-out both; }
.lc-form.a4 { animation: lcrise .5s .1s ease-out both; }

@media (min-width: 768px) {
  .lc-left { display: block; }
  .login-card2 { min-height: 600px; }
  .lc-right { width: 50%; padding: 2.5rem; }
}

/* ---------- layout ---------- */
#app-view { display: flex; min-height: 100vh; }
#sidebar {
  width: 232px; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
}
.logo { padding: 18px 18px 14px; font-weight: 800; font-size: 18px; color: #fff; }
.logo span { font-weight: 500; opacity: .7; }
#nav { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px; overflow-y: auto; }
#nav a {
  color: var(--sidebar-ink); text-decoration: none; padding: 9px 12px;
  border-radius: 8px; font-size: 14px;
}
#nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
#nav a.active { background: var(--accent); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { font-size: 13px; margin-bottom: 10px; }
.user-info .name { color: #fff; font-weight: 600; display: block; }
.user-info .role { opacity: .7; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
#menu-btn { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.period-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.period-label input {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  background: #fff;
}
#content { padding: 20px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- components ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .value.neg { color: var(--bad); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 14px; cursor: pointer; color: var(--ink); text-decoration: none;
}
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--bad); border-color: #fecaca; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; margin-top: 10px; }
.btn.ghost { border-color: transparent; background: transparent; color: inherit; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.gray { background: #f3f4f6; color: #4b5563; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
tbody tr:hover { background: #f9fafb; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.total-row td { font-weight: 700; border-top: 2px solid var(--ink); background: #f9fafb; }
.table-wrap { overflow-x: auto; }

input[type="text"], input[type="number"], input[type="date"], input[type="month"],
input[type="password"], select, textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 60px; resize: vertical; }
label.fld { display: block; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
label.fld > input, label.fld > select, label.fld > textarea { width: 100%; margin-top: 4px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.filters label { font-size: 13px; color: var(--muted); }
.filters select, .filters input { margin-top: 3px; }

.warn-item {
  display: flex; gap: 10px; padding: 9px 12px; border-radius: 8px; margin-bottom: 6px;
  background: #fffbeb; border: 1px solid #fde68a; font-size: 14px;
}
.warn-item.bad { background: #fef2f2; border-color: #fecaca; }
.warn-item .wtype { font-weight: 700; flex-shrink: 0; min-width: 90px; }

/* работа со временем */
.wt-grid { overflow: auto; max-height: 72vh; }
.wt-grid table { border-collapse: separate; border-spacing: 0; }
.wt-grid th.day { padding: 4px 3px; text-align: center; font-size: 11px; min-width: 44px; }
.wt-grid th.first { position: sticky; left: 0; z-index: 3; background: var(--panel); min-width: 200px; }
.wt-grid td.first { position: sticky; left: 0; z-index: 2; background: var(--panel); border-right: 1px solid var(--line); }
.wt-grid th { position: sticky; top: 0; background: #f9fafb; z-index: 1; }
.wt-grid td.num, .wt-grid td { padding: 0; text-align: center; }
.wt-grid td input {
  width: 52px; padding: 7px 4px; border: none; text-align: center; font-size: 14px;
  background: transparent; border-radius: 0;
}
.wt-grid td input:hover { background: var(--accent-soft); }
.wt-grid td input:focus { background: #fff; outline: 2px solid var(--accent); }
.wt-grid tr.total-row td { text-align: center; }
.saved-flash { animation: flash 1.2s; border-radius: 6px; }
@keyframes flash { 0% { background: #bbf7d0; } 100% { background: transparent; } }

/* модалка */
.modal-back {
  position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 20px; width: 100%;
  max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.3);
}
.modal h3 { font-size: 17px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal .close-x { float: right; border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); }

/* поиск-выбор */
.search-select { position: relative; }
.search-select input { width: 100%; }
.search-select .dropdown {
  position: absolute; top: 100%; left: 0; right: 0; background: #fff; z-index: 50;
  border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow-y: auto;
  box-shadow: var(--shadow);
}
.search-select .dropdown div { padding: 8px 10px; cursor: pointer; font-size: 14px; }
.search-select .dropdown div:hover, .search-select .dropdown div.sel { background: var(--accent-soft); }

/* печать */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0 0 14px; }
  body { background: #fff; font-size: 12px; }
  th, td { padding: 4px 6px; font-size: 11px; }
  h1 { font-size: 16px; }
}

/* мобильные */
@media (max-width: 860px) {
  #sidebar {
    position: fixed; z-index: 60; transform: translateX(-100%);
    transition: transform .2s; height: 100vh;
  }
  #sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
  #menu-btn { display: inline-flex; }
  #content { padding: 12px; }
  .wt-grid th.first { min-width: 140px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr 1fr; }
}

/* toast */
#toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: tin .2s;
}
.toast.err { background: var(--bad); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
