/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:          #0f1b2d;
  --navy-mid:      #1a2d45;
  --navy-light:    #243d5c;
  --accent:        #2dd4bf;
  --accent-dim:    rgba(45,212,191,0.14);
  --accent-glow:   rgba(45,212,191,0.28);
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;
  --surface:       #162030;
  --surface2:      #1e2e42;
  --surface3:      #253649;
  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.13);
  --border-accent: rgba(45,212,191,0.25);
  --red:           #f87171;
  --red-dim:       rgba(248,113,113,0.14);
  --green:         #4ade80;
  --green-dim:     rgba(74,222,128,0.14);
  --amber:         #fbbf24;
  --amber-dim:     rgba(251,191,36,0.14);
  --radius:        10px;
  --radius-lg:     14px;
  --font:          'DM Sans', sans-serif;
  --mono:          'DM Mono', monospace;
}

html, body { height: 100%; }
body { font-family: var(--font); background: var(--navy); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
code { font-family: var(--mono); background: var(--surface2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 1.75rem; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sidebar-header {
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-title { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sidebar-sub   { font-size: 11px; color: var(--text-muted); }
.sidebar-nav   { flex: 1; padding: 0.75rem; overflow-y: auto; }
.nav-section-label {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.6rem 0.5rem 0.3rem;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text-muted); font-size: 13px;
  cursor: pointer; transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 8px; opacity: 0.5; }
.nav-item.active .nav-icon { opacity: 1; color: var(--accent); }

.sidebar-footer { padding: 0.75rem; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--radius);
  background: var(--surface2);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid var(--border-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent); flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text-muted); display: flex; align-items: center; justify-content: center;
  font-size: 11px; cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.btn-logout:hover { color: var(--red); border-color: rgba(248,113,113,0.3); background: var(--red-dim); }

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-sub   { font-size: 12px; color: var(--text-muted); }

/* ── Logo mark ───────────────────────────────────────────────────────────── */
.logo-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent); color: var(--navy);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-mark.sm { width: 28px; height: 28px; font-size: 13px; border-radius: 7px; }
.logo-name { font-size: 17px; font-weight: 600; }
.logo-sub  { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  font-family: var(--font); font-size: 13px; font-weight: 500;
  padding: 9px 17px; border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer;
  transition: all 0.16s;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; background: transparent; color: var(--text);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary  { background: var(--accent); color: var(--navy); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover  { background: #14b8a6; border-color: #14b8a6; transform: translateY(-1px); }
.btn-ghost    { color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border-hover); }
.btn-danger   { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.25); }
.btn-danger:hover { background: rgba(248,113,113,0.25); }
.btn-sm  { padding: 6px 11px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 7px; }
.btn-full { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.1rem; }
.form-label  { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.04em; text-transform: uppercase; }
.form-input, .form-select {
  font-family: var(--font); font-size: 14px;
  background: var(--navy); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 9px 13px; outline: none; width: 100%;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-dim); }
.form-select option { background: var(--navy-mid); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint  { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--red); margin-top: 4px; display: none; }
.form-error.show { display: block; }

/* ── Panels / Cards ──────────────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 1rem;
}
.panel-header {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-title { font-size: 13px; font-weight: 600; }
.panel-body  { padding: 1.2rem; }

/* ── Stats Row ───────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.stat-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 5px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.c-accent { color: var(--accent); }
.c-green  { color: var(--green); }
.c-amber  { color: var(--amber); }
.c-red    { color: var(--red); }
.c-muted  { color: var(--text-muted); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
}
.badge-green  { background: var(--green-dim); color: var(--green); }
.badge-red    { background: var(--red-dim); color: var(--red); }
.badge-amber  { background: var(--amber-dim); color: var(--amber); }
.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-grey   { background: var(--surface3); color: var(--text-muted); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 8px 13px;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.data-table td { padding: 10px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.data-table th:last-child,
.data-table td:last-child { text-align: right; }

/* ── Stock Roll Cards ────────────────────────────────────────────────────── */
.roll-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 0.9rem;
  overflow: hidden;
  transition: border-color 0.18s;
}
.roll-card:hover   { border-color: var(--border-hover); }
.roll-card.depleted { border-color: rgba(248,113,113,0.22); }

.roll-header {
  padding: 0.9rem 1.2rem;
  display: flex; align-items: center; gap: 11px;
  background: var(--surface2);
  border-bottom: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.roll-header:hover  { background: var(--surface3); }
.roll-body-open .roll-header { border-bottom-color: var(--border); }

.roll-po {
  font-family: var(--mono); font-size: 12px; color: var(--accent);
  background: var(--accent-dim); padding: 3px 9px;
  border-radius: 6px; border: 1px solid var(--border-accent);
  white-space: nowrap; flex-shrink: 0;
}
.roll-meta { flex: 1; min-width: 0; }
.roll-name   { font-weight: 600; font-size: 14px; }
.roll-detail { font-size: 11px; color: var(--text-muted); }
.roll-meters { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.meters-remaining { font-size: 20px; font-weight: 700; line-height: 1; }
.meters-total { font-size: 10px; color: var(--text-dim); }
.progress-bar { height: 3px; background: var(--surface3); border-radius: 2px; width: 110px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; transition: width 0.35s ease; }
.roll-chevron { color: var(--text-dim); font-size: 11px; flex-shrink: 0; transition: transform 0.2s; }

.roll-body { display: none; }
.roll-body.open { display: block; }

.roll-actions-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.depleted-notice {
  padding: 9px 1.2rem;
  background: var(--red-dim);
  border-bottom: 1px solid rgba(248,113,113,0.18);
  font-size: 12px; color: var(--red); font-weight: 500;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  padding: 1.6rem;
  position: relative;
  animation: slideUp 0.2s ease;
}
.modal-sm { max-width: 380px; }
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 1.3rem; }
.modal-close {
  position: absolute; top: 1.1rem; right: 1.1rem;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-muted); width: 26px; height: 26px;
  border-radius: 7px; cursor: pointer; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); background: var(--surface3); }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 1.4rem; }
