:root {
  --navy: #0b2545;
  --navy-light: #13355e;
  --steel: #5c7fa6;
  --paper: #f6f7f9;
  --line: #dde3ea;
  --ink: #1c2530;
  --ink-soft: #5b6572;
  --good: #1e7a4c;
  --bad: #b3261e;
  --accent: #d68c2b;
  --radius: 6px;
  font-size: 15px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

.numeric { font-variant-numeric: tabular-nums; font-family: "Consolas", "SFMono-Regular", monospace; }

/* ---------- Top bar ---------- */
header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

header.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.store-tabs { display: flex; gap: 6px; }

.store-tabs button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: #cfe0f5;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.store-tabs button.active {
  background: #fff;
  color: var(--navy);
  border-color: #fff;
}

.date-controls { display: flex; align-items: center; gap: 8px; }

.date-controls button {
  background: var(--navy-light);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
}

.date-controls input[type="date"] {
  padding: 6px 8px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
}

.view-toggle button {
  background: var(--navy-light);
  border: none;
  color: #cfe0f5;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.view-toggle button.active { background: var(--accent); color: #fff; }

main { padding: 18px 20px 60px; max-width: 1500px; margin: 0 auto; }

/* ---------- Summary cards ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}

.card .value { font-size: 20px; font-weight: 600; }
.card.pace { border-color: var(--accent); background: #fdf6ec; }

/* ---------- Deal table ---------- */
.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 20px;
}

table.deals { width: 100%; border-collapse: collapse; min-width: 1350px; }

table.deals th {
  background: var(--navy);
  color: #fff;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 6px;
  text-align: left;
  position: sticky;
  top: 0;
}

table.deals td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

table.deals input, table.deals select {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px;
  font-size: 13px;
  border-radius: 4px;
  font-family: inherit;
}
table.deals input:focus, table.deals select:focus {
  border-color: var(--steel);
  background: #fff;
  outline: none;
}

tr.deal-row { cursor: grab; }
tr.deal-row.sortable-ghost { opacity: 0.4; }
tr.deal-row td.drag-handle { color: var(--ink-soft); text-align: center; width: 24px; }

.color-swatch {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1px solid var(--line);
  cursor: pointer;
  display: inline-block;
}

.row-actions button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--bad);
  font-size: 13px;
}

.add-row-bar { padding: 8px; }
.add-row-bar button {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}

/* ---------- Section headers ---------- */
h2.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 24px 0 10px;
}

/* ---------- Source tally ---------- */
.tally-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.tally-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tally-item .name { font-size: 12.5px; flex: 1; }
.tally-item input {
  width: 44px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px;
  font-size: 12.5px;
}
.tally-item .sold-count {
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* ---------- Closures panel ---------- */
.closures-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  max-width: 480px;
}
.closures-panel form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.closures-panel input, .closures-panel select {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
}
.closures-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.closures-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.closures-list button { border: none; background: none; color: var(--bad); cursor: pointer; }

.toggle-link {
  background: none; border: none; color: var(--navy);
  text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0;
}

.status-msg { font-size: 12px; color: var(--ink-soft); margin-left: 10px; }

/* ---------- Manager sidebar ---------- */
.sidebar-toggle {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.manager-sidebar {
  position: fixed;
  top: 0;
  right: -380px;
  width: 360px;
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 16px rgba(0,0,0,0.15);
  z-index: 100;
  transition: right 0.2s ease;
  display: flex;
  flex-direction: column;
}
.manager-sidebar.open { right: 0; }

.sidebar-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-header h2 { font-size: 15px; margin: 0; font-weight: 600; }
.sidebar-header button { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; }

.sidebar-content { padding: 14px 16px; overflow-y: auto; flex: 1; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 99;
  display: none;
}
.sidebar-backdrop.open { display: block; }

.sb-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 18px 0 8px;
}
.sb-section-title:first-child { margin-top: 0; }

table.sb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.sb-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 4px 4px;
  border-bottom: 1px solid var(--line);
}
table.sb-table td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--line);
}
table.sb-table tr.sb-total td { font-weight: 700; border-top: 1px solid var(--ink-soft); border-bottom: none; }
table.sb-table td.numeric, table.sb-table th.numeric { text-align: right; }

.sb-compare-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.sb-compare-row .diff-up { color: var(--good); font-weight: 600; }
.sb-compare-row .diff-down { color: var(--bad); font-weight: 600; }
.sb-note {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 10px;
  line-height: 1.4;
}
