/* ============================================================
   admin.css — dashboard theme (dark, monochrome SaaS look)
   ============================================================ */

:root {
  --bg: #0b0c10;
  --panel: #14151b;
  --panel-2: #191a22;
  --border: #24252f;
  --text-0: #f2f3f7;
  --text-1: #9296a6;
  --text-2: #5b5e6c;
  --up: #4fd18b;
  --down: #ef5163;
  --accent: #e9eaf0;

  --milspec: #4b69ff;
  --restricted: #8847ff;
  --classified: #d32ce6;
  --covert: #eb4b4b;
  --gold: #e4ae39;

  --radius: 12px;
  --font: 'Inter', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-0);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font-family: inherit; }
a { color: inherit; }

/* ---------------- Login screen ---------------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 500px at 20% 0%, #171923 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 34px 26px;
}
.login-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.login-icon svg { width: 20px; height: 20px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-1); font-size: 13.5px; margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--text-1); margin-bottom: 6px; }
.field input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text-0); padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
.field input:focus-visible { outline: 2px solid var(--text-0); outline-offset: 1px; }
.login-submit {
  width: 100%; margin-top: 6px;
  background: var(--accent); color: #0b0c10; border: none;
  padding: 11px; border-radius: 8px; font-weight: 600; font-size: 14px;
}
.login-error {
  color: var(--down); font-size: 12.5px; margin-top: 10px; min-height: 16px;
}
.login-back { display: block; text-align: center; margin-top: 18px; color: var(--text-2); font-size: 12.5px; }

/* ---------------- Dashboard shell ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  padding-top: max(18px, env(safe-area-inset-top));
  display: flex; flex-direction: column;
}
.sb-logo { display: flex; align-items: center; gap: 9px; padding: 6px 8px 18px; font-weight: 700; font-size: 15px; }
.sb-logo .sq { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); }
.sb-section { color: var(--text-2); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; margin: 14px 8px 8px; }
.sb-nav { list-style: none; margin: 0; padding: 0; }
.sb-nav li a, .sb-nav li button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; color: var(--text-1);
  font-size: 13.5px; border: none; background: transparent; text-align: left;
}
.sb-nav li a:hover, .sb-nav li button:hover { background: var(--panel-2); color: var(--text-0); }
.sb-nav li.active a, .sb-nav li.active button { background: var(--panel-2); color: var(--text-0); }
.sb-nav svg { width: 16px; height: 16px; flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.admin-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.admin-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; }
.admin-chip .who { font-size: 13px; }
.admin-chip .who .name { font-weight: 600; }
.admin-chip .who .role { color: var(--text-2); font-size: 11.5px; }
.logout-btn { margin-top: 10px; width: 100%; background: var(--panel-2); border: 1px solid var(--border); color: var(--text-1); padding: 8px; border-radius: 8px; font-size: 12.5px; }
.logout-btn:hover { color: var(--text-0); }

.main { flex: 1 1 auto; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .sub { color: var(--text-1); font-size: 13px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 10px; }
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text-0);
  padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  touch-action: manipulation;
}
.btn:hover { border-color: #34364266; background: var(--panel-2); }
.btn.primary { background: var(--accent); color: #0b0c10; border-color: transparent; }
.btn.danger { color: var(--down); }
.btn:focus-visible { outline: 2px solid var(--text-0); outline-offset: 2px; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.content { padding: 24px 26px 60px; }

/* stat cards */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label { color: var(--text-1); font-size: 12.5px; }
.stat-card .value { font-size: 24px; font-weight: 700; margin-top: 8px; }
.stat-card .delta { font-size: 12px; margin-top: 8px; }
.stat-card .delta.up { color: var(--up); }
.stat-card .delta.warn { color: var(--down); }

/* panels */
.panel-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px;
}
.panel h2 { font-size: 14px; margin: 0 0 12px; }

