/* ---- Design tokens -------------------------------------------------- */
:root {
  --bg: #0a0e13;
  --bg-panel: #111820;
  --bg-panel-raised: #161f2a;
  --line: #223041;
  --line-soft: #1a2530;
  --text: #e7edf3;
  --text-dim: #8ea0b3;
  --text-faint: #576877;

  --signal: #35e0c2;      /* thiet bi hoat dong / bao hanh */
  --signal-dim: #1c6f60;
  --amber: #f2b13d;       /* trial */
  --amber-dim: #7a5a1d;
  --red: #ff6363;         /* het han / loi */
  --red-dim: #7a2e2e;
  --blue: #5b9dff;        /* thong tin trung tinh */

  --radius: 8px;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

/* ---- Signal-bar brand mark ------------------------------------------ */
.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 26px;
}
.brand-mark span {
  width: 5px;
  display: block;
  background: var(--signal);
  border-radius: 1px;
  animation: pulse 1.8s ease-in-out infinite;
}
.brand-mark span:nth-child(1) { height: 8px; animation-delay: 0s; }
.brand-mark span:nth-child(2) { height: 14px; animation-delay: .15s; }
.brand-mark span:nth-child(3) { height: 20px; animation-delay: .3s; }
.brand-mark span:nth-child(4) { height: 26px; animation-delay: .45s; }
@keyframes pulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark span { animation: none; opacity: 1; }
}

/* ---- Login ------------------------------------------------------------ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(53,224,194,.08), transparent),
    var(--bg);
}
.login-card {
  width: 340px;
  padding: 32px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: .06em; font-size: 15px; }
.brand-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 6px; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 6px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--signal); box-shadow: 0 0 0 2px rgba(53,224,194,.15); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}
button.primary, .login-card button[type="submit"] {
  background: var(--signal);
  color: #04211c;
}
button.primary:hover, .login-card button[type="submit"]:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--line); }
button.ghost:hover { color: var(--text); border-color: var(--text-dim); }
button.danger { background: var(--red-dim); color: #ffe4e4; }
button:disabled { opacity: .5; cursor: not-allowed; }

.error-text { color: var(--red); font-size: 12px; }

/* ---- App shell --------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar .brand { margin-bottom: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 13px;
}
.nav button:hover { background: var(--bg-panel-raised); color: var(--text); }
.nav button.active { background: var(--bg-panel-raised); color: var(--signal); }
.sidebar-footer { margin-top: auto; font-size: 12px; color: var(--text-faint); display: flex; flex-direction: column; gap: 8px; }

.main { padding: 26px 32px 60px; overflow-x: hidden; }
.page-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-title { font-size: 19px; font-weight: 700; }
.page-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; }

/* ---- Stat cards --------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .value { font-family: var(--mono); font-size: 24px; font-weight: 700; }
.stat-card .label { color: var(--text-dim); font-size: 12px; margin-top: 4px; }
.stat-card.signal .value { color: var(--signal); }
.stat-card.amber .value { color: var(--amber); }
.stat-card.red .value { color: var(--red); }

/* ---- Panels / tables ----------------------------------------------------- */
.panel { background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-body { padding: 14px 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-faint); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; color: var(--text-dim); background: rgba(255,255,255,.06); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.warranty_active { color: var(--signal); background: rgba(53,224,194,.12); }
.badge.trial { color: var(--amber); background: rgba(242,177,61,.12); }
.badge.expired, .badge.blocked { color: var(--red); background: rgba(255,99,99,.12); }
.badge.not_shipped { color: var(--text-dim); background: rgba(255,255,255,.06); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.dropzone.drag-over { border-color: var(--signal); background: rgba(53,224,194,.06); color: var(--text); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { min-width: 160px; }

.empty-state { padding: 30px 16px; text-align: center; color: var(--text-faint); }

/* ---- Modal ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,7,10,.6);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px;
  z-index: 50;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px;
  width: 100%; max-width: 560px; padding: 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 15px; }
.modal .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); grid-column: span 1; }
.modal .grid label.full { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--bg-panel-raised);
  border: 1px solid var(--line); border-left: 3px solid var(--signal);
  padding: 12px 16px; border-radius: 6px; font-size: 13px; z-index: 60;
  max-width: 320px;
}
.toast.error { border-left-color: var(--red); }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 10px 16px; font-size: 12px; color: var(--text-dim); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 10; flex-direction: row; align-items: center; overflow-x: auto; }
  .nav { flex-direction: row; }
  .sidebar-footer { display: none; }
}
