﻿:root {
  --bg: #07101f;
  --panel: #0d172f;
  --panel-2: #131f38;
  --card: #111c2f;
  --text: #e9f2ff;
  --muted: #9fb8d8;
  --line: rgba(148, 163, 184, 0.16);
  --primary: #3b82f6;
  --primary-2: #0ea5e9;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius: 20px;
  --shadow: 0 24px 60px rgba(0,0,0,.35);
  --focus: 0 0 0 3px rgba(59,130,246,.25);
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }
html, body {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(59,130,246,.14), transparent 22%),
    radial-gradient(circle at 80% 0%, rgba(96,165,250,.1), transparent 24%),
    linear-gradient(180deg, #050a13 0%, #07101f 100%);
  color: var(--text);
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(15,23,42,.92);
  border: 1px solid var(--line);
  color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus {
  outline: none;
  box-shadow: var(--focus);
  border-color: rgba(59,130,246,.65);
}
label span {
  display:block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

#app { min-height: 100vh; min-width: 0; overflow-x: clip; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display:flex; gap: 16px; align-items:center; justify-content:space-between;
  padding: 18px 22px;
  background: rgba(6,10,20,.85);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.05);
}
.brand { display:flex; align-items:center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 16px;
  display:grid; place-items:center;
  background: linear-gradient(145deg, var(--primary), var(--primary-2));
  color: white; font-weight: 800; letter-spacing: .08em;
  box-shadow: 0 16px 40px rgba(59,130,246,.24);
}
.brand-title { font-size: 15px; font-weight: 800; }
.brand-subtitle { font-size: 12px; color: var(--muted); }

