@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --accent: #997d75;
  --accent-soft: #e3b197;
  --accent-contrast: #ffffff;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f6f3f1;
  --border: rgba(0, 0, 0, 0.1);
  --text: #000000;
  --text-muted: rgba(0, 0, 0, 0.5);

  --sidebar-width: 212px;
  --radius: 10px;
}

:root[data-theme='dark'] {
  --accent: #e3b197;
  --accent-soft: #997d75;
  --accent-contrast: #000000;

  --bg: #000000;
  --surface: #0c0c0c;
  --surface-muted: #161616;
  --border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; font-weight: 600; letter-spacing: -0.01em; }

a { color: inherit; }

/* ---------- Логин ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.login-logo img { height: 48px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width: 320px;
}

.login-card h1 { font-size: 19px; margin: 0 0 22px; font-weight: 600; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.01em; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--accent); }

button.primary {
  width: 100%;
  padding: 11px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
button.primary:hover { opacity: 0.88; }
button.primary:active { opacity: 0.8; }

.error-text { color: var(--text); font-size: 13px; margin-top: 12px; min-height: 16px; }
.success-text { color: var(--text-muted); font-size: 13px; margin-top: 12px; min-height: 16px; }

.theme-toggle-floating {
  position: fixed; top: 20px; right: 20px;
  background: none; border: 1px solid var(--border); border-radius: 24px;
  padding: 7px 16px; font-size: 12px; cursor: pointer; color: var(--text-muted);
  font-family: inherit;
}
.theme-toggle-floating:hover { color: var(--text); border-color: var(--text); }

/* ---------- Каркас приложения ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo { padding: 2px 6px 28px; }
.sidebar-logo img { height: 28px; display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 7px;
  border: none; background: none; cursor: pointer;
  font-size: 13.5px; color: var(--text-muted); text-align: left;
  font-family: inherit;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { color: var(--text); }
.nav-item.active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface-muted);
}

.sidebar-footer { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.main-content { flex: 1; min-width: 0; padding: 28px 32px 60px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 14px; margin-bottom: 26px;
}
.topbar h1 { font-size: 21px; margin: 0; font-weight: 600; }

.view { display: none; }
.view.active { display: block; }

/* ---------- Выбор периода ---------- */

.period-picker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; position: relative; }
.period-pill {
  border: 1px solid var(--border); background: none; border-radius: 20px;
  padding: 6px 14px; font-size: 12.5px; cursor: pointer; color: var(--text-muted);
  font-family: inherit;
}
.period-pill:hover { color: var(--text); }
.period-pill.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.custom-range-popover {
  display: none;
  position: absolute; top: 42px; right: 0; z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; gap: 10px; flex-direction: column;
}
.custom-range-popover.open { display: flex; }
.custom-range-popover .row { display: flex; gap: 8px; align-items: center; }
.custom-range-popover input[type="date"] {
  border: 1px solid var(--border); border-radius: 7px; padding: 7px 8px; font-size: 13px;
  background: var(--bg); color: var(--text); font-family: inherit;
}

/* ---------- KPI ---------- */

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; margin-bottom: 24px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kpi-card { background: var(--surface); padding: 18px 18px 16px; }
.kpi-card .label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card .value-row { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.kpi-card .value { font-size: 23px; font-weight: 600; letter-spacing: -0.01em; }
.kpi-trend { font-size: 12px; font-weight: 500; }
.kpi-trend.up { color: var(--text); }
.kpi-trend.down { color: var(--text-muted); }
.kpi-trend.flat { color: var(--text-muted); }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 7px; }

/* ---------- Карточки / таблицы ---------- */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card h2 { font-size: 15px; margin: 0; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-muted); }
tbody tr.is-clickable { cursor: pointer; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
  background: var(--bg); color: var(--text); font-family: inherit;
}

.btn-outline {
  border: 1px solid var(--border); background: none; border-radius: 7px;
  padding: 7px 13px; cursor: pointer; font-size: 13px; color: var(--text); font-family: inherit;
}
.btn-outline:hover { border-color: var(--text); }

.pagination { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.pagination button {
  border: 1px solid var(--border); background: none; border-radius: 6px;
  padding: 5px 11px; cursor: pointer; color: var(--text); font-family: inherit;
}
.pagination button:disabled { opacity: 0.35; cursor: default; }

.status-row { display: flex; align-items: center; gap: 7px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.status-dot.is-paid { background: var(--accent); }
.status-dot.is-cancelled { background: none; border: 1px solid var(--text-muted); }
.status-row.is-cancelled { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--border); }

.low-stock { font-weight: 600; }
.out-stock { font-weight: 600; color: var(--text-muted); }
.out-stock::before { content: '— '; }

/* ---------- Настройки ---------- */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

.theme-switch-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }

/* ---------- Прочее ---------- */

.empty-state { color: var(--text-muted); font-size: 13px; padding: 24px 0; text-align: center; }

/* ---------- Модалка заказа ---------- */

.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  align-items: flex-start; justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: calc(100vh - 96px); overflow-y: auto;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-close {
  border: none; background: none; font-size: 15px; cursor: pointer; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 50%;
}
.modal-close:hover { color: var(--text); background: var(--surface-muted); }

.modal-body { padding: 22px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 20px; }
.detail-item .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px; }
.detail-item .value { font-size: 13.5px; }
.detail-item.full { grid-column: 1 / -1; }

.modal-section-title { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 22px 0 10px; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 14px; gap: 10px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-logo { padding: 0 10px 0 0; }
  .sidebar-nav { flex-direction: row; flex: none; }
  .sidebar-footer { flex-direction: row; margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; }
  .main-content { padding: 18px; }
}