.modal-info {
  background: var(--surface2); border-radius: var(--radius);
  padding: 9px 13px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── Audit Log ───────────────────────────────────────────────────────────── */
.audit-filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 1.2rem; align-items: flex-end;
}
.audit-filters .form-group { margin-bottom: 0; }
.audit-action-badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 5px; font-size: 11px; font-weight: 600; font-family: var(--mono);
}
.action-create  { background: var(--green-dim); color: var(--green); }
.action-delete  { background: var(--red-dim); color: var(--red); }
.action-login   { background: var(--accent-dim); color: var(--accent); }
.action-logout  { background: var(--surface3); color: var(--text-muted); }
.action-default { background: var(--amber-dim); color: var(--amber); }
.json-preview {
  font-family: var(--mono); font-size: 11px; color: var(--text-muted);
  max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pagination { display: flex; gap: 6px; align-items: center; margin-top: 1rem; justify-content: flex-end; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; top: 1.2rem; right: 1.2rem; z-index: 999; display: flex; flex-direction: column; gap: 7px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 15px;
  font-size: 13px;
  display: flex; align-items: center; gap: 9px;
  min-width: 240px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  animation: slideIn 0.22s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }
.toast.out { animation: slideOut 0.22s ease forwards; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.empty-state { padding: 3rem 2rem; text-align: center; }
.empty-icon  { font-size: 2rem; margin-bottom: 0.75rem; }
.empty-text  { font-size: 14px; color: var(--text-muted); }
.empty-sub   { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.loading-spinner { padding: 3rem; text-align: center; color: var(--text-dim); }
.search-wrap { position: relative; }
.search-wrap input { padding-left: 34px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; font-size: 13px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0; }
.user-cell { display: flex; align-items: center; gap: 9px; }
.mini-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid var(--border-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--accent); flex-shrink: 0;
}
.alert { padding: 10px 13px; border-radius: var(--radius); font-size: 13px; margin-bottom: 1rem; }
.alert-error { background: var(--red-dim); border: 1px solid rgba(248,113,113,0.25); color: var(--red); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 1.2rem; flex-wrap: wrap; }

/* ── Login Page ──────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at 30% 20%, rgba(45,212,191,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(45,212,191,0.04) 0%, transparent 50%),
              var(--navy);
}
.login-wrap { width: 100%; max-width: 390px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
}
.login-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 1.75rem; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 1.1rem; }

/* ── Status Select ───────────────────────────────────────────────────────────── */
.status-select {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 26px 4px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  width: auto;
  transition: all 0.18s;
}
.status-select.status-allocated {
  background-color: var(--amber-dim);
  color: var(--amber);
  border-color: rgba(251,191,36,0.25);
}
.status-select.status-installed {
  background-color: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(45,212,191,0.25);
}
.status-select option {
  background: var(--navy-mid);
  color: var(--text);
  font-weight: 400;
}
.status-select:hover { filter: brightness(1.15); }

/* ── Force PW Change Toggle ──────────────────────────────────────────────────── */
.force-pw-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; width: 20px; height: 20px;
}
.force-pw-toggle input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.force-pw-check {
  width: 18px; height: 18px;
  border: 1.5px solid var(--border-hover);
  border-radius: 5px;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.force-pw-toggle input:checked + .force-pw-check {
  background: var(--amber-dim);
  border-color: rgba(251,191,36,0.5);
}
.force-pw-toggle input:checked + .force-pw-check::after {
  content: '';
  display: block;
  width: 5px; height: 9px;
  border: 2px solid var(--amber);
  border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px);
}
.force-pw-toggle:hover .force-pw-check { border-color: var(--amber); }

/* ── On Order Roll ───────────────────────────────────────────────────────────── */
.roll-card.on-order { border-color: rgba(251,191,36,0.3); }
.roll-card.on-order .roll-header { background: rgba(251,191,36,0.05); }
.on-order-banner {
  padding: 8px 1.2rem;
  background: var(--amber-dim);
  border-bottom: 1px solid rgba(251,191,36,0.2);
  font-size: 12px; color: var(--amber); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}

/* ── Purple badge (On Order) ─────────────────────────────────────────────────── */
.badge-purple { background: rgba(168,85,247,0.15); color: #c084fc; }
