:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-muted: #fafaf8;
  --surface-hover: #f3f3ef;
  --border: #e6e6e0;
  --border-strong: #d4d4cc;
  --text: #141413;
  --text-secondary: #52524e;
  --text-muted: #7c7c76;
  --ink: #18181b;
  --ink-hover: #2c2c30;
  --accent: #1d4ed8;
  --accent-soft: #eef2ff;
  --profit: #0f766e;
  --profit-bg: #eef7f6;
  --loss: #b91c1c;
  --loss-bg: #fdf2f2;
  --warn: #a16207;
  --warn-bg: #fef9ec;
  --radius: 6px;
  --radius-sm: 4px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

/* ==================== SIDEBAR (Quiet Editorial Light) ==================== */
.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.brand {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--ink);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 14px;
  height: 14px;
}

.brand-title {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-section-label {
  padding: 14px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

.nav-list {
  padding: 8px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav-item.active {
  background: #efefeb;
  color: var(--text);
  font-weight: 600;
}

.nav-item.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 6px;
  bottom: 6px;
  width: 2.5px;
  background: var(--ink);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  stroke-width: 1.75;
  opacity: 0.72;
}

.nav-item.active svg {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 0 5px;
  min-width: 18px;
  height: 17px;
  line-height: 17px;
  text-align: center;
  border-radius: 3px;
  background: var(--warn-bg);
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface-muted);
}

.sidebar-fx {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 11.5px;
}

.demo-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--warn);
  font-weight: 600;
  margin-bottom: 4px;
}

/* ==================== TOPBAR ==================== */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 15;
}

