/* ============ Base ============ */
:root {
  --blue: #1a5da6;
  --blue-dark: #124a87;
  --blue-darker: #0d3a6b;
  --bg: #f4f6f9;
  --text: #2b2f33;
  --muted: #6b7480;
  --border: #dde3ea;
  --white: #ffffff;
  --danger: #c62828;
  --radius: 8px;
  --shadow: 0 2px 10px rgba(16, 42, 74, 0.10);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

h1, h2, h3 { font-weight: 700; margin: 0 0 14px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Buttons ============ */
.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius);
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-blue { background: var(--blue); color: var(--white); }
.btn-blue:hover { background: var(--blue-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-outline-light {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.6);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.12); }
.btn-outline {
  background: var(--white);
  color: var(--blue);
  border: 1px solid var(--blue);
}
.btn-outline:hover { background: #eef4fb; }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #a51f1f; }
.btn-link {
  background: none;
  color: var(--blue);
  padding: 0;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

/* ============ Login ============ */
#view-login {
  display: flex;
  min-height: 100vh;
}
.login-left {
  flex: 0 0 42%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  padding: 40px 30px;
}
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box .logo { margin-bottom: 14px; }
.login-box .logo img { width: 190px; border-radius: 4px; }
.login-box h1 { font-size: 24px; font-weight: 900; margin-bottom: 26px; }
.login-error { color: var(--danger); font-size: 14px; margin-top: 12px; }

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-darker) 100%);
  padding: 40px;
}
.login-right-text p {
  color: var(--white);
  font-size: 32px;
  font-weight: 900;
  margin: 6px 0;
  line-height: 1.25;
}
.login-right-text p:nth-child(2) { font-weight: 500; opacity: 0.9; }
.login-right-text p:nth-child(3) { font-weight: 300; opacity: 0.8; }

.demo-accounts {
  margin-top: 28px;
  padding: 14px;
  background: #f0f5fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}
.demo-title { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.demo-account {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.demo-account:hover { border-color: var(--blue); }

.copyright { margin-top: 24px; font-size: 12px; color: var(--muted); }
.copyright p { margin: 4px 0; }

/* ============ Forms ============ */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--muted);
}
input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 93, 166, 0.15);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 0 0 150px; }
.form-row .form-group.grow { flex: 1 1 220px; }
.form-panel { max-width: 720px; }
.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input { width: auto; }

/* ============ App shell ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--blue);
  color: var(--white);
  padding: 10px 24px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.topbar-logo {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: 6px;
  padding: 2px 7px;
}
.topbar-logo img { height: 32px; display: block; }
#main-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-link {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.12); color: var(--white); }
.nav-link.active { background: var(--blue-darker); color: var(--white); }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.role-chip {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

main { padding: 28px; max-width: 1200px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.view-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.view-head h2 { margin: 0; }

/* ============ Panels & stat cards ============ */
.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 30px; font-weight: 900; color: var(--blue); }
.stat-card .stat-label { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-card.amber { border-left-color: #e0a220; }
.stat-card.amber .stat-value { color: #b7791f; }
.stat-card.green { border-left-color: #2e7d32; }
.stat-card.green .stat-value { color: #2e7d32; }
.stat-card.gray { border-left-color: #90979f; }
.stat-card.gray .stat-value { color: #5a626b; }

/* ============ Tables ============ */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
}
tbody tr:hover { background: #f6f9fc; }
.empty-note { color: var(--muted); padding: 18px 6px; font-size: 14px; }
.table-scroll { overflow-x: auto; }

/* ============ Status badges ============ */
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-pending    { background: #fdf3dc; color: #96690e; }
.badge-inprogress { background: #e1edfa; color: #17579c; }
.badge-ready      { background: #e2f3e4; color: #256a29; }
.badge-delivered  { background: #eceff2; color: #5a626b; }
.badge-cancelled  { background: #fbe4e4; color: #a52222; }
.badge-urgent     { background: #fdeada; color: #a05008; }
.badge-emergency  { background: #fbe4e4; color: #a52222; }
.badge-routine    { background: #eceff2; color: #5a626b; }
.badge-inactive   { background: #fbe4e4; color: #a52222; }
.badge-active     { background: #e2f3e4; color: #256a29; }

/* ============ Filter bar ============ */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar select { width: 180px; }
.filter-bar input[type="search"] { flex: 1; min-width: 220px; }

/* ============ Modal ============ */
#modal-backdrop[hidden], #toast[hidden] { display: none; }

#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 34, 56, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 50;
  overflow-y: auto;
}
#modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
#modal-body { padding: 20px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin-bottom: 16px;
}
.detail-grid .full { grid-column: 1 / -1; }
.detail-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.detail-value { font-size: 14px; margin-top: 2px; }

.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 14px 22px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
  font-size: 13px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}
.timeline .timeline-meta { color: var(--muted); font-size: 12px; }
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ============ Toast ============ */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #123a63;
  color: var(--white);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 14px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

/* ============ Responsive ============ */
@media (max-width: 760px) {
  #view-login { flex-direction: column-reverse; }
  .login-right { padding: 26px; }
  .login-right-text p { font-size: 20px; }
  .topbar { gap: 10px; }
  main { padding: 16px; }
}
