/* ===== Variables & Theme ===== */
:root {
  --bg: #0b1220;
  --panel: #0f172a;
  --border: #1e293b;
  --border-light: #334155;
  --text: #e5f0ff;
  --text-muted: rgba(229, 240, 255, 0.75);
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --danger: #ef4444;
  --danger-dark: #b91c1c;
  --radius: 14px;
  --transition: 0.15s ease;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Utilities ===== */
.muted { color: var(--text-muted); }
.tiny { font-size: 12px; }
.hidden { display: none !important; }

/* ===== Layout ===== */
.app {
  max-width: 1200px;
  margin: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Header ===== */
.topbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}

.searchbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.searchbar input {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  transition: border var(--transition), background var(--transition);
}

.searchbar input:focus {
  border-color: var(--primary);
  background: #0c1b2f;
  outline: none;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ===== Buttons ===== */
.btn {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition), transform var(--transition);
}

.btn:hover {
  background: #1a2438;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: white;
}

.btn.primary:hover {
  background: #38bdf8;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger-dark);
  color: white;
}

.btn.danger:hover {
  background: #f87171;
}

.btn.ghost {
  background: transparent;
}

/* ===== Stats ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.stat-num {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

/* ===== Ingest Section ===== */
.ingest {
  display: grid;
  gap: 10px;
}

.ingest-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

textarea {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  resize: vertical;
}

/* ===== Inventory Grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.med-card {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.med-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

.pill {
  width: 10px;
  height: 48px;
  border-radius: 6px;
  background: linear-gradient(135deg, #94a3b8, rgba(255,255,255,0.08));
}

.meta .name {
  font-weight: 700;
  font-size: 16px;
}

.sub {
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  padding: 6px 8px;
  border-radius: 12px;
}

/* ===== Modal ===== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  position: relative;
  width: min(680px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.form .row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
