:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e2230;
  --border: #2a2f3d;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --green: #34c98e;
  --red: #f0616d;
  --orange: #f5a95c;
  --purple: #a78bfa;
}

/* ---- Light mode ---- */
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #e9edf4;
  --border: #d5dbe7;
  --text: #1c2434;
  --muted: #63708a;
  --accent: #2f6de0;
  --green: #128a5c;
  --red: #d43f4f;
  --orange: #c96f1a;
  --purple: #7a5cd6;
}
:root[data-theme="light"] .badge.new { background: #dbe5ff; color: #2f56c4; }
:root[data-theme="light"] .badge.confirmed { background: #d3f2e4; color: #0f7a50; }
:root[data-theme="light"] .badge.no_answer.na-1 { background: #ffeccd; color: #9a6414; }
:root[data-theme="light"] .badge.no_answer.na-2 { background: #ffdda8; color: #8a5203; }
:root[data-theme="light"] .badge.no_answer.na-3 { background: #ffc97e; color: #7a4300; }
:root[data-theme="light"] .badge.postponed { background: #d5e8fb; color: #1d6fc2; }
:root[data-theme="light"] .badge.cancelled { background: #fbdadd; color: #c22736; }
:root[data-theme="light"] .badge.didnt_order { background: #1c2434; color: #ffffff; border: 1px solid #1c2434; }
:root[data-theme="light"] tbody tr.row-didnt_order { background: rgba(28, 36, 52, 0.10); }
:root[data-theme="light"] .badge.shipped { background: #d3ecf8; color: #146d99; }
:root[data-theme="light"] .badge.delivered { background: #d3f2e4; color: #0f7a50; }
:root[data-theme="light"] .badge.returned { background: #fbdadd; color: #c22736; }
:root[data-theme="light"] .statusmenu .mi-na1 { color: #b07514; }
:root[data-theme="light"] .statusmenu .mi-na2 { color: #9a5f07; }
:root[data-theme="light"] .statusmenu .mi-na3 { color: #855000; }
:root[data-theme="light"] .statusmenu .mi-blue { color: #1d6fc2; }
:root[data-theme="light"] .statusmenu { box-shadow: 0 10px 30px rgba(30, 40, 70, 0.18); }
:root[data-theme="light"] .msg.err { background: #fbdadd; color: #b02231; }
:root[data-theme="light"] .msg.ok { background: #d3f2e4; color: #0f7a50; }
:root[data-theme="light"] .msg.warn { background: #ffeccd; color: #9a6414; }
:root[data-theme="light"] button.good { color: #ffffff; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

button {
  font: inherit;
  color: inherit;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.good { background: var(--green); border-color: var(--green); color: #08281b; font-weight: 600; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }

/* ---- Login ---- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: 340px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.login-card button { width: 100%; margin-top: 16px; }

/* ---- Layout ---- */
header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
header .logo { font-weight: 700; font-size: 16px; }
header .logo span { color: var(--accent); }
nav { display: flex; gap: 6px; }
nav button { border: none; background: transparent; color: var(--muted); padding: 7px 12px; }
nav button.active { background: var(--panel-2); color: var(--text); border-radius: 8px; }
header .spacer { flex: 1; }
header .who { color: var(--muted); font-size: 13px; }

main { padding: 20px 24px; width: 100%; }

/* ---- Toolbar / filters ---- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { width: 240px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.chip.active { border-color: var(--accent); color: var(--text); background: var(--panel-2); }
.chip b { color: var(--text); }

/* ---- Orders table ---- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 8px 7px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13px; }
th:first-child, td:first-child { padding-left: 12px; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr { cursor: pointer; }
/* Whole row tinted by status — the badge color, spread across the section */
tbody tr.row-confirmed { background: rgba(52, 201, 142, 0.08); }
tbody tr.row-no_answer.na-1 { background: rgba(242, 197, 131, 0.07); }
tbody tr.row-no_answer.na-2 { background: rgba(245, 169, 92, 0.13); }
tbody tr.row-no_answer.na-3 { background: rgba(255, 139, 38, 0.20); }
tbody tr.row-postponed { background: rgba(88, 166, 240, 0.09); }
tbody tr.row-cancelled { background: rgba(240, 97, 109, 0.10); }
tbody tr.row-didnt_order { background: rgba(0, 0, 0, 0.45); }
tbody tr.row-shipped { background: rgba(88, 196, 240, 0.07); }
tbody tr.row-delivered { background: rgba(52, 201, 142, 0.05); }
tbody tr.row-returned { background: rgba(240, 97, 109, 0.06); }
tbody tr:hover { background: var(--panel-2); }
td.wrap { white-space: normal; max-width: 190px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.new { background: #2a3550; color: #9db8ff; }
.badge.confirmed { background: #14382a; color: var(--green); }
/* No answer: darker & hotter with each attempt */
.badge.no_answer.na-1 { background: #3a2d18; color: #f2c583; }
.badge.no_answer.na-2 { background: #4d340e; color: #f5a95c; }
.badge.no_answer.na-3 { background: #613608; color: #ff8b26; }
.badge.postponed { background: #16324d; color: #58a6f0; }
.badge.cancelled { background: #40222a; color: var(--red); cursor: help; }
.badge.didnt_order { background: #000000; color: #b8bfce; border: 1px solid #3a3f4c; }
.badge.shipped { background: #123344; color: #58c4f0; }
.badge.delivered { background: #14382a; color: var(--green); }
.badge.returned { background: #40222a; color: var(--red); }

/* ---- Modal ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: grid; place-items: center; z-index: 10; padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(720px, 100%); max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal h2 { font-size: 17px; margin-bottom: 2px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.timeline { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 10px; }
.timeline h3 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.timeline .ev { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.timeline .ev b { color: var(--text); font-weight: 600; }
.timeline .ev-time { float: inline-end; }

.langsel { width: auto; padding: 7px 8px; }

/* ---- Profit breakdown ---- */
.pf-line { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.pf-line span:last-child { font-variant-numeric: tabular-nums; }
.pf-earn {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: rgba(52, 201, 142, 0.12); color: var(--green);
  font-weight: 700; font-size: 17px;
}
.pf-earn.pf-loss { background: rgba(240, 97, 109, 0.12); color: var(--red); }
.pf-sub { border-bottom: none; color: var(--muted); font-size: 12.5px; }

/* Special-offer orders: product name in heavy bold so the team spots them */
td.offer-bold { font-weight: 800; color: var(--text); }

/* ---- Offer switcher in the order form ---- */
.offers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.offer-chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: start; padding: 8px 12px; max-width: 260px;
}
.offer-chip .offer-name { font-size: 12.5px; white-space: normal; }
.offer-chip .offer-price { font-size: 13px; font-weight: 700; color: var(--green); }
.offer-chip.active { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ---- Delivery price line in the order form ---- */
.pricebox { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.price-line { font-size: 13px; color: var(--muted); }
.price-line b { color: var(--green); font-size: 14px; }
.price-hint { font-size: 12.5px; color: var(--muted); }

/* ---- Settings / cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.card h2 { font-size: 15px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; }
.card .status-ok { color: var(--green); font-size: 12.5px; }
.card .status-warn { color: var(--orange); font-size: 12.5px; }
.card button { margin-top: 12px; }

/* ---- Status dropdown menu ---- */
.badge-btn { cursor: pointer; user-select: none; }
.badge-btn:hover { filter: brightness(1.25); }
.statusmenu {
  position: fixed; z-index: 50; min-width: 170px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.statusmenu button {
  border: none; background: transparent; text-align: start;
  padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.statusmenu button:hover { background: var(--panel); border: none; }
.statusmenu .mi-green { color: var(--green); }
.statusmenu .mi-na1 { color: #f2c583; }
.statusmenu .mi-na2 { color: #f5a95c; }
.statusmenu .mi-na3 { color: #ff8b26; }
.statusmenu .mi-blue { color: #58a6f0; }
.statusmenu .mi-red { color: var(--red); }
.statusmenu .mi-black { color: var(--text); }

/* ---- Bulk action bar ---- */
.bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel-2); border: 1px solid var(--accent); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 13.5px;
}
.bulk-hint { color: var(--muted); font-size: 12.5px; }
.rowcheck, #selectAll { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ---- Stats tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.tile-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.statnote { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.hidebtn { padding: 3px 10px; font-size: 12px; }
.hiddenwrap { margin-top: 18px; }
.hiddenwrap summary { color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 8px; }
.hiddenwrap summary:hover { color: var(--text); }

.msg { margin: 10px 0; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.msg.err { background: #40222a; color: var(--red); }
.msg.ok { background: #14382a; color: var(--green); }
.msg.warn { background: #3d2f1b; color: var(--orange); }

/* ---- Customer history dot (green = good, red = bad, dark red = super bad) ---- */
.cust-dot {
  display: inline-block; min-width: 20px; text-align: center;
  border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 800;
  margin-inline-start: 6px; color: #ffffff; cursor: help; vertical-align: middle;
}
.cust-dot.good { background: #128a5c; }
.cust-dot.bad { background: #d43f4f; }
.cust-dot.superbad { background: #7a0c16; box-shadow: 0 0 0 1px #ff8b8b inset; }
.cust-dot.neutral { background: #5f6b81; }

/* "20/6" pair badge: green delivered / red returned, border = verdict */
.cust-pair {
  display: inline-block; border-radius: 999px; padding: 1px 8px;
  font-size: 11.5px; font-weight: 800; margin-inline-start: 6px;
  background: rgba(0, 0, 0, 0.35); cursor: help; vertical-align: middle;
  border: 1.5px solid transparent; color: var(--muted);
}
:root[data-theme="light"] .cust-pair { background: rgba(28, 36, 52, 0.07); }
.cust-pair .cp-g { color: #22b57f; }
.cust-pair .cp-r { color: #ff5d6b; }
:root[data-theme="light"] .cust-pair .cp-g { color: #0f7a50; }
:root[data-theme="light"] .cust-pair .cp-r { color: #c22736; }
.cust-pair.good { border-color: #128a5c; }
.cust-pair.warn { border-color: #c96f1a; }
.cust-pair.bad { border-color: #d43f4f; }
.cust-pair.superbad { border-color: #7a0c16; background: rgba(122, 12, 22, 0.35); }

/* ---- Click-to-call ---- */
.phone-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.phone-link:hover { text-decoration: underline; }
.callbtn { padding: 7px 10px; flex-shrink: 0; }

/* ---- Team performance ---- */
.agtitle { font-size: 15px; margin: 0; }
.agentwrap .tablewrap { margin-top: 4px; }

.empty { text-align: center; color: var(--muted); padding: 48px 0; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  header { flex-wrap: wrap; }
}
