/* cexytime — visual language borrowed from chadboard's cb component library:
   white page, dark #1e1e2e navbar, indigo #4f46e5 accent, #f8f9fa sidebar,
   6px radii, uppercase micro-labels, stat tiles above a responsive card grid. */

:root {
  --nav-bg: #1e1e2e;
  --nav-surface: #2a2a3d;
  --nav-border: #3a3a4d;
  --page-bg: #ffffff;
  --surface-muted: #f8f9fa;
  --surface-hover: #fafafa;
  --border: #dee2e6;
  --border-faint: #f0f1f3;
  --radius: 6px;
  --radius-sm: 4px;
  --text: #212529;
  --text-muted: #6c757d;
  --text-faint: #adb5bd;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --green: #198754;
  --green-soft: #d1e7dd;
  --red: #dc3545;
  --red-soft: #f8d7da;
  --amber: #997404;
  --amber-soft: #fff8e1;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- navbar */
.navbar {
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.navbar .brand {
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: #fff;
  margin-right: 1rem;
}
.navbar .brand span { color: #e2483d; }
.nav-link {
  background: none;
  border: 0;
  color: #9ca3af;
  font-size: 0.875rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav-link .badge {
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.05rem 0.4rem;
  margin-left: 0.3rem;
  vertical-align: 1px;
}
.nav-spacer { flex: 1; }
.nav-user { color: #9ca3af; font-size: 0.85rem; margin-right: 0.5rem; }

/* ---------------------------------------------------------------- layout */
.page {
  max-width: 1400px;
  margin: 1.25rem auto;
  padding: 0 1.25rem;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
.sidebar {
  flex: 0 0 260px;
  background: var(--surface-muted);
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  position: sticky;
  top: 64px;
}
.sidebar-section { padding: 0.9rem 1rem; border-bottom: 1px solid #e9ecef; }
.sidebar-section:last-child { border-bottom: 0; }
.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.main { flex: 1; min-width: 0; }

@media (max-width: 900px) {
  .page { flex-direction: column; }
  .sidebar { position: static; flex: none; width: 100%; }
}

/* ------------------------------------------------------------- controls */
.input, select.input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  background: var(--surface-muted);
  color: var(--text);
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { background: #fff; border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); }
.btn-outline-danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn-outline-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-outline-success { background: #fff; border-color: var(--green); color: var(--green); }
.btn-outline-success:hover:not(:disabled) { background: var(--green); color: #fff; }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.mb { margin-bottom: 0.6rem; }

/* ------------------------------------------------------------ stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.stat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 0.6rem 0.75rem;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.stat-symbol { font-family: var(--mono); color: var(--text-faint); text-transform: none; }
.stat-value { font-size: 1.75rem; font-weight: 600; }
.stat-value.good { color: var(--green); }
.stat-value.bad { color: var(--red); }
.stat-sub { font-size: 0.78rem; color: var(--text-muted); }

/* ------------------------------------------------------------- item grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: 0 0.25rem 0.6rem rgba(0, 0, 0, 0.1); }
.card-body { padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.card-title { font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.card-title a { color: var(--text); }
.card-img { height: 110px; display: flex; align-items: center; justify-content: center; }
.card-img img { max-height: 110px; max-width: 100%; border-radius: var(--radius-sm); }
.card-img .noimg { color: var(--text-faint); font-size: 0.8rem; }
.param-list { list-style: none; margin: 0; padding: 0; font-size: 0.82rem; }
.param-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.16rem 0;
  border-bottom: 1px solid var(--border-faint);
}
.param-list li:last-child { border-bottom: 0; }
.param-list .k { color: var(--text-muted); }
.param-list .v { font-variant-numeric: tabular-nums; text-align: right; }

.pill {
  display: inline-block;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.55rem;
}
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-grey { background: var(--border-faint); color: var(--text-muted); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-region { background: var(--accent-soft); color: var(--accent); font-family: var(--mono); }

.card-actions { display: flex; gap: 0.4rem; margin-top: auto; }
.remove-btn {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  border: 1px solid var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  font-size: 1rem;
  line-height: 1;
  z-index: 5;
}
.card.stale { outline: 2px solid var(--amber); }

/* --------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 2rem;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.modal-head {
  background: var(--nav-bg);
  color: #fff;
  border-radius: 8px 8px 0 0;
  padding: 0.7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-head .close { background: none; border: 0; color: #9ca3af; font-size: 1.3rem; }
.modal-body { padding: 1rem; }

/* ------------------------------------------------------------ search hits */
.hit {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}
.hit img { width: 44px; height: 44px; object-fit: contain; }
.hit .hit-main { flex: 1; min-width: 0; }
.hit .hit-name { font-size: 0.85rem; font-weight: 600; }
.hit .hit-meta { font-size: 0.75rem; color: var(--text-muted); }

/* --------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
}
.table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border-faint); vertical-align: middle; }
.table .mono { font-family: var(--mono); }

/* --------------------------------------------------------------- events */
.event {
  display: flex;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius);
  margin-bottom: 0.45rem;
  align-items: baseline;
}
.event.unseen { background: var(--accent-soft); border-color: #dfe3ff; }
.event .when { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }

/* ---------------------------------------------------------- voucher bits */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.4rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-muted);
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.voucher-value { font-family: var(--mono); font-weight: 700; }
.problems { background: var(--amber-soft); border: 1px solid #ffe69c; border-radius: var(--radius); padding: 0.5rem 0.75rem; font-size: 0.82rem; margin-bottom: 0.6rem; }
.rawtext { font-family: var(--mono); font-size: 0.72rem; white-space: pre-wrap; background: var(--surface-muted); border-radius: var(--radius); padding: 0.6rem; max-height: 160px; overflow-y: auto; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.8rem; }
.form-grid .full { grid-column: 1 / -1; }
.field-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.2rem; display: block; }

/* ---------------------------------------------------------------- login */
.auth-wrap { max-width: 380px; margin: 8vh auto; padding: 0 1rem; }
.auth-card { border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08); }
.auth-brand { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; text-align: center; margin-bottom: 1rem; }
.auth-brand span { color: #e2483d; }

.muted { color: var(--text-muted); }
.small { font-size: 0.8rem; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.section-title { font-size: 1.05rem; font-weight: 650; margin: 0 0 0.7rem; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; background: #fff; }

.toast-wrap { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--nav-bg);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
}
.toast.err { background: var(--red); }
