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

:root {
  --bg:   #f0f0f0;
  --sd:   #cbcbcb;
  --sl:   #ffffff;
  --text: #2a2a2a;
  --muted:#9a9a9a;
  --green: #1a5c42;
  --blue:  #2c3e9e;
  --rose:  #7c1d3f;
  --amber: #92400e;
  --sidebar-w: 68px;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── SHADOW HELPERS ── */
.raised    { box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl); }
.raised-sm { box-shadow: 4px 4px 9px  var(--sd), -4px -4px 9px  var(--sl); }
.inset     { box-shadow: inset 4px 4px 9px var(--sd), inset -4px -4px 9px var(--sl); }

/* ── FROSTED GLASS CHIPS ── */
.fg {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  white-space: nowrap;
}
.fg-green {
  background: rgba(26,92,66,0.09); border: 1px solid rgba(26,92,66,0.2); color: #1a5c42;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 2px 10px rgba(26,92,66,0.12), inset 0 0 14px rgba(26,92,66,0.05);
}
.fg-blue {
  background: rgba(44,62,158,0.09); border: 1px solid rgba(44,62,158,0.2); color: #2c3e9e;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 2px 10px rgba(44,62,158,0.12), inset 0 0 14px rgba(44,62,158,0.05);
}
.fg-rose {
  background: rgba(124,29,63,0.09); border: 1px solid rgba(124,29,63,0.2); color: #7c1d3f;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 2px 10px rgba(124,29,63,0.12), inset 0 0 14px rgba(124,29,63,0.05);
}
.fg-amber {
  background: rgba(146,64,14,0.09); border: 1px solid rgba(146,64,14,0.2); color: #92400e;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 2px 10px rgba(146,64,14,0.12), inset 0 0 14px rgba(146,64,14,0.05);
}
.fg-dot { width: 4px; height: 4px; border-radius: 50%; }
.fg-green .fg-dot { background: #1a5c42; }
.fg-blue  .fg-dot { background: #2c3e9e; }
.fg-rose  .fg-dot { background: #7c1d3f; }
.fg-amber .fg-dot { background: #92400e; }

/* ── FROSTED BADGES (margin %) ── */
.fb {
  display: inline-block; padding: 4px 9px; border-radius: 8px;
  font-size: 10.5px; font-weight: 700;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.fb-green {
  background: rgba(26,92,66,0.09); border: 1px solid rgba(26,92,66,0.18); color: #1a5c42;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 0 10px rgba(26,92,66,0.1);
}
.fb-blue {
  background: rgba(44,62,158,0.09); border: 1px solid rgba(44,62,158,0.18); color: #2c3e9e;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 0 10px rgba(44,62,158,0.1);
}
.fb-rose {
  background: rgba(124,29,63,0.09); border: 1px solid rgba(124,29,63,0.18); color: #7c1d3f;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 0 10px rgba(124,29,63,0.1);
}

/* ── LOGIN ── */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--bg); border-radius: 20px; padding: 44px 40px; width: 380px;
  box-shadow: 10px 10px 24px var(--sd), -10px -10px 24px var(--sl);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.login-card .field { margin-bottom: 18px; }
.login-card label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.login-card input {
  width: 100%; padding: 11px 14px; border: none; border-radius: 10px;
  font-size: 14px; outline: none; font-family: inherit;
  background: var(--bg); color: var(--text);
  box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl);
  transition: box-shadow .2s;
}
.login-card input:focus { box-shadow: inset 4px 4px 9px var(--sd), inset -4px -4px 9px var(--sl); }
.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
  background: var(--bg); color: var(--blue);
  box-shadow: 5px 5px 12px var(--sd), -5px -5px 12px var(--sl);
  transition: box-shadow .15s;
}
.btn-primary:active { box-shadow: inset 4px 4px 9px var(--sd), inset -4px -4px 9px var(--sl); }
.login-error { color: var(--rose); font-size: 13px; margin-top: 10px; text-align: center; min-height: 20px; }

/* ── LAYOUT ── */
#app { display: block; min-height: 100vh; width: 100%; }
.app-layout { display: flex; min-height: 100vh; width: 100%; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 0; gap: 6px; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
}

.sidebar-logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--text); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
  box-shadow: 5px 5px 10px var(--sd), -5px -5px 10px var(--sl);
}

/* hide old wide sidebar elements */
.sidebar-logo h2, .sidebar-logo p, .sidebar-nav { display: none; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.user-info { display: none; }
#sidebar-username, #sidebar-role { display: none; }

.s-btn {
  width: 44px; height: 44px; border-radius: 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted);
  box-shadow: 4px 4px 9px var(--sd), -4px -4px 9px var(--sl);
  position: relative; transition: color .2s, box-shadow .2s;
  border: none;
}
.s-btn:hover { color: var(--text); }
.s-btn.active {
  color: var(--blue);
  box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl);
}

