:root {
  --bg: #0b0d12;
  --bg-2: #0e1117;
  --panel: #151922;
  --panel-2: #1b202b;
  --panel-hover: #1f2530;
  --border: #262c38;
  --border-soft: #1e2430;
  --text: #edeef1;
  --muted: #8b93a1;
  --muted-2: #5f6774;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --accent-soft: rgba(91, 140, 255, 0.12);
  --green: #3ecf8e;
  --green-soft: rgba(62, 207, 142, 0.12);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.12);
  --yellow: #f5c451;
  --yellow-soft: rgba(245, 196, 81, 0.12);
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 12px 40px -12px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3140; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #333c4d; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(91, 140, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(62, 207, 142, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  letter-spacing: -0.005em;
}

/* ---------- Login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.login-box {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 340px;
  box-shadow: var(--shadow-pop);
}

.login-mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), #7ee0c2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #0b0d12;
  margin-bottom: 18px;
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
  font-weight: 700;
}

.login-box p.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 22px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0L5 6L10 0Z' fill='%238b93a1'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: white;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }

button.secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--panel-hover); filter: none; }

button.danger {
  background: linear-gradient(180deg, #ff8080, var(--red));
}

.error-msg {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}

/* ---------- App shell ---------- */
#app {
  display: none;
  height: 100vh;
}

.layout {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 236px;
  background: linear-gradient(180deg, var(--panel), #12151c);
  border-right: 1px solid var(--border-soft);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7ee0c2);
  flex-shrink: 0;
}

.brand h2 {
  font-size: 14.5px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand span {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  font-weight: 500;
}

.nav-section-label {
  font-size: 10.5px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 0 10px;
  margin: 14px 0 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item svg { flex-shrink: 0; opacity: 0.85; }

.nav-item:hover { background: var(--panel-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: white;
  box-shadow: 0 4px 14px -4px rgba(91, 140, 255, 0.5);
}
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--muted);
}

.sidebar-footer button { width: 100%; margin-top: 10px; }

.main {
  flex: 1;
  padding: 34px 44px 60px;
  overflow-y: auto;
}

.page-header {
  margin-bottom: 26px;
}

.page-header h1 {
  font-size: 23px;
  margin: 0 0 4px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.card {
  background: linear-gradient(165deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-2px); border-color: #313847; }

.card .label {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 10px;
}

.card .value {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card .value.green { color: var(--green); }
.card .value.red { color: var(--red); }
.card .value.yellow { color: var(--yellow); }

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(165deg, var(--panel), var(--panel-2) 130%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}

.panel h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 700;
}

.panel > p.muted { margin: 0 0 16px; font-size: 13px; }
.panel h3 + p.muted { margin-top: 0; margin-bottom: 16px; }
.panel h3 + .form-row,
.panel h3 + .error-msg,
.panel h3 + div { margin-top: 14px; }

/* ---------- Tables ---------- */
.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

thead th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--panel-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Forms ---------- */
.form-row {
  display: flex;
  gap: 12px;
}
.form-row > * { flex: 1; }
.form-row > div { display: flex; flex-direction: column; }

/* ---------- Toast notifications ---------- */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Per-brand progress bars (Phase 7) ---------- */
.progress-brand-block { margin-bottom: 22px; }
.progress-brand-block:last-child { margin-bottom: 0; }
.progress-brand-name { font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.progress-row:last-child { margin-bottom: 0; }
.progress-row-label { flex: 0 0 70px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.progress-track { flex: 1; height: 10px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.2s ease; }
.progress-fill.checked { background: var(--green); }
.progress-row-numbers { flex: 0 0 110px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Bulk action bar (Phase 5) ---------- */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.bulk-bar span { font-size: 13px; font-weight: 600; }
.bulk-bar select { max-width: 200px; margin-bottom: 0; }
.bulk-bar button { flex: 0 0 auto; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.pending { background: var(--yellow-soft); color: var(--yellow); }
.badge.complete { background: var(--green-soft); color: var(--green); }
.badge.incomplete { background: var(--red-soft); color: var(--red); }

.badge.status-active { background: var(--green-soft); color: var(--green); }
.badge.status-inactive { background: var(--yellow-soft); color: var(--yellow); }
.badge.status-not-on-tal { background: var(--red-soft); color: var(--red); }
.badge.status-rejected { background: var(--red-soft); color: var(--red); }
.badge.status-product-added { background: var(--blue-soft); color: var(--blue); }

/* PLAN_ADDED_TO_TAL.md -- path badges in the Product Added tab */
.badge.path-awaiting { background: var(--blue-soft); color: var(--blue); }
.badge.path-full-add { background: var(--panel-2); color: var(--muted); }

select.status-select {
  margin-bottom: 0;
  padding: 4px 24px 4px 8px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 20px;
}
select.status-select.status-active { background-color: var(--green-soft); color: var(--green); border-color: transparent; }
select.status-select.status-inactive { background-color: var(--yellow-soft); color: var(--yellow); border-color: transparent; }
select.status-select.status-not-on-tal { background-color: var(--red-soft); color: var(--red); border-color: transparent; }
select.status-select.status-rejected { background-color: var(--red-soft); color: var(--red); border-color: transparent; }
select.status-select.status-product-added { background-color: var(--blue-soft); color: var(--blue); border-color: transparent; }

textarea#prod-import-csv {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  resize: vertical;
}

input.not-done-input {
  border-color: rgba(255, 107, 107, 0.4);
  background: var(--red-soft);
}
input.not-done-input::placeholder {
  color: var(--red);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.03em;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.15s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.row-actions { white-space: nowrap; }
.row-actions button { padding: 5px 11px; font-size: 12px; margin-right: 6px; }

.muted { color: var(--muted); }

.empty-row td {
  color: var(--muted-2);
  text-align: center;
  padding: 24px 12px;
  font-style: italic;
}