.topnav { display:flex; flex-wrap: wrap; gap: 10px; align-items:center; justify-content:center; }
.topnav a {
  padding: 10px 16px; border-radius: 999px; color: var(--muted);
  background: rgba(255,255,255,.04);
  border: 1px solid transparent;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.topnav a.active {
  color: var(--text); background: rgba(59,130,246,.16);
  border-color: rgba(59,130,246,.25);
}

.topbar-actions { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; }

.main-grid {
  width: min(1440px, calc(100vw - 28px));
  margin: 16px auto 28px;
  display:grid; gap: 16px;
}

.hero-card, .panel, .card, .auth-card, .modal {
  background: linear-gradient(180deg, rgba(15,23,42,.98), rgba(11,17,31,.95));
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: var(--shadow);
}

.hero-card {
  border-radius: 26px;
  padding: 28px;
  display:grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 22px;
}
.eyebrow { text-transform: uppercase; letter-spacing: .18em; color: #93c5fd; font-size: 11px; }
.hero-card h1 { margin: 10px 0 8px; font-size: clamp(26px, 4vw, 44px); line-height: 1.05; }
.hero-copy { color: var(--muted); line-height: 1.65; max-width: 64ch; }

.hero-stats, .status-row {
  display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
}
.stat, .status-chip, .info-card {
  border-radius: 22px; background: rgba(7,12,24,.62); border: 1px solid rgba(255,255,255,.06);
}
.stat { padding: 18px; }
.stat .label { color: var(--muted); font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 10px; }

.status-chip {
  padding: 16px; display:flex; flex-direction:column; gap: 6px;
}
.status-chip strong { font-size: 15px; }
.status-chip span { color: var(--muted); font-size: 12px; }

.view-root { display:grid; grid-template-columns:minmax(0,1fr); gap: 18px; min-width: 0; }

.panel { border-radius: 24px; padding: 20px; min-width: 0; }
.panel-header {
  display:flex; justify-content:space-between; gap: 14px; align-items:flex-start; margin-bottom: 18px;
}
.panel-header h2, .panel-header h3 { margin: 0; }
.panel-header p { margin: 8px 0 0; color: var(--muted); }

.grid-2 { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }

.card { border-radius: 22px; padding: 18px; }
.card h3, .card h4 { margin-top: 0; }
.card .muted { color: var(--muted); }

.toolbar {
  display:flex; flex-wrap: wrap; gap: 10px; align-items:center; justify-content:space-between; margin-bottom: 14px;
}
.toolbar .left, .toolbar .right { display:flex; flex-wrap: wrap; gap: 10px; align-items:center; }

.btn {
  border: 1px solid transparent; background: rgba(37,99,235,.95); color: white;
  padding: 12px 16px; border-radius: 14px; font-weight: 700;
  transition: transform .16s ease, filter .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn.primary { background: linear-gradient(145deg, var(--primary), var(--primary-2)); }
.btn.ghost { background: rgba(15,23,42,.88); border-color: rgba(255,255,255,.08); color: var(--text); }
.btn.danger { background: rgba(239,68,68,.92); }
.btn.small { padding: 9px 12px; font-size: 13px; border-radius: 12px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid rgba(255,255,255,.06);
  background: rgba(15,23,42,.94); color: var(--text);
}

.badge, .chip {
  display:inline-flex; align-items:center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; border: 1px solid rgba(255,255,255,.08); background: rgba(7,12,24,.55);
}
.badge.ok { color: #86efac; border-color: rgba(34,197,94,.22); }
.badge.damaged { color: #fda4af; border-color: rgba(239,68,68,.22); }
.badge.retire { color: #fca5a5; border-color: rgba(239,68,68,.26); }
.badge.warn { color: #fde68a; border-color: rgba(245,158,11,.22); }
.badge.info { color: #93c5fd; border-color: rgba(59,130,246,.22); }

.table-wrap {
  min-width: 0; overflow:auto; border-radius: 20px; border: 1px solid rgba(255,255,255,.06); background: rgba(7,12,24,.45);
}
table {
  width: 100%; border-collapse: collapse; min-width: 720px; background: rgba(7,12,24,.55);
}
.inventory-table { min-width: 1280px; }
thead th {
  position: sticky; top: 0; background: rgba(13,19,33,.98); border-bottom: 1px solid rgba(255,255,255,.08);
}
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid rgba(148,163,184,.12); }
tbody tr:hover { background: rgba(59,130,246,.08); }
th.sortable { cursor: pointer; }
td.actions { display:flex; gap: 8px; flex-wrap: wrap; }

.form-grid { display:grid; gap: 14px; }
.form-row { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-row.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.help { color: var(--muted); font-size: 12px; }
textarea { min-height: 100px; resize: vertical; }

details.modular {
  border: 1px solid rgba(255,255,255,.08); border-radius: 20px; background: rgba(7,12,24,.42); padding: 14px 16px;
}
details.modular summary { cursor: pointer; list-style: none; font-weight: 700; position: relative; padding-left: 28px; }
details.modular summary::before {
  content: "";
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border-radius: 999px; background: rgba(59,130,246,.35);
}
details.modular summary::-webkit-details-marker { display: none; }
details.modular[open] { background: rgba(7,12,24,.55); }

.tree { display:grid; gap: 10px; }
.tree-item {
  display:flex; justify-content:space-between; gap: 12px; align-items:center;
  padding: 14px 16px; border-radius: 18px; border: 1px solid rgba(255,255,255,.06); background: rgba(7,12,24,.5);
}
.tree-item strong { display:block; }
.tree-item small { color: var(--muted); }
.indent-1 { margin-left: 20px; }
.indent-2 { margin-left: 40px; }

.auth-card {
  width: min(520px, calc(100vw - 24px)); margin: 8vh auto; padding: 28px; border-radius: 24px;
}
.auth-panel h1 { margin-bottom: 10px; }
.auth-badge {
  display:inline-flex; padding: 6px 10px; border-radius: 999px; background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.22); color: #bfdbfe; font-size: 12px; margin-bottom: 10px;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,.8); display:grid; place-items:center; padding: 14px; z-index: 80;
}
.modal { width: min(920px, 100%); border-radius: 24px; overflow:hidden; }
.modal-header {
  display:flex; justify-content:space-between; gap: 12px; align-items:flex-start; padding: 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.scanner-body { display:grid; gap: 12px; padding: 18px; }
#scan-video {
  width: 100%; max-height: 56vh; border-radius: 18px; background: #020617;
  border: 1px solid rgba(255,255,255,.08); object-fit: cover;
}
.manual-scan { display:grid; grid-template-columns: 1fr auto; gap: 10px; }
.modal-actions { display:flex; gap: 10px; justify-content:flex-end; flex-wrap: wrap; }

.empty-state {
  padding: 24px; text-align: center; color: var(--muted); border: 1px dashed rgba(255,255,255,.1);
  border-radius: 18px; background: rgba(7,12,24,.35);
}

.kpi-list { display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; }

@media (max-width: 1120px) {
  .hero-card, .grid-2, .grid-3, .kpi-list, .hero-stats, .status-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-actions, .topnav { justify-content: space-between; }
  .hero-card, .grid-2, .grid-3, .kpi-list, .hero-stats, .status-row, .form-row, .form-row.three { grid-template-columns: 1fr; }
  table { min-width: 100%; }
  .inventory-table { min-width: 0; table-layout: fixed; }
  .inventory-table thead { display: none; }
  .inventory-table, .inventory-table tbody, .inventory-table tr, .inventory-table td { display: block; width: 100%; }
  .inventory-table tbody { display: grid; gap: 10px; }
  .inventory-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    overflow: hidden;
  }
  .inventory-table tbody td {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    padding: 10px 12px;
    overflow-wrap: anywhere;
  }
  .inventory-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
  }
  .inventory-table tbody td:first-child,
  .inventory-table tbody td.actions,
  .inventory-table tbody td[colspan] { grid-column: 1 / -1; }
  .inventory-table tbody td.actions { flex-direction: row; flex-wrap: wrap; }
  .inventory-table tbody td.actions::before,
  .inventory-table tbody td[colspan]::before { content: none; }
}
@media (max-width: 560px) {
  .main-grid { width: min(100vw - 16px, 100vw); }
  .hero-card, .panel, .card, .auth-card { border-radius: 18px; }
  .topnav a { padding: 9px 12px; }
  .btn, input, select, textarea { border-radius: 12px; }
}