.s-tip {
  position: absolute; left: 56px;
  background: var(--text); color: #fff;
  font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 7px;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .15s; z-index: 99;
}
.s-btn:hover .s-tip { opacity: 1; }

.s-sep {
  width: 20px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--sd), transparent);
  margin: 6px 0;
}

.btn-logout {
  width: 44px; height: 44px; border-radius: 12px; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); border: none;
  box-shadow: 4px 4px 9px var(--sd), -4px -4px 9px var(--sl);
  font-size: 15px; position: relative; transition: color .2s;
}
.btn-logout:hover { color: var(--rose); }
.btn-logout::after {
  content: 'Выйти';
  position: absolute; left: 56px;
  background: var(--text); color: #fff;
  font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 7px;
  white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity .15s; z-index: 99;
}
.btn-logout:hover::after { opacity: 1; }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; }

/* ── TOPBAR ── */
.topbar {
  border-radius: 16px; background: var(--bg); margin: 16px 20px 0;
  padding: 14px 22px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
  position: sticky; top: 16px; z-index: 100;
}
.topbar h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.sync-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted); padding: 5px 12px;
  background: var(--bg); border-radius: 10px;
  box-shadow: inset 2px 2px 5px var(--sd), inset -2px -2px 5px var(--sl);
}
.sync-dot { width: 6px; height: 6px; border-radius: 50%; background: #1a5c42; }

.content-body { padding: 16px 20px 24px; flex: 1; }

/* ── VIEWS ── */
.view { display: none; }
.view.active { display: block; }

/* ── PERIOD TABS ── */
.period-tabs {
  display: flex; padding: 4px; border-radius: 11px; gap: 2px;
  box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl);
}
.period-tab {
  padding: 6px 14px; border-radius: 8px; border: none; background: none;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: all .18s; font-family: inherit;
}
.period-tab.active {
  color: var(--text);
  box-shadow: 3px 3px 6px var(--sd), -3px -3px 6px var(--sl);
}

/* ── KPI ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi-card {
  border-radius: 16px; background: var(--bg); padding: 22px 20px 18px;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
}
.kpi-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 10px; }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; }
.kpi-sub { font-size: 11px; color: var(--muted); }
.kpi-bar { height: 3px; border-radius: 2px; margin-top: 14px; opacity: .4; }
.kpi-card.revenue .kpi-bar { background: linear-gradient(90deg, var(--blue), transparent); }
.kpi-card.profit  .kpi-bar { background: linear-gradient(90deg, var(--green), transparent); }
.kpi-card.delivery.kpi-bar { background: linear-gradient(90deg, var(--rose), transparent); }
.kpi-card.orders  .kpi-bar { background: linear-gradient(90deg, var(--muted), transparent); }

/* ── CHART CARD ── */
.chart-card {
  border-radius: 16px; background: var(--bg); padding: 20px;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
  margin-bottom: 16px;
}
.chart-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.chart-card-header h3 { font-size: 13px; font-weight: 700; }
.chart-wrap { position: relative; height: 220px; }

/* ── STORE GRID ── */
.store-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.store-stat-card {
  border-radius: 14px; background: var(--bg); padding: 18px 20px;
  box-shadow: 4px 4px 9px var(--sd), -4px -4px 9px var(--sl);
  border-top: 3px solid;
}
.store-stat-card .store-name { font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.store-stat-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; color: var(--muted); }
.store-stat-row span:last-child { font-weight: 600; color: var(--text); }

