:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #0d9488;
  --accent-hover: #14b8a6;
  --danger: #ef4444;
  --border: #334155;
  --shadow: 0 4px 20px rgba(0,0,0,.4);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; min-height: 100vh; }

header { padding: 1.2rem 1rem 0.5rem; text-align: center; }
header h1 { margin: 0; font-size: 1.6rem; color: var(--accent); }
.subtitle { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.tabs { display: flex; gap: 0.25rem; padding: 0.5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { flex: 1; background: transparent; border: none; color: var(--muted); padding: 0.7rem 0.5rem; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.tab.active { background: var(--accent); color: white; }

main { flex: 1; padding: 1rem; overflow-y: auto; }
.panel { display: none; }
.panel.active { display: block; }

.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select, label input, label select, label textarea {
  background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 0.6rem; width: 100%;
}
.toolbar input[type=search] { flex: 1; min-width: 140px; }
.toolbar select { width: auto; }

.list { display: flex; flex-direction: column; gap: 0.75rem; }
.item-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem; display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; box-shadow: var(--shadow);
}
.item-card.expiring { border-color: #f59e0b; }
.item-card.expired { border-color: var(--danger); opacity: 0.85; }
.item-name { font-weight: 600; font-size: 1.05rem; }
.item-meta { color: var(--muted); font-size: 0.85rem; margin-top: 0.2rem; }
.item-actions { display: flex; flex-direction: column; gap: 0.3rem; }
.item-actions button { font-size: 0.8rem; padding: 0.35rem 0.6rem; }

.btn { border: none; border-radius: 8px; padding: 0.65rem 1rem; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: #334155; color: white; }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.empty { text-align: center; color: var(--muted); padding: 2rem; }
.hidden { display: none !important; }

.scanner { width: 100%; max-width: 400px; margin: 0 auto 1rem; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 240px; }
.hint, .note { color: var(--muted); font-size: 0.85rem; text-align: center; }
.result-card { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }

.output { background: var(--surface); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; white-space: pre-wrap; line-height: 1.5; min-height: 100px; }
.output h3 { margin-top: 0; color: var(--accent); }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem; max-width: 420px; width: 90%; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { display: flex; flex-direction: column; gap: 0.7rem; }
dialog menu { display: flex; gap: 0.5rem; justify-content: flex-end; margin: 0; padding: 0; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

@media (max-width: 480px) {
  .toolbar { flex-direction: column; }
  .item-card { grid-template-columns: 1fr; }
  .item-actions { flex-direction: row; }
}

/* Auth overlay */
.auth-overlay {
  position: fixed; inset: 0; background: var(--bg); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
.auth-card h2 { margin: 0 0 0.3rem; color: var(--accent); text-align: center; }
.auth-card form { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 1rem; }
.auth-toggle { text-align: center; margin: 1rem 0 0; font-size: 0.9rem; }
.auth-toggle a { color: var(--accent); text-decoration: none; }
.error { color: var(--danger); font-size: 0.85rem; text-align: center; margin-top: 0.5rem; }
