/* ================================================================
   Windows 11 Fluent Design — Mica + Acrylic dark theme
   Palette: Win11 dark mode + #0078D4 accent
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700&display=swap');

:root {
  /* Win11 Dark Mica */
  --mica-bg:        #1c1c1c;
  --mica-tint:      rgba(28, 28, 45, 0.95);

  /* Acrylic layers */
  --acrylic-nav:    rgba(32, 32, 40, 0.88);
  --acrylic-card:   rgba(255, 255, 255, 0.055);
  --acrylic-card-hover: rgba(255, 255, 255, 0.09);
  --acrylic-input:  rgba(255, 255, 255, 0.07);

  /* Win11 accent */
  --accent:         #60CDFF;
  --accent-dim:     rgba(96, 205, 255, 0.18);
  --accent-press:   #4ab8e8;

  /* Text */
  --text-primary:   rgba(255, 255, 255, 0.95);
  --text-secondary: rgba(255, 255, 255, 0.62);
  --text-tertiary:  rgba(255, 255, 255, 0.36);

  /* Borders */
  --border:         rgba(255, 255, 255, 0.10);
  --border-strong:  rgba(255, 255, 255, 0.18);

  /* Semantic colours */
  --green:   #6CCB5F;
  --red:     #FC5C5C;
  --orange:  #FFAB45;
  --purple:  #C787F8;

  /* Geometry */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  /* Shadows */
  --shadow-card:  0 4px 24px rgba(0,0,0,.45), 0 1px 4px rgba(0,0,0,.3);
  --shadow-nav:   4px 0  32px rgba(0,0,0,.5);

  --sidebar-w: 220px;
  --font: 'Nunito', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
}

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

html {
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%,  rgba(0,120,212,.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%,  rgba(96,205,255,.10) 0%, transparent 55%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(45,45,70,.6) 0%, transparent 100%),
    var(--mica-bg);
  background-attachment: fixed;
  min-height: 100%;
}

body {
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ================================================================
   SIDEBAR — Acrylic NavigationView
   ================================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--acrylic-nav);
  backdrop-filter: blur(40px) saturate(160%);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-nav);
  padding: 16px 8px 24px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 10px 12px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  letter-spacing: .01em;
}
.sidebar .logo .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #0078D4 0%, #60CDFF 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(0,120,212,.45);
}

.sidebar ul { list-style: none; flex: 1; }

.sidebar ul li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  position: relative;
}

.sidebar ul li a:hover {
  background: rgba(255,255,255,.07);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar ul li a.active,
.sidebar ul li a:focus {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Active pill indicator */
.sidebar ul li a.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

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

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: auto;
}

/* ================================================================
   CONTENT
   ================================================================ */
.content {
  flex: 1;
  padding: 28px 32px 48px;
  min-width: 0;
}

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

/* ================================================================
   DATE FILTER — Win11 CommandBar style
   ================================================================ */
.date-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--acrylic-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 14px;
  flex-wrap: wrap;
}

.date-filter label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  white-space: nowrap;
}

.date-filter input[type="date"] {
  background: var(--acrylic-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color-scheme: dark;
  transition: border-color .15s;
}
.date-filter input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* ================================================================
   KPI CARDS — Acrylic tiles
   ================================================================ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--acrylic-card);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
  transition: background .15s, transform .1s;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.04) 0%, transparent 60%);
  pointer-events: none;
  border-radius: inherit;
}
.kpi-card:hover {
  background: var(--acrylic-card-hover);
  transform: translateY(-1px);
}

.kpi-card.cafe     { border-top: 2px solid var(--orange); }
.kpi-card.culinary { border-top: 2px solid var(--accent); }
.kpi-card.checks   { border-top: 2px solid var(--green);  }
.kpi-card.yandex   { border-top: 2px solid var(--purple); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.90);
  text-transform: uppercase;
  letter-spacing: .07em;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  line-height: 1.1;
}

/* ================================================================
   CHARTS GRID
   ================================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--acrylic-card);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 12px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.chart-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
  pointer-events: none;
}

.chart-card.wide { grid-column: 1 / -1; }

.chart-card h3 {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.90);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 14px;
}

/* ================================================================
   TABLE — Fluent DataGrid style
   ================================================================ */
.table-card {
  background: var(--acrylic-card);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.table-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
  pointer-events: none;
}

.table-card h3 {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.90);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 14px;
}

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; white-space: nowrap; }

th, td {
  padding: 9px 14px;
  text-align: right;
}
th:first-child, td:first-child { text-align: left; }

th {
  background: rgba(255,255,255,.04);
  color: rgba(255, 255, 255, 0.90);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--border-strong);
  position: sticky;
  top: 0;
}

td { border-bottom: 1px solid rgba(255,255,255,.04); }