/* ── FILTERS BAR ── */
.filters-bar {
  border-radius: 14px; background: var(--bg); padding: 14px 18px;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
  margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filters-bar > div { display: flex; flex-direction: column; gap: 5px; }
.filters-bar label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.filters-bar select,
.filters-bar input[type="text"],
.filters-bar input[type="date"] {
  padding: 7px 12px; border: none; border-radius: 8px;
  font-size: 13px; outline: none; background: var(--bg); color: var(--text);
  font-family: inherit;
  box-shadow: inset 3px 3px 6px var(--sd), inset -3px -3px 6px var(--sl);
}

/* ── TABLE ── */
.table-card {
  border-radius: 16px; background: var(--bg); overflow: hidden;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; text-align: left;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
  border-bottom: 1px solid rgba(0,0,0,0.06); white-space: nowrap;
}
tbody td {
  padding: 11px 14px; font-size: 12.5px;
  border-bottom: 1px solid rgba(0,0,0,0.04); vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(0,0,0,.013); }

/* ── INLINE EDIT ── */
.editable-comment {
  border: none; background: transparent; font-size: 13px; color: var(--text);
  width: 140px; cursor: pointer; outline: none; font-family: inherit;
  padding: 3px 6px; border-radius: 8px;
}
.editable-comment:focus {
  box-shadow: inset 2px 2px 5px var(--sd), inset -2px -2px 5px var(--sl);
  cursor: text;
}
.editable-comment::placeholder { color: var(--muted); font-style: italic; }

/* ── STATUS SELECT ── */
.status-select {
  border: none; cursor: pointer; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; outline: none;
  font-family: inherit; appearance: none; -webkit-appearance: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.status-select.badge-processing {
  background: rgba(44,62,158,0.09); border: 1px solid rgba(44,62,158,0.2); color: #2c3e9e;
}
.status-select.badge-waiting {
  background: rgba(146,64,14,0.09); border: 1px solid rgba(146,64,14,0.2); color: #92400e;
}
.status-select.badge-delivered {
  background: rgba(26,92,66,0.09); border: 1px solid rgba(26,92,66,0.2); color: #1a5c42;
}
.status-select.badge-cancelled {
  background: rgba(124,29,63,0.09); border: 1px solid rgba(124,29,63,0.2); color: #7c1d3f;
}

/* ── STORE BADGE ── */
.store-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; color: #fff;
}

/* ── PROFIT ── */
.profit-pos  { color: #1a5c42; font-weight: 700; }
.profit-neg  { color: #7c1d3f; font-weight: 700; }
.profit-zero { color: var(--muted); }

/* ── PAGINATION ── */
.pagination {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-top: 1px solid rgba(0,0,0,.05);
}
.pagination button {
  padding: 5px 12px; border: none; background: var(--bg);
  border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--text);
  font-family: inherit;
  box-shadow: 3px 3px 6px var(--sd), -3px -3px 6px var(--sl);
  transition: box-shadow .15s, color .15s;
}
.pagination button:hover:not(:disabled) {
  color: var(--blue);
  box-shadow: 4px 4px 8px var(--sd), -4px -4px 8px var(--sl);
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button.active-page {
  color: var(--blue);
  box-shadow: inset 3px 3px 6px var(--sd), inset -3px -3px 6px var(--sl);
}
.pagination .page-info { font-size: 12px; color: var(--muted); }

/* ── BUTTONS ── */
.btn {
  padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: box-shadow .15s, color .15s;
  font-family: inherit;
  background: var(--bg); color: var(--text);
  box-shadow: 4px 4px 9px var(--sd), -4px -4px 9px var(--sl);
}
.btn:active { box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl); }

.btn-blue { color: var(--blue); }
.btn-blue:hover { color: #1f2d7a; }

.btn-ghost {
  color: var(--muted);
  box-shadow: 3px 3px 7px var(--sd), -3px -3px 7px var(--sl);
}
.btn-ghost:hover { color: var(--text); }

.btn-danger { color: var(--rose); }
.btn-danger:hover { color: #6a1834; }

.btn-sm { padding: 5px 12px; font-size: 12px; }

#btn-sync {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text);
  box-shadow: 3px 3px 7px var(--sd), -3px -3px 7px var(--sl);
}
#btn-sync:active { box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl); }

#btn-new-order, #btn-new-store {
  color: var(--blue); font-weight: 700;
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg); border-radius: 18px; padding: 28px 32px;
  width: 560px; max-width: 94vw; max-height: 90vh; overflow-y: auto;
  box-shadow: 10px 10px 28px var(--sd), -10px -10px 28px var(--sl);
  transform: translateY(16px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-grid.cols-1 { grid-template-columns: 1fr; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.field-group input, .field-group select, .field-group textarea {
  padding: 9px 12px; border: none; border-radius: 9px;
  font-size: 13.5px; font-family: inherit; outline: none;
  background: var(--bg); color: var(--text);
  box-shadow: inset 3px 3px 7px var(--sd), inset -3px -3px 7px var(--sl);
}
.field-group textarea { resize: vertical; min-height: 64px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── SETTINGS ── */
.settings-section {
  background: var(--bg); border-radius: 16px; padding: 24px;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
  margin-bottom: 18px;
}
.settings-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,.06); }
.settings-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid rgba(0,0,0,.04); }
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ── COLOR PICKER ── */
#color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.color-option {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  box-shadow: 2px 2px 5px var(--sd), -2px -2px 5px var(--sl);
  border: 2px solid transparent; transition: box-shadow .15s, border .15s;
}
.color-option.selected {
  box-shadow: inset 2px 2px 5px rgba(0,0,0,.2); border-color: var(--text);
}

/* ── LOADING / TOAST ── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(240,240,240,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 900; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.loading-overlay.show { opacity: 1; pointer-events: all; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  box-shadow: inset 4px 4px 9px var(--sd), inset -4px -4px 9px var(--sl);
  border: 3px solid transparent; border-top-color: var(--blue);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg); color: var(--text); padding: 12px 18px; border-radius: 12px;
  font-size: 12.5px; min-width: 220px;
  box-shadow: 6px 6px 14px var(--sd), -6px -6px 14px var(--sl);
  animation: toastIn .3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid #1a5c42; }
.toast.error   { border-left: 3px solid #7c1d3f; }
.toast.info    { border-left: 3px solid #2c3e9e; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .store-grid { grid-template-columns: 1fr; }
  .modal-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
}