.case-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.case-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 9px 10px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; color: var(--text-1); cursor: pointer;
}
.case-list li:hover { background: var(--panel-2); }
.case-list li.active { background: var(--panel-2); border-color: var(--border); color: var(--text-0); }
.case-list li .cl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-list li .cl-del { background: none; border: none; color: var(--text-2); font-size: 15px; line-height: 1; padding: 2px 4px; }
.case-list li .cl-del:hover { color: var(--down); }
.add-case-row { display: flex; gap: 6px; margin-top: 12px; }
.add-case-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text-0);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; min-width: 0;
}

.case-meta { display: flex; gap: 16px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.mini-field label { display: block; font-size: 11.5px; color: var(--text-1); margin-bottom: 5px; }
.mini-field input {
  background: var(--bg); border: 1px solid var(--border); color: var(--text-0);
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; width: 200px;
}
.mini-field.price input { width: 120px; }
.case-img-row { display: flex; gap: 8px; align-items: flex-start; }

.odds-summary { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 13px; }
.odds-badge { padding: 5px 10px; border-radius: 999px; font-weight: 600; font-variant-numeric: tabular-nums; }
.odds-badge.ok { background: rgba(79,209,139,0.12); color: var(--up); }
.odds-badge.bad { background: rgba(239,81,99,0.12); color: var(--down); }

table.items-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13.5px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.items-table th {
  text-align: left; color: var(--text-2); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.items-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.items-table tr:last-child td { border-bottom: none; }
.items-table input[type="text"] {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text-0);
  padding: 7px 9px; border-radius: 7px; font-size: 13px;
}
.items-table input[type="number"] {
  width: 84px; background: var(--bg); border: 1px solid var(--border); color: var(--text-0);
  padding: 7px 9px; border-radius: 7px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.items-table select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text-0);
  padding: 7px 9px; border-radius: 7px; font-size: 13px;
}
.rarity-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.img-thumb {
  width: 48px; height: 48px; border-radius: 8px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.img-ph svg { width: 18px; height: 18px; }
.img-actions { display: flex; flex-direction: column; gap: 4px; width: 64px; }
.img-actions .btn { width: 100%; padding: 4px 6px; }
.row-del { background: none; border: none; color: var(--text-2); font-size: 16px; padding: 4px 8px; border-radius: 6px; }
.row-del:hover { color: var(--down); background: var(--panel-2); }
.table-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; }
.empty-state { color: var(--text-2); font-size: 13px; padding: 26px 4px; text-align: center; }

.save-status {
  font-size: 12.5px;
  color: var(--text-2);
  align-self: center;
  white-space: nowrap;
}
.save-status.pending { color: var(--text-1); }
.save-status.saving  { color: var(--text-1); }
.save-status.saved   { color: var(--up); }
.save-status.error   { color: var(--down); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text-0);
  padding: 10px 18px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }

  /* The sidebar becomes a horizontally-scrollable toolbar instead of
     disappearing — logout, "view store" and reset stay reachable on
     a phone, they just sit in a row instead of a column. */
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sb-logo { padding: 4px 8px 4px 2px; flex: 0 0 auto; }
  .sb-section { display: none; }
  .sb-nav {
    display: flex;
    flex-direction: row;
    gap: 4px;
    flex: 0 0 auto;
  }
  .sb-nav li a, .sb-nav li button { width: auto; white-space: nowrap; padding: 8px 10px; }
  .sidebar-foot {
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
    border-top: none;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .admin-chip { padding: 4px; }
  .admin-chip .who .role { display: none; }
  .logout-btn { margin-top: 0; width: auto; white-space: nowrap; }
}

@media (max-width: 700px) {
  .topbar { padding: 16px 18px; flex-wrap: wrap; gap: 10px; }
  .content { padding: 18px 16px 50px; }
  .case-meta { align-items: stretch; }
  .mini-field { flex: 1 1 140px; }
  .mini-field input { width: 100%; }
  .mini-field.price input { width: 100%; }
  .odds-summary { margin-left: 0; width: 100%; flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
  .admin-chip .who { display: none; }
  .sb-logo-text { display: none; }
}