.topbar-title-group {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.topbar-title-group h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.topbar-title-group p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-select {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.filter-select:hover {
  border-color: #a8a89f;
}

.filter-select:focus {
  border-color: var(--ink);
}

.date-pair {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  height: 30px;
  padding: 0 4px;
}

.date-pair select {
  border: none;
  background: transparent;
  font-size: 12.5px;
  color: var(--text);
  padding: 0 4px;
  outline: none;
  cursor: pointer;
}

.date-pair span {
  color: var(--text-muted);
  font-size: 11px;
  padding: 0 2px;
}

/* Tactile Segmented Switch */
.segmented {
  display: inline-flex;
  background: #efefeb;
  border-radius: var(--radius-sm);
  padding: 2px;
  height: 30px;
  align-items: center;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 0 9px;
  height: 26px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.content {
  padding: 18px 24px 44px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #a8a89f;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--ink-hover);
  border-color: var(--ink-hover);
}

.btn-danger {
  background: var(--surface);
  border-color: #e5c3c3;
  color: var(--loss);
}

.btn-danger:hover:not(:disabled) {
  background: var(--loss-bg);
  border-color: #d99b9b;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ==================== QUIET STATUS STRIP ==================== */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.status-bar-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.status-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-warn { background: #d97706; }
.dot-loss { background: #b91c1c; }
.dot-profit { background: #0f766e; }
.dot-neutral { background: #7c7c76; }
.dot-ozon { background: #1d4ed8; }
.dot-tiktok { background: #18181b; }
.dot-shein { background: #7e22ce; }

/* ==================== UNIFIED LEDGER KPI STRIP ==================== */
.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.metric-strip-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-cell {
  padding: 15px 18px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.metric-cell:last-child {
  border-right: none;
}

.metric-cell.emphasis {
  background: var(--surface-muted);
}

.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.metric-tag {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}

.metric-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==================== PANELS & LAYOUT ==================== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.1px;
}

.panel-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.grid-2-1 {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stack-14 {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ==================== SEMANTIC TEXT & RESTRAINED TAGS ==================== */
.text-profit { color: var(--profit); }
.text-loss { color: var(--loss); }
.text-warn { color: var(--warn); }
.text-muted { color: var(--text-muted); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag-profit { background: var(--profit-bg); color: var(--profit); }
.tag-loss { background: var(--loss-bg); color: var(--loss); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-neutral { background: #f1f1ed; color: var(--text-secondary); }
.tag-outline { background: transparent; border-color: var(--border-strong); color: var(--text-secondary); }

.plat-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ==================== TABLES (Crisp Ledger Style) ==================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

table.ledger th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}

table.ledger th.right,
table.ledger td.right {
  text-align: right;
}

table.ledger td {
  padding: 9px 10px;
  border-bottom: 1px solid #efefeb;
  vertical-align: middle;
}

table.ledger tbody tr:hover {
  background: var(--surface-muted);
}

table.ledger tbody tr.clickable {
  cursor: pointer;
}

table.ledger tbody tr.sub-row {
  background: #fafaf7;
}

table.ledger tbody tr.sub-row td {
  font-size: 12px;
  color: var(--text-secondary);
  padding-top: 7px;
  padding-bottom: 7px;
}

table.ledger tbody tr.total-row td {
  background: #f3f3ef;
  font-weight: 700;
  border-top: 1.5px solid var(--border-strong);
  border-bottom: none;
}

.expand-btn {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: var(--text-secondary);
  margin-right: 6px;
}

/* ==================== UNDERLINE TABS ==================== */
.underline-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.underline-tab {
  border: none;
  background: transparent;
  padding: 8px 2px 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.underline-tab:hover {
  color: var(--text);
}

.underline-tab.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--ink);
}

/* ==================== FORMS, INLINE INPUTS & BATCH ==================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: #fff;
  outline: none;
}

.input:focus {
  border-color: var(--ink);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar-row .input {
  width: auto;
  min-width: 120px;
  height: 30px;
  padding: 0 9px;
  font-size: 12.5px;
}

.toolbar-row .search-input {
  min-width: 220px;
  flex: 1;
  max-width: 340px;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 8px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.summary-strip b {
  color: var(--text);
}

/* Seamless Excel-like inline cell input */
.cell-input {
  width: 74px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-bottom-color: var(--border);
  border-radius: 3px;
  font-size: 12.5px;
  text-align: right;
  background: transparent;
  color: var(--text);
  outline: none;
  font-variant-numeric: tabular-nums;
}

.cell-input:hover {
  border-color: var(--border-strong);
  background: #fff;
}

.cell-input:focus {
  border-color: var(--ink);
  background: #fff;
}

.cell-input.text-left {
  width: 150px;
  text-align: left;
}

.cell-input.saved {
  border-color: var(--profit);
  background: var(--profit-bg);
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: #f3f3ef;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 12px;
}

.batch-bar .cell-input {
  background: #fff;
  border: 1px solid var(--border-strong);
}

.filter-tabs {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.filter-tab {
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.filter-tab:last-child {
  border-right: none;
}

.filter-tab.active {
  background: var(--ink);
  color: #ffffff;
  font-weight: 600;
}

/* ==================== STORE CARDS ==================== */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 12px;
}

.store-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.store-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.store-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  background: var(--surface-muted);
  border: 1px solid #efefeb;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.store-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #efefeb;
}

/* ==================== PLATFORM SELECTOR ==================== */
.platform-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.platform-tab {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 9px 8px;
  text-align: center;
  cursor: pointer;
}

.platform-tab.active {
  border-color: var(--ink);
  background: #f3f3ef;
  box-shadow: inset 0 0 0 1px var(--ink);
}

.platform-tab strong { display: block; font-size: 13px; color: var(--text); }
.platform-tab span { font-size: 11px; color: var(--text-muted); }

/* ==================== DRAWER & MODAL ==================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 19, 0.36);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
}

.overlay.center {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.drawer {
  width: min(540px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header,
.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body,
.drawer-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer,
.drawer-footer {
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-muted);
}

.close-btn {
  border: none;
  background: transparent;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
}

.close-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.kv-list {
  display: flex;
  flex-direction: column;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #f1f1ed;
  font-size: 12.5px;
}

.kv-row.strong {
  font-weight: 700;
  font-size: 13.5px;
  border-bottom: none;
  border-top: 1.5px solid var(--border-strong);
  padding-top: 9px;
  margin-top: 2px;
}

/* ==================== CHARTS & MISC ==================== */
.chart-box {
  width: 100%;
  overflow-x: auto;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.alloc-bar {
  display: flex;
  height: 12px;
  border-radius: 3px;
  overflow: hidden;
  background: #efefeb;
  margin-bottom: 14px;
}

.alloc-seg {
  height: 100%;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.page-controls {
  display: flex;
  gap: 6px;
}

.progress-bar-bg {
  height: 6px;
  background: #e6e6e0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--ink);
  transition: width 0.25s ease;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.dropzone.dragover {
  border-color: var(--ink);
  background: #f3f3ef;
}

.hint-box {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-secondary);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  background: var(--ink);
  color: #f8f8f6;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  max-width: 360px;
}

.toast.success { border-left: 3px solid #14b8a6; }
.toast.error { border-left: 3px solid #ef4444; }
.toast.info { border-left: 3px solid #94a3b8; }

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

[hidden] {
  display: none !important;
}

/* ==================== AUTH GATE (Editorial Login & First-Run Setup) ==================== */
.auth-gate {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px 24px;
  box-shadow: 0 12px 32px rgba(24, 24, 27, 0.06);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.auth-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.auth-sub {
  margin: 6px 0 18px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-error {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--loss-bg);
  border: 1px solid #fecaca;
  color: var(--loss);
  font-size: 12px;
  line-height: 1.45;
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap .input {
  padding-right: 52px;
}

.pw-toggle {
  position: absolute;
  right: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  padding: 3px 5px;
}

.pw-toggle:hover {
  color: var(--text);
}

.auth-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.auth-submit {
  width: 100%;
  height: 36px;
  font-size: 13.5px;
  margin-top: 4px;
}

.auth-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #efefeb;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-foot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  background: var(--surface-muted);
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-secondary);
}

.sidebar-user {
  padding-bottom: 9px;
  margin-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.sidebar-user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
  font-size: 11.5px;
}

@media (max-width: 1180px) {
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-cell { border-bottom: 1px solid var(--border); }
  .grid-2-1, .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-list { flex-direction: row; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-item.active::before { display: none; }
  .metric-strip, .metric-strip-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}
