:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --secondary: #117a65;
  --accent: #e74c3c;
  --warn: #f39c12;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dce3eb;
  --text: #2c3e50;
  --text-muted: #7f8c8d;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sarabun', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* NAV */
nav {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
nav .logo {
  font-size: 17px;
  font-weight: 700;
  margin-right: 24px;
  white-space: nowrap;
}
nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.2s;
  white-space: nowrap;
}
nav a:hover, nav a.active { background: rgba(255,255,255,0.18); color: white; }

/* MAIN */
main { max-width: 1300px; margin: 0 auto; padding: 24px 20px; }

/* PAGE TITLE */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title .icon { font-size: 26px; }

/* DATE BAR */
.date-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.date-bar input[type=date] {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 15px;
  color: var(--text);
  background: white;
}
.date-bar .btn { flex-shrink: 0; }

/* HOSPITAL GRID */
.hospital-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
@media (max-width: 800px) { .hospital-grid { grid-template-columns: 1fr; } }

/* CARD */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header.blue { background: var(--primary); color: white; }
.card-header.green { background: var(--secondary); color: white; }
.card-body { padding: 18px 20px; }

/* STAT PILLS */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.stat-pill {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 8px;
  text-align: center;
}
.stat-pill .val {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.stat-pill .val.red { color: var(--accent); }
.stat-pill .val.orange { color: var(--warn); }
.stat-pill .lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* SHIFT TABLE */
.shift-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.shift-table th {
  background: #eaf0f6;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--border);
}
.shift-table td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; }
.shift-table tr:last-child td { border-bottom: none; }
.shift-table tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-blue { background: #d6eaf8; color: var(--primary); }
.badge-green { background: #d5f5e3; color: #1e8449; }
.badge-red { background: #fadbd8; color: #c0392b; }
.badge-orange { background: #fef9e7; color: #d68910; }
.badge-gray { background: #ecf0f1; color: #7f8c8d; }

/* NO DATA */
.no-data {
  text-align: center;
  color: var(--text-muted);
  padding: 28px;
  font-size: 14px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--secondary); color: white; }
.btn-danger { background: var(--accent); color: white; }
.btn-warn { background: var(--warn); color: white; }
.btn-ghost { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* QUICK ACTIONS */
.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

/* FORM */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.form-section-title {
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 15px;
}
.form-section-title.green { background: var(--secondary); }
.form-section-title.orange { background: #d35400; }
.form-body { padding: 20px; }

.form-row {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media (max-width: 700px) {
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-group label .req { color: var(--accent); margin-left: 2px; }

input[type=text], input[type=date], input[type=time], input[type=number],
select, textarea {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: white;
  width: 100%;
  transition: border-color 0.2s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41,128,185,0.12);
}
textarea { resize: vertical; min-height: 72px; }

/* STAFF TABLE */
.staff-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.staff-table th {
  background: #eaf0f6;
  padding: 9px 10px;
  text-align: center;
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--border);
}
.staff-table th:first-child { text-align: left; }
.staff-table td { padding: 6px 8px; border-bottom: 1px solid #f4f4f4; }
.staff-table input[type=number] { text-align: center; padding: 5px 8px; }
.staff-table .dept-name { font-weight: 600; padding: 8px 10px; }

/* ROUND CHECKS */
.round-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.round-tab {
  padding: 7px 18px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
}
.round-tab.active { background: var(--primary); border-color: var(--primary); color: white; }

.check-grid { display: flex; flex-direction: column; gap: 4px; }
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1.5px solid transparent;
  background: #f8f9fa;
  cursor: pointer;
  transition: all 0.15s;
}
.check-item:hover { background: #eaf0f6; border-color: var(--border); }
.check-item input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; }
.check-item .check-label { flex: 1; font-size: 14px; }
.check-item .check-note { width: 200px; font-size: 13px; padding: 4px 8px; }
.check-item.checked { background: #d5f5e3; border-color: #82e0aa; }

/* EVENTS TABLE */
.events-section { margin-top: 4px; }
.event-row { display: grid; grid-template-columns: 90px 130px 150px 1fr 36px; gap: 8px; margin-bottom: 8px; align-items: start; }
.event-row .remove-btn {
  background: #fadbd8;
  border: none;
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
  padding: 7px 10px;
  font-size: 16px;
  line-height: 1;
  margin-top: 2px;
}
.add-row-btn {
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: 7px;
  padding: 8px 14px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  width: 100%;
  transition: all 0.2s;
}
.add-row-btn:hover { border-color: var(--primary-light); color: var(--primary); background: #eaf0f6; }

/* STATUS INDICATOR */
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.dot-green { background: #27ae60; }
.dot-red { background: var(--accent); }
.dot-gray { background: #bdc3c7; }

/* ALERT */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: #d5f5e3; color: #1e8449; border: 1px solid #82e0aa; }
.alert-error { background: #fadbd8; color: #c0392b; border: 1px solid #f1948a; }

/* TOAST */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: slideIn 0.3s ease;
}
#toast.show { display: block; }
#toast.success { background: var(--secondary); }
#toast.error { background: var(--accent); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* REPORT VIEW */
.report-section { margin-bottom: 24px; }
.report-section h3 {
  font-size: 15px;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #eaf0f6;
}

/* INCIDENT SEVERITY BADGES */
.sev-A { background: #d5f5e3; color: #1e8449; }
.sev-B { background: #d6eaf8; color: #1a5276; }
.sev-C { background: #fef9e7; color: #d68910; }
.sev-D { background: #fadbd8; color: #c0392b; }

/* WEEKLY CHART */
.weekly-bar-wrap { margin-top: 10px; }
.weekly-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.weekly-bar-row .lbl { width: 80px; text-align: right; color: var(--text-muted); flex-shrink: 0; }
.weekly-bar-track { flex: 1; background: #ecf0f1; border-radius: 4px; height: 20px; position: relative; overflow: hidden; }
.weekly-bar-fill { height: 100%; border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 12px; color: white; font-weight: 600; transition: width 0.4s ease; min-width: 2px; }
.bar-blue { background: var(--primary-light); }
.bar-green { background: var(--secondary); }
