/* ═══════════════════════════════════════════════════════════════════════
   ТОС MVP v2.0 — Modern Design System
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette — cool blue-grey industrial */
  --bg:          #F4F6F9;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFB;

  --border:      #E2E8F0;
  --border-strong: #CBD5E1;

  --text:        #1E293B;
  --text-secondary: #475569;
  --text-muted:  #94A3B8;
  --text-hint:   #CBD5E1;

  --accent:      #3B82F6;
  --accent-hover:#2563EB;
  --accent-bg:   #EFF6FF;
  --accent-text: #1D4ED8;

  --green:       #16A34A;
  --green-bg:    #F0FDF4;
  --green-text:  #15803D;
  --green-light: #BBF7D0;

  --amber:       #D97706;
  --amber-bg:    #FFFBEB;
  --amber-text:  #B45309;
  --amber-light: #FDE68A;

  --red:         #DC2626;
  --red-bg:      #FEF2F2;
  --red-text:    #B91C1C;
  --red-light:   #FECACA;

  --purple:      #7C3AED;
  --purple-bg:   #F5F3FF;
  --purple-text: #6D28D9;

  --grey-bg:     #F1F5F9;
  --grey-text:   #64748B;

  --radius:      10px;
  --radius-lg:   14px;
  --radius-sm:   6px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.04);
  --shadow:      0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.08);
  --shadow-xl:   0 20px 50px rgba(0,0,0,0.12);

  --sidebar-w:   250px;
  --topbar-h:    56px;

  --transition:  0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-icon { flex-shrink: 0; }
.sidebar-logo h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.sidebar-logo p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.nav {
  padding: 8px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  text-decoration: none;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}
.nav-item svg { flex-shrink: 0; opacity: 0.6; transition: opacity var(--transition); }
.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; stroke: var(--accent); }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-time { font-size: 11px; color: var(--text-muted); }
.sidebar-version { font-size: 10px; color: var(--text-hint); margin-top: 3px; letter-spacing: 0.02em; }

/* ── Main Area ──────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h2 {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.01em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-time { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ── Mobile Header (hidden on desktop) ──────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 90;
}
.mobile-header h2 { font-size: 15px; font-weight: 700; flex: 1; }
.burger {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px; background: none; border: none; cursor: pointer;
}
.burger span {
  width: 18px; height: 2px; background: var(--text); border-radius: 1px;
  transition: var(--transition);
}

/* ── Page Content ───────────────────────────────────────────────────── */
.page-content {
  padding: 24px 28px 40px;
  flex: 1;
}
.page { display: none; animation: fadeIn 0.25s ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── KPI Cards ──────────────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card-label { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.card-val { font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.card-sub { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.val-red   { color: var(--red); }
.val-green { color: var(--green); }
.val-amber { color: var(--amber); }
.val-blue  { color: var(--accent); }

/* ── Section (panel) ────────────────────────────────────────────────── */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.section-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}
.section-body { padding: 14px 18px; }

/* ── Table ──────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.b-green  { background: var(--green-bg);  color: var(--green-text); }
.b-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.b-red    { background: var(--red-bg);    color: var(--red-text); }
.b-blue   { background: var(--accent-bg); color: var(--accent-text); }
.b-purple { background: var(--purple-bg); color: var(--purple-text); }
.b-gray   { background: var(--grey-bg);   color: var(--grey-text); }

/* ── Status badges ──────────────────────────────────────────────────── */
.s-draft   { background: var(--grey-bg);   color: var(--grey-text); }
.s-confirm { background: var(--accent-bg); color: var(--accent-text); }
.s-release { background: var(--purple-bg); color: var(--purple-text); }
.s-prod    { background: var(--amber-bg);  color: var(--amber-text); }
.s-shipped { background: var(--green-bg);  color: var(--green-text); }
.s-closed  { background: var(--grey-bg);   color: var(--grey-text); }

/* ── Traffic light dots ─────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface);
}
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }

/* ── Progress bar ───────────────────────────────────────────────────── */
.bar-bg {
  height: 6px;
  background: var(--grey-bg);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-secondary);
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-muted); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-danger { color: var(--red); border-color: var(--red-light); background: var(--red-bg); }
.btn-danger:hover { background: var(--red-light); border-color: var(--red); }

/* ── Toolbar ────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.spacer { flex: 1; }
.hint-text { font-size: 12px; color: var(--text-muted); font-style: italic; }
.filter-group { display: flex; gap: 4px; }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 6px;
  font-weight: 500;
}
.alert-row:last-child { margin-bottom: 0; }
.alert-red   { background: var(--red-bg);   color: var(--red-text);   border-left: 3px solid var(--red); }
.alert-amber { background: var(--amber-bg); color: var(--amber-text); border-left: 3px solid var(--amber); }

/* ── Resource load bars ─────────────────────────────────────────────── */
.resource-row {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  margin-bottom: 12px;
}
.resource-row:last-child { margin-bottom: 0; }
.resource-name { width: 170px; flex-shrink: 0; font-weight: 500; }

/* ── Grid ───────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  z-index: 1000;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px 28px;
  width: 480px;
  max-width: 92vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 18px; }
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ── Form ───────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row.full { grid-column: span 2; }
label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.input-styled, .select-styled {
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: all var(--transition);
  outline: none;
}
.input-styled:focus, .select-styled:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* ── Toast ──────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  box-shadow: var(--shadow-xl);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }
  .main { margin-left: 0; }
  .mobile-header { display: flex; }
  .topbar { display: none; }
  .page-content { padding: 68px 14px 32px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 12px 14px; }
  .card-val { font-size: 20px; }
  .toolbar { gap: 6px; }
  .filter-group { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-row.full { grid-column: span 1; }
}