:root {
  color-scheme: dark;
  --bg: #071017;
  --panel: rgba(17, 27, 38, .82);
  --panel-2: rgba(23, 35, 48, .72);
  --line: rgba(160, 176, 200, .14);
  --text: #f5f7fb;
  --muted: #aab4c4;
  --green: #63df42;
  --purple: #7758f6;
  --red: #ff5a5a;
  --amber: #ffb42b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 55% 5%, rgba(60, 130, 105, .13), transparent 32%), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
a { color: var(--green); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 28px 16px;
  border-right: 1px solid var(--line);
  background: rgba(4, 12, 20, .76);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand, .user { display: flex; align-items: center; gap: 14px; }
.brand-mark, .user span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), #2aa76c);
  color: white;
  font-weight: 800;
}
.brand strong { display: block; font-size: 30px; line-height: 1; }
.brand small, .user small { display: block; color: var(--muted); margin-top: 4px; }
nav { display: grid; gap: 8px; }
nav a {
  color: var(--text);
  padding: 14px 16px;
  border-radius: 8px;
}
nav a.active, nav a:hover { background: linear-gradient(135deg, #249f50, #74d84a); }
.user { margin-top: auto; border: 1px solid var(--line); padding: 14px; border-radius: 8px; }
.user span { width: 38px; height: 38px; }

main { margin-left: 250px; padding: 28px; }
.topbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.search {
  width: min(650px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 8px 16px;
}
.search input, .manual input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: 0;
}
input, select, textarea {
  min-width: 0;
}
button, .search button {
  border: 1px solid rgba(99, 223, 66, .55);
  background: linear-gradient(135deg, #209e48, #70d64a);
  color: white;
  padding: 11px 18px;
  border-radius: 8px;
  cursor: pointer;
}
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-color: var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 18px;
}
.logout { white-space: nowrap; }
.notice { border: 1px solid rgba(255, 180, 43, .35); background: rgba(255, 180, 43, .08); padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; color: #ffd48c; }
.notice.success { border-color: rgba(99, 223, 66, .35); background: rgba(99, 223, 66, .08); color: #bdf6ae; }
.notice.danger { border-color: rgba(255, 90, 90, .38); background: rgba(255, 90, 90, .08); color: #ffb4b4; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}
.auth-shell {
  width: min(420px, 100%);
  margin: 0;
  padding: 0;
}
.auth-card { padding: 28px; }
.auth-brand { margin-bottom: 24px; }
.auth-form { display: grid; gap: 16px; }
.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}
.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 14px 16px;
  outline: 0;
}
.auth-form .notice { margin: 0; }

.panel, .stat {
  background: linear-gradient(145deg, var(--panel), rgba(8, 17, 26, .88));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
}
.hero-grid { display: grid; grid-template-columns: minmax(420px, 1.4fr) 1fr; gap: 18px; }
.scanner { padding: 32px; text-align: center; }
h1 { margin: 0; font-size: 56px; line-height: 1; }
h1 span { color: var(--green); }
h2 { margin: 0; font-size: 20px; }
h3 { margin: 0 0 14px; font-size: 22px; }
p { color: var(--muted); }
.scan-frame {
  width: min(620px, 100%);
  aspect-ratio: 16 / 7;
  margin: 28px auto 18px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  background: rgba(5, 12, 20, .42);
  border: 3px solid var(--green);
  box-shadow: inset 0 0 40px rgba(99, 223, 66, .12), 0 0 40px rgba(99, 223, 66, .11);
}
.scan-submit {
  border-style: solid;
}
.scan-submit input {
  width: min(420px, 100%);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.05);
  color: var(--text);
  padding: 14px 16px;
  outline: 0;
}
.scan-frame.is-active { border-color: var(--purple); box-shadow: inset 0 0 40px rgba(119, 88, 246, .16), 0 0 40px rgba(119, 88, 246, .14); }
.barcode {
  width: 110px;
  height: 58px;
  background: repeating-linear-gradient(90deg, #dbe6f4 0 5px, transparent 5px 12px);
  opacity: .75;
}
.manual { display: flex; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; }
.manual input { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stat { padding: 24px; min-height: 140px; }
.stat span, .stat small { color: var(--muted); display: block; }
.stat strong { display: block; font-size: 42px; margin: 8px 0; }
.stat small { color: var(--green); }
.stat.danger strong, .stat.danger small { color: var(--red); }

.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.scan-list, .task-list { display: grid; gap: 10px; }
.scan-list div, .task-list div {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.scan-list small { grid-column: 2; color: var(--muted); }
.ok { color: var(--green); border: 1px solid var(--green); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; }
time { color: var(--muted); }
.task-list div { grid-template-columns: 1fr auto; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.task-list small { grid-column: 1; color: var(--muted); }
.task-list b { grid-column: 2; grid-row: 1 / span 2; background: rgba(255,255,255,.08); border-radius: 999px; padding: 6px 10px; }
.task-list .danger b { color: var(--red); }
.task-list .warning b { color: var(--amber); }
.asset-detail { display: grid; grid-template-columns: 170px 1fr; gap: 24px; align-items: center; }
.device-art { aspect-ratio: 16 / 10; border-radius: 8px; background: linear-gradient(150deg, #1f5dff, #03101d 54%, #c8d0da 55%); border: 1px solid var(--line); }
dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 18px; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions button { background: rgba(255,255,255,.04); border-color: var(--line); }
.peripheral-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.peripheral { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 8px; }
.device-art.small { width: 88px; }
.peripheral small, .muted { color: var(--muted); }
.peripheral span { color: var(--red); font-size: 13px; }
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  gap: 18px;
  align-items: start;
}
.side-stack { display: grid; gap: 18px; }
.filter-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, .35fr) auto;
  gap: 10px;
  margin-bottom: 16px;
}
.filter-row input, .filter-row select, .compact-form input, .compact-form select, .compact-form textarea, .import-item input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 12px 14px;
  outline: 0;
}
.compact-form textarea { resize: vertical; }
.compact-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}
.danger-zone {
  border-top: 1px solid rgba(255, 90, 90, .28);
  padding-top: 14px;
}
.danger-zone button {
  border-color: rgba(255, 90, 90, .55);
  background: rgba(255, 90, 90, .12);
  color: #ffb4b4;
}
.compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  background: rgba(255,255,255,.03);
}
td small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
tr:last-child td { border-bottom: 0; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  padding: 4px 9px;
  font-size: 13px;
  white-space: nowrap;
}
.pill.success { color: #bdf6ae; background: rgba(99, 223, 66, .11); }
.pill.warning { color: #ffd48c; background: rgba(255, 180, 43, .11); }
.pill.condition-green { color: #bdf6ae; background: rgba(99, 223, 66, .13); }
.pill.condition-yellow { color: #ffd48c; background: rgba(255, 180, 43, .13); }
.pill.condition-red { color: #ffb4b4; background: rgba(255, 90, 90, .13); }
.section-gap { margin-top: 18px; }
.import-list { display: grid; gap: 10px; }
.import-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 14px;
}
.import-item small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}
.process-steps, .template-list, .template-items, .timeline {
  display: grid;
  gap: 10px;
}
.phase-timeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.phase {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}
.phase > span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-top: 2px;
  border: 2px solid var(--line);
  background: rgba(255,255,255,.04);
}
.phase strong { display: block; line-height: 1.2; }
.phase small {
  display: block;
  color: var(--muted);
  margin-top: 7px;
  line-height: 1.35;
}
.phase.done { border-color: rgba(99, 223, 66, .32); }
.phase.done > span { background: var(--green); border-color: var(--green); box-shadow: 0 0 0 5px rgba(99, 223, 66, .12); }
.phase.active { border-color: rgba(255, 180, 43, .42); background: rgba(255, 180, 43, .07); }
.phase.active > span { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 5px rgba(255, 180, 43, .12); }
.phase.open { opacity: .74; }
.process-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 150px auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}
.process-step small, .timeline-item small, .template-item small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}
.process-step input, .process-step select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  padding: 12px 14px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  align-items: start;
}
.timeline-item > span {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(99, 223, 66, .12);
}
.template-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}
.template-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(120px, .4fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.template-item button {
  border-color: rgba(255, 90, 90, .45);
  background: rgba(255, 90, 90, .1);
  color: #ffb4b4;
}
.checkline {
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.checkline input {
  width: auto;
}

@media (max-width: 1050px) {
  .sidebar { position: static; width: auto; padding: 18px; }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .user { display: none; }
  main { margin-left: 0; padding: 18px; }
  .hero-grid, .content-grid, .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  body { background: var(--bg); }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px 12px 10px;
    gap: 12px;
    background: rgba(4, 12, 20, .96);
  }
  .brand-mark { width: 36px; height: 36px; }
  .brand strong { font-size: 22px; }
  .brand small { display: none; }
  nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    flex: 0 0 auto;
    min-width: 104px;
    text-align: center;
    padding: 10px 12px;
    font-size: 14px;
  }
  main { padding: 14px; }
  .topbar, .manual { flex-direction: column; align-items: stretch; }
  .topbar { gap: 10px; margin-bottom: 14px; }
  .search { padding: 8px; }
  .search span { display: none; }
  .search button, .manual button, .ghost { width: 100%; }
  .scanner { padding: 22px 16px; }
  h1 { font-size: 38px; }
  h2 { font-size: 18px; }
  .scan-frame {
    aspect-ratio: 1.18 / 1;
    margin: 22px auto 16px;
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .stat { min-height: 110px; padding: 16px; }
  .stat strong { font-size: 32px; }
  .panel { padding: 16px; }
  .panel-head { align-items: flex-start; }
  .peripheral-grid { grid-template-columns: 1fr; }
  .asset-detail { grid-template-columns: 1fr; }
  dl { grid-template-columns: 1fr; gap: 4px; }
  dt { margin-top: 8px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions button { padding-inline: 10px; }
  .filter-row, .import-item { grid-template-columns: 1fr; }
  .process-step, .template-item { grid-template-columns: 1fr; }
  .phase-timeline { grid-template-columns: 1fr; }
  .phase { min-height: 0; }
  table { min-width: 620px; }
  .compact-form { margin-top: 14px; }
}
