:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;
  --light-bg: #f0f4ff;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  background-color: #f5f7fb;
  font-family: 'Hiragino Kaku Gothic ProN', 'メイリオ', Meiryo, sans-serif;
  font-size: 15px;
}

/* ========== Navbar ========== */
.navbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.navbar-brand { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.05em; }
.navbar .badge { font-size: 0.7rem; }

/* ========== Cards ========== */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 1rem;
}
.card-header {
  background: var(--light-bg);
  border-bottom: 2px solid var(--primary);
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
  color: var(--primary-dark);
  padding: 0.8rem 1.2rem;
}

/* ========== Quick Action Buttons ========== */
.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  min-height: 110px;
  box-shadow: var(--card-shadow);
}
.action-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.15);
  text-decoration: none;
}
.action-btn .icon { font-size: 2rem; margin-bottom: 0.4rem; }
.action-btn-primary  { background: var(--primary); color: #fff; }
.action-btn-success  { background: var(--success); color: #fff; }
.action-btn-info     { background: #17a2b8; color: #fff; }
.action-btn-warning  { background: var(--warning); color: #333; }
.action-btn-purple   { background: #6f42c1; color: #fff; }
.action-btn-secondary{ background: #6c757d; color: #fff; }

/* ========== Summary Cards ========== */
.summary-card {
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  background: #fff;
  box-shadow: var(--card-shadow);
}
.summary-card.danger  { border-color: var(--danger); }
.summary-card.warning { border-color: var(--warning); }
.summary-card.success { border-color: var(--success); }
.summary-card .num    { font-size: 2rem; font-weight: 700; }
.summary-card .label  { font-size: 0.85rem; color: #666; }

/* ========== Tables ========== */
.table-responsive { border-radius: 8px; overflow: hidden; }
.table { margin-bottom: 0; }
.table thead th {
  background: var(--primary);
  color: #fff;
  border: none;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.75rem 1rem;
}
.table tbody tr:hover { background-color: #f0f4ff; }
.table td { vertical-align: middle; }

/* ========== Stock Status Badges ========== */
.badge-ok      { background-color: var(--success); color: #fff; }
.badge-warning { background-color: var(--warning); color: #333; }
.badge-danger  { background-color: var(--danger);  color: #fff; }
.badge-zero    { background-color: #343a40; color: #fff; }

/* ========== Barcode Scanner ========== */
#scanner-overlay {
  display: none;
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.95);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#scanner-overlay.active { display: flex; }
#scanner-video {
  width: 100%;
  max-width: 600px;
  height: 60vh;
  object-fit: cover;
  border-radius: 8px;
}
.scanner-guide {
  position: absolute;
  width: min(80vw, 400px);
  height: 120px;
  border: 3px solid #00ff88;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}
.scanner-line {
  position: absolute;
  width: 100%;
  height: 2px;
  background: #00ff88;
  animation: scanline 2s linear infinite;
}
@keyframes scanline {
  0%   { top: 0; opacity: 1; }
  100% { top: 100%; opacity: 0.3; }
}
.scanner-hint { color: #fff; margin-top: 1rem; font-size: 0.9rem; text-align: center; }

/* ========== Forms ========== */
.form-control, .form-select {
  border-radius: 8px;
  border: 1.5px solid #ced4da;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(26,115,232,0.2);
}
.form-label { font-weight: 600; font-size: 0.9rem; color: #444; margin-bottom: 0.3rem; }
.input-group-text { background: var(--light-bg); border-color: #ced4da; }

/* ========== Buttons ========== */
.btn { border-radius: 8px; font-weight: 600; padding: 0.5rem 1.2rem; }
.btn-lg { padding: 0.75rem 1.8rem; font-size: 1rem; }
.btn-scan {
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: #fff; border: none;
  display: flex; align-items: center; gap: 0.5rem;
}
.btn-scan:hover { background: linear-gradient(135deg, #00a381, #00b5b8); color: #fff; }

/* ========== Reagent Info Card ========== */
.reagent-info-card {
  background: linear-gradient(135deg, #e8f4fd, #f0faf5);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 1.2rem;
  animation: fadeIn 0.3s ease;
}
.reagent-info-card .reagent-name { font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); }
.reagent-info-card .reagent-meta { font-size: 0.85rem; color: #666; }

/* ========== Alerts ========== */
.alert { border-radius: 10px; border: none; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger  { background: #f8d7da; color: #721c24; }

/* ========== Login Page ========== */
.login-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}
.login-card {
  width: 100%; max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header {
  background: rgba(255,255,255,0.1);
  color: #fff; padding: 2rem;
  text-align: center;
}
.login-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.3rem; }
.login-header p { font-size: 0.85rem; opacity: 0.8; }
.login-body { background: #fff; padding: 2rem; }

/* ========== Inventory All Table ========== */
.inv-all-table th, .inv-all-table td { text-align: center; min-width: 70px; }
.inv-all-table td:first-child { text-align: left; min-width: 200px; }
.stock-cell { font-weight: 700; border-radius: 4px; padding: 2px 6px; }
.stock-ok      { background: #d4edda; color: #155724; }
.stock-warn    { background: #fff3cd; color: #856404; }
.stock-danger  { background: #f8d7da; color: #721c24; }
.stock-zero    { background: #343a40; color: #fff; }

/* ========== Toast notification ========== */
.toast-container { position: fixed; top: 80px; right: 20px; z-index: 9998; }

/* ========== Page header ========== */
.page-header {
  background: #fff;
  border-bottom: 2px solid var(--primary);
  padding: 1rem 0;
  margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; color: var(--primary-dark); margin: 0; }

/* ========== Animations ========== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ========== Mobile adjustments ========== */
@media (max-width: 576px) {
  .action-btn { min-height: 90px; padding: 1rem 0.5rem; font-size: 0.85rem; }
  .action-btn .icon { font-size: 1.6rem; }
  .page-header h2 { font-size: 1.1rem; }
  .table { font-size: 0.85rem; }
  .summary-card .num { font-size: 1.6rem; }
}
