/* DataTaper admin console.
   Layout is a two-column grid: a collapsible sidebar and the scrolling main
   area. The sidebar width is a custom property so collapsing is one variable
   change rather than a rule per child. */
:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --line: #e3e6ea;
  --text: #1c2024;
  --dim: #6b7280;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --sidebar: #fff;
  --sidebar-dim: #667085;
  --nav-w: 236px;
  --nav-w-collapsed: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hide { display: none !important; }
.muted { color: var(--dim); }

/* --- shell --------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.18s ease;
}

.shell.collapsed { grid-template-columns: var(--nav-w-collapsed) 1fr; }

/* --- sidebar ------------------------------------------------------------- */

/* White rail, separated from the content by a hairline rather than a colour
   change. The DataTaper wordmark is a dark gradient, so it only reads on a
   light background — which is why the brand block below needs no inversion. */
.nav {
  background: var(--sidebar);
  color: var(--text);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

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

/* The wordmark is a wide SVG, illegible at 64px — so the collapsed rail shows
   the square app mark instead and the two swap rather than one being scaled. */
.nav-logo { height: 26px; width: auto; display: block; }
.nav-mark { width: 30px; height: 30px; border-radius: 7px; display: none; }
.collapsed .nav-logo { display: none; }
.collapsed .nav-mark { display: block; margin: 0 auto; }
.collapsed .nav-brand { padding: 16px 0; justify-content: center; }

.nav-items { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--sidebar-dim);
  font: inherit;
  font-weight: 500;
  text-align: left;
  width: 100%;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
/* Active page keeps the solid accent fill — a tinted background alone is too
   quiet against white to find at a glance. */
.nav-item.on { background: var(--accent); color: #fff; }
.nav-item svg { flex-shrink: 0; }

/* Collapsed: icons only, centred, with the label removed from the flow (not
   just hidden) so it can't force the rail wider. */
.collapsed .nav-item { justify-content: center; padding: 9px 0; }
.collapsed .nav-label { display: none; }

.nav-foot { padding: 10px; border-top: 1px solid var(--line); }

.nav-who {
  padding: 4px 11px 10px;
  font-size: 12px;
  color: var(--sidebar-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collapsed .nav-who { display: none; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--sidebar-dim);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--bg); color: var(--text); }
.collapsed .nav-btn { justify-content: center; padding: 9px 0; }

/* --- main ---------------------------------------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 13px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 { font-size: 17px; margin: 0; }
.topbar .sub { color: var(--dim); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.burger {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 8px;
  line-height: 0;
  color: var(--dim);
  cursor: pointer;
}

.burger:hover { background: #f0f2f5; color: var(--text); }

.view { padding: 22px; max-width: 1280px; width: 100%; }

/* --- shared bits --------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}

.card h2 { margin: 0; font-size: 15px; }

label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }

input, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 7px;
}

button:hover { background: #f0f2f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.07); }
button.sm { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover { background: #fafbfc; }
.serial { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}

.b-free, .b-customer { color: var(--dim); border-color: var(--line); }
.b-paid, .b-active { color: var(--green); border-color: var(--green); }
.b-disabled { color: var(--red); border-color: var(--red); }
.b-expired { color: var(--amber); border-color: var(--amber); }
.b-admin { color: var(--accent); border-color: var(--accent); }

.actions { display: flex; gap: 5px; }

.ico {
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  line-height: 0;
}

.ico:hover { background: #f0f2f5; color: var(--text); }
.ico.danger:hover { background: #fdecec; color: var(--red); border-color: #f0c9c9; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 9px;
  font-size: 13px;
  max-width: 420px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 80;
}

.toast.bad { background: #7f1d1d; }
.toast .k { font-family: ui-monospace, Consolas, monospace; font-weight: 700; }

.hint { color: var(--dim); font-size: 12px; margin-top: 8px; }
.row-hi { animation: hi 2.2s ease; }
@keyframes hi { from { background: #fff7db; } to { background: transparent; } }

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input { width: 220px; }
.filters select { width: auto; }
.scroll-x { overflow-x: auto; }
.empty { padding: 26px 10px; text-align: center; color: var(--dim); }

/* --- login --------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
}

.login-card img { height: 30px; display: block; margin: 0 auto 6px; }
.login-card .lead { text-align: center; color: var(--dim); font-size: 13px; margin-bottom: 20px; }
.login-card .fld + .fld { margin-top: 12px; }
.login-card button { width: 100%; margin-top: 18px; }
.login-card .hint { text-align: center; min-height: 18px; }

/* --- dashboard ----------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 17px;
}

.tile .k { font-size: 12px; color: var(--dim); font-weight: 600; }
.tile .v { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.15; }
.tile .m { font-size: 12px; color: var(--dim); margin-top: 3px; }
.tile .v.accent { color: var(--accent); }
.tile .v.green { color: var(--green); }
.tile .v.amber { color: var(--amber); }
.tile .v.red { color: var(--red); }

.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .cols2 { grid-template-columns: 1fr; } }

/* Validation activity: a bar per day. Plain divs rather than a chart library —
   fourteen bars do not justify a dependency, and this stays legible when the
   values are all zero (every bar keeps a 2px floor). */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 92px; margin-top: 6px; }
.spark .bar { flex: 1; background: var(--accent-soft); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.spark .bar > i { position: absolute; inset: auto 0 0 0; background: var(--accent); border-radius: 3px 3px 0 0; display: block; }
.spark-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); margin-top: 6px; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-list li:last-child { border-bottom: none; }
.mini-list .r { color: var(--dim); font-size: 12px; white-space: nowrap; }

.bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; }
.bar-row .track { flex: 1; height: 7px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--accent); border-radius: 99px; }

/* --- drawer -------------------------------------------------------------- */

.drawer-back {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0);
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  visibility: hidden;
  transition: background 0.2s ease, visibility 0.2s;
}

.drawer-back.open { background: rgba(17, 24, 39, 0.42); visibility: visible; }

.drawer {
  width: 420px;
  max-width: 94vw;
  height: 100%;
  background: var(--panel);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.14);
  padding: 20px 22px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.drawer-back.open .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer .fld { margin-top: 12px; }
.drawer .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