tbody tr { transition: background .1s; }
tbody tr:hover { background: rgba(255,255,255,.05); }
tbody tr:last-child td { border-bottom: none; }

tfoot td {
  font-weight: 700;
  background: rgba(255,255,255,.05);
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
  color: var(--text-primary);
}

td.total       { color: var(--accent);  font-weight: 600; }
td.grand-total { color: var(--green);   font-weight: 700; }
td.yandex-col  { color: var(--purple);  font-weight: 600; }

/* ================================================================
   FORM CARD
   ================================================================ */
.form-card {
  background: var(--acrylic-card);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  max-width: 460px;
  box-shadow: var(--shadow-card);
}

.form-section-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-row input,
.form-row select {
  background: var(--acrylic-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  color-scheme: dark;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.form-row select option { background: #2c2c3c; }

.btn-primary {
  background: linear-gradient(135deg, #0078D4 0%, #1e90ff 100%);
  color: #fff;
  border: none;
  padding: 10px 26px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  box-shadow: 0 2px 12px rgba(0,120,212,.4);
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
.btn-primary:hover {
  opacity: .9;
  box-shadow: 0 4px 20px rgba(0,120,212,.55);
}
.btn-primary:active { transform: scale(.98); opacity: .8; }

.success-msg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
  margin-left: 12px;
  font-size: 13px;
  font-weight: 600;
}

/* ================================================================
   MISC
   ================================================================ */
.loading {
  color: var(--text-tertiary);
  padding: 60px 0;
  text-align: center;
  font-size: 15px;
}

/* Win11 scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.18);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.32); }

/* ================================================================
   MOBILE BOTTOM NAV (скрыт на десктопе)
   ================================================================ */
.bottom-nav {
  display: none;
}

/* ================================================================
   TABLET  ≤ 900px
   ================================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 180px; }
  .content { padding: 20px 18px 40px; }
  .kpi-value { font-size: 22px; }
}

/* ================================================================
   MOBILE  ≤ 640px
   ================================================================ */
@media (max-width: 640px) {

  /* Скрываем боковую панель, показываем нижний таббар */
  .sidebar { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(60px + env(safe-area-inset-bottom));
    background: var(--acrylic-nav);
    backdrop-filter: blur(30px) saturate(160%);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    border-top: 1px solid var(--border);
    z-index: 100;
    justify-content: space-around;
    align-items: stretch;
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .05em;
    transition: color .15s, background .15s;
    border-radius: 0;
    padding: 6px 4px 10px;
  }

  .bottom-nav a .bn-icon {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .bottom-nav a.active,
  .bottom-nav a:hover {
    color: var(--accent);
    text-decoration: none;
  }

  .bottom-nav a.active .bn-icon {
    background: var(--accent-dim);
  }

  /* Отступ снизу чтобы контент не перекрывался таббаром + safe-area */
  .content {
    padding: 16px 14px calc(76px + env(safe-area-inset-bottom));
  }

  /* Шапка страницы — вертикально */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-header h1 { font-size: 20px; }

  .date-filter {
    width: 100%;
    padding: 8px 12px;
    gap: 6px;
  }

  .date-filter input[type="date"] {
    flex: 1;
    min-width: 0;
  }

  /* KPI — 2 колонки */
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .kpi-card { padding: 14px 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 10px; }

  /* Графики — всегда одна колонка */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .chart-card.wide { grid-column: 1; }

  /* Таблица — горизонтальный скролл (уже есть), уменьшаем шрифт */
  .table-card { padding: 12px; }
  th, td { padding: 7px 10px; font-size: 12px; }

  /* Форма */
  .form-card {
    padding: 18px 16px;
    border-radius: var(--radius-lg);
  }

  .btn-primary {
    width: 100%;
    padding: 13px;
    font-size: 15px;
  }

  /* Summary — спарклайны */
  .sparkline-row { grid-template-columns: 1fr; }
  .spark-card    { padding: 12px 14px; }
}

/* ================================================================
   Section title
   ================================================================ */
.section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
  margin-top: 0.5rem;
}

/* ================================================================
   KPI delta badge
   ================================================================ */
.kpi-delta {
  display: block;
  font-size: 11px;
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 20px;
  width: fit-content;
}
.delta-up   { background: rgba(74,222,128,0.15); color: #4ade80; }
.delta-down { background: rgba(239,68,68,0.15);  color: #ef4444; }

/* ================================================================
   Sparkline cards (Summary page)
   ================================================================ */
.sparkline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.spark-card {
  background: var(--acrylic-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  backdrop-filter: blur(10px);
}

.spark-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.sparkline { height: 60px; }

.spark-dates {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}
.spark-dates span {
  font-size: 10px;
  color: var(--text-tertiary);
}
