/* Twixy admin — deliberately distinct from the storefront look, so nobody
   mistakes this for a customer-facing page during a screen share. */

:root {
  --bg: #0f0e17;
  --panel: #1a1826;
  --panel-2: #211f30;
  --border: #2e2b40;
  --ink: #f2f0f8;
  --dim: #9a94b3;
  --purple: #8b5cf6;
  --purple-deep: #6a3aa0;
  --good: #34c77b;
  --warn: #e0a83e;
  --bad: #ef5757;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
button, input, select { font: inherit; }
a { color: var(--purple); }

.screen { min-height: 100vh; }

/* The `hidden` attribute is how login/dashboard visibility is toggled in
   app.js (els.loginScreen.hidden = true/false). By default that maps to
   `display: none`, but any other rule targeting the same element with equal
   or higher specificity - like #login-screen's own `display: flex` below -
   silently wins instead, since `[hidden]` has very low CSS specificity.
   That was the actual bug: after signing in, JS correctly set
   `loginScreen.hidden = true`, but #login-screen's `display: flex` kept it
   visually on screen anyway, sitting on top of the real, correctly-populated
   dashboard underneath. This rule makes `hidden` win no matter what else
   targets the element. */
[hidden] { display: none !important; }

/* LOGIN */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: grid;
  gap: 14px;
  text-align: center;
}
.login-logo { height: 48px; width: auto; max-width: 160px; object-fit: contain; margin: 0 auto 4px; }
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-sub { margin: 0 0 8px; color: var(--dim); font-size: .88rem; }
.login-card label {
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: .82rem;
  font-weight: 700;
  color: var(--dim);
}
.login-card input {
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--ink);
}
.login-card input:focus-visible { outline: 2px solid var(--purple); outline-offset: 1px; }
.login-error { min-height: 1.2em; color: var(--bad); font-size: .85rem; margin: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-deep));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ghost:hover { border-color: var(--purple); }

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.topbar-brand img { height: 28px; width: auto; max-width: 100px; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-email { color: var(--dim); font-size: .85rem; }

/* NAV TABS (Dashboard / Transactions) */
.topbar-nav { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: .88rem;
  color: var(--dim);
  text-decoration: none;
}
.nav-link:hover { color: var(--ink); background: var(--panel-2); }
.nav-link--active { color: var(--ink); background: var(--panel-2); }
.nav-link--inline {
  padding: 0;
  color: var(--purple);
  font-weight: 700;
  font-size: .82rem;
}
.nav-link--inline:hover { background: none; text-decoration: underline; }

.content { padding: 24px; max-width: 1280px; margin: 0 auto; }
.view { animation: none; }

/* DASHBOARD LAYOUT */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  align-items: start;
}
/* min-width:0 on both the grid children and the table itself - without it,
   .orders-table's own `min-width: 900px` (needed on the full Transactions
   table so its columns stay readable) forces the compact recent-orders panel
   to the same width, which blew the whole grid apart and pushed the
   breakdown panel almost entirely off-screen. */
.dash-grid > .panel { min-width: 0; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; font-size: 1rem; }

.orders-table--compact { min-width: 0; table-layout: fixed; }
.orders-table--compact td { padding: 9px 6px; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orders-table--compact tr:last-child td { border-bottom: none; }

/* BREAKDOWN BARS */
.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: .84rem;
}
.breakdown-label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-bar-track { height: 8px; border-radius: 999px; background: var(--panel-2); overflow: hidden; }
.breakdown-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--purple-deep), var(--purple)); }
.breakdown-qty { color: var(--dim); font-variant-numeric: tabular-nums; text-align: right; }
.breakdown-empty { margin: 0; font-size: .85rem; }

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}
.pagination-label { color: var(--dim); font-size: .85rem; }

@media (max-width: 860px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* STATS */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 4px;
}
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--dim); font-weight: 700; }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-sub { font-size: .78rem; color: var(--dim); }
.stat-card--warn .stat-value { color: var(--warn); }
.stat-card--bad .stat-value { color: var(--bad); }

/* TOOLBAR */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}
.toolbar select {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
}
.toolbar-count { color: var(--dim); font-size: .82rem; white-space: nowrap; margin-left: auto; }

/* TABLE */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.orders-table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 900px; }
.orders-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.orders-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.order-row { cursor: pointer; }
.order-row:hover { background: var(--panel-2); }
.loading-row { text-align: center; color: var(--dim); padding: 32px !important; }
.dim { color: var(--dim); }
.mono { font-variant-numeric: tabular-nums; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  background: var(--panel-2);
  color: var(--dim);
  text-decoration: none;
}
.badge--good { background: rgba(52,199,123,.15); color: var(--good); }
.badge--warn { background: rgba(224,168,62,.15); color: var(--warn); }
.badge--bad { background: rgba(239,87,87,.15); color: var(--bad); }

/* DETAIL OVERLAY */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}
.detail-panel {
  width: min(520px, 100%);
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 28px;
  overflow-y: auto;
}
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.detail-head h2 { margin: 0; font-size: 1.2rem; }
.detail-badges { display: flex; gap: 8px; margin-bottom: 20px; }
.detail-panel h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--dim);
  margin: 22px 0 10px;
}
.detail-panel p { font-size: .9rem; line-height: 1.6; margin: 0 0 10px; }
.detail-notes { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; font-size: .85rem; }
.detail-items, .detail-totals, .detail-meta { width: 100%; border-collapse: collapse; font-size: .88rem; }
.detail-items td, .detail-totals td, .detail-meta td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-items td:last-child, .detail-totals td:last-child { text-align: right; }
.detail-total-row td { font-weight: 800; border-top: 1px dashed var(--border); }
.detail-meta td:first-child { color: var(--dim); width: 40%; }
.detail-timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .85rem; }
.detail-timeline li { padding-bottom: 8px; border-bottom: 1px solid var(--border); }

@media (max-width: 720px) {
  .content { padding: 16px; }
  .detail-panel { width: 100%; }
}

/* DATE-RANGE FILTER (Transactions) */
.toolbar--dates { margin-top: -6px; margin-bottom: 16px; flex-wrap: wrap; }
.date-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--dim);
}
.date-label input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: .85rem;
}
.date-range-note { color: var(--dim); font-size: .82rem; }
