:root {
  --bg: #0e1420;
  --bg-elevated: #161d2e;
  --card: #1a2235;
  --card-border: #2a3348;
  --ink-navy: #232e46;
  --ink-navy-2: #2d3a58;
  --ink-c: #22c3e6;
  --ink-m: #ff5c8a;
  --ink-y: #ffcb3d;
  --ink-k: #e7ebf3;
  --line: #2a3348;
  --text: #e7ebf3;
  --muted: #8892a8;
  --danger: #ff6b6b;
  --danger-bg: rgba(255,107,107,0.12);
  --success: #35d68e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 32px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(34,195,230,0.07), transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(255,92,138,0.06), transparent 40%);
  color: var(--text);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--line);
  color: #fff;
  padding: 16px 24px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 12px; }
.app-icon { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; }
.brand-text h1 { font-size: 26px; color: #fff; line-height: 1; }

main {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 20px 80px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
main:has(#loginView:not([hidden])) {
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
}

/* ---------- Login ---------- */
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 0 12px;
  text-align: center;
  animation: fadeUp 0.35s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.eyebrow {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-c);
  margin: 0 0 6px;
}
.particle-anim {
  display: block;
  margin: 0 auto 8px;
}
.login-card h2 { font-size: 24px; margin-bottom: 0; color: #fff; }
#otpStep h2 { margin-bottom: 20px; }
#requestStep .primary-btn { margin-top: 32px; }
#otpStep label { margin-top: 0; }
#otpStep .primary-btn { margin-top: 28px; }
.current-qty-line {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}
.current-qty-line strong { color: var(--ink-c); font-size: 15px; }
.resend-line {
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.resend-link {
  color: var(--ink-c);
  text-decoration: none;
  font-weight: 600;
}
.resend-link:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 16px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 15px;
  background: var(--bg-elevated);
  color: var(--text);
}
input:focus {
  outline: none;
  border-color: var(--ink-c);
  box-shadow: 0 0 0 3px rgba(34,195,230,0.18);
}

/* ---------- OTP segmented digits ---------- */
.otp-digits {
  display: flex;
  gap: 8px;
}
.otp-digit {
  width: 100%;
  aspect-ratio: 1 / 1;
  text-align: center;
  font-size: 22px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  border: 1px solid #3d4a68;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0;
}
.otp-digit:focus {
  outline: none;
  border-color: var(--ink-c);
  box-shadow: 0 0 0 3px rgba(34,195,230,0.18);
}
.otp-digit.filled {
  border-color: var(--ink-c);
}
.otp-digits.shake {
  animation: shake 0.4s ease;
}
.otp-digits.shake .otp-digit {
  border-color: var(--danger);
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
.otp-digits.success .otp-digit {
  border-color: var(--success);
  color: var(--success);
}

.primary-btn {
  background: var(--ink-c);
  color: #06141f;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-top: 16px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.primary-btn:hover { filter: brightness(1.1); }
.primary-btn:active { transform: scale(0.98); }
.primary-btn:disabled { opacity: 0.5; cursor: default; }
.primary-btn.small { margin-top: 0; padding: 9px 14px; font-size: 14px; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:hover { background: var(--bg-elevated); }

.status-line {
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}
.status-line.ok { color: var(--success); }
.status-line.error { color: var(--danger); }

/* ---------- Main view ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-pill {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 13px;
  word-spacing: 2px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--muted);
}
.toolbar .primary-btn.small { margin-left: auto; }

.table-wrap { overflow-x: hidden; padding: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
thead th {
  text-align: left;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 2px solid var(--line);
}
th.num, td.num { text-align: right; }
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
tbody tr { cursor: pointer; }
tbody tr:active { background: rgba(34,195,230,0.06); }
@media (hover: hover) {
  tbody tr:hover { background: rgba(34,195,230,0.05); }
}
tbody tr.low-stock .qty-badge { color: var(--danger); font-weight: 600; }

.actions-col { width: 64px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 7px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  font-family: inherit;
}
.icon-btn:hover { background: var(--ink-navy); }
.icon-btn.danger:hover { background: var(--danger-bg); border-color: rgba(255,107,107,0.35); color: var(--danger); }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
  margin: 0;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4,8,16,0.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 10;
}
.modal { width: 100%; max-width: 380px; padding: 24px; }

.detail-modal {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.detail-value {
  font-size: 18px;
  color: #fff;
  word-break: break-word;
}
.modal h3 { color: #fff; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px;
}

[hidden] { display: none !important; }

@media (max-width: 480px) {
  .brand-text h1 { font-size: 21px; }
  .app-icon { width: 32px; height: 32px; }
  .login-card { padding: 0 8px; }
  .toolbar .primary-btn.small { margin-left: auto; width: auto; }
  .otp-digit { font-size: 18px; }
  table { font-size: 12.5px; }
  thead th { padding: 8px 6px; font-size: 10.5px; }
  tbody td { padding: 9px 6px; }
  .actions-col { width: 56px; }
  .icon-btn { padding: 4px 5px; font-size: 12px; }
  .modal-overlay { padding: 0; align-items: stretch; }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    box-shadow: none;
    border: none;
  }
}
