:root {
  --primary: #0f766e;
  --primary-dark: #0a5048;
  --primary-light: #ccfbf1;
  --accent: #2563eb;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --ok: #16a34a;
  --ok-light: #dcfce7;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 10px;
  --sidebar-w: 250px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark), var(--primary));
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.15); }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 20px; }
.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 14.5px; }
.brand-text span { font-size: 11px; opacity: .75; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.navlink { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; opacity: .88; font-size: 13.5px; }
.navlink:hover { background: rgba(255,255,255,.12); opacity: 1; }
.navlink.active { background: rgba(255,255,255,.22); opacity: 1; font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.15); }
.user-chip { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-weight: bold; }
.uname { font-size: 13px; font-weight: 600; }
.urole { font-size: 11px; opacity: .75; }
.btn-logout { width: 100%; background: rgba(255,255,255,.12); border: none; color: #fff; padding: 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; }
.btn-logout:hover { background: rgba(255,255,255,.22); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 26px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 19px; font-weight: 700; }
.topbar-meta { font-size: 11.5px; color: var(--text-muted); }
.content { padding: 22px 26px 60px; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 15.5px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.stat .label { color: var(--text-muted); font-size: 12.5px; }
.stat.warn .num { color: var(--warn); }
.stat.danger .num { color: var(--danger); }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea { resize: vertical; min-height: 70px; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; border: 1px solid transparent; font-size: 13.5px; font-weight: 600; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: #f1f5f9; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 11px; font-size: 12px; }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; color: var(--text-muted); font-weight: 700; font-size: 12px; }
tr:hover td { background: #fafcfe; }
.table-wrap { overflow-x: auto; }

/* ---------- Misc ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge-default { background: #e2e8f0; color: #334155; }
.badge-ok { background: var(--ok-light); color: #166534; }
.badge-warn { background: var(--warn-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; }
.alert-ok { background: var(--ok-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-err { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary-dark); border-color: var(--primary); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; }
.bed { border-radius: 10px; padding: 12px; text-align: center; border: 2px solid transparent; font-size: 12.5px; }
.bed .bed-name { font-weight: 700; margin-bottom: 4px; }
.bed.vacant { background: var(--ok-light); border-color: #bbf7d0; color: #166534; }
.bed.occupied { background: var(--danger-light); border-color: #fecaca; color: #991b1b; }
.bed.cleaning { background: var(--warn-light); border-color: #fde68a; color: #92400e; }
.bed.maintenance { background: #e2e8f0; border-color: #cbd5e1; color: #475569; }
.bed.reserved { background: var(--warn-light); border-color: #fde68a; color: #92400e; }

.print-label { border: 1px dashed #94a3b8; border-radius: 8px; padding: 14px; display: inline-block; background: #fff; text-align: center; }
.print-label h4 { margin: 0 0 6px; font-size: 13px; }
.print-label .qr-code { margin-top: 8px; }
.codes-row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 34px 30px; width: 100%; max-width: 400px; box-shadow: 0 10px 40px rgba(0,0,0,.08); border: 1px solid var(--border); }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; margin: 0 auto 16px; }
.login-card h2 { text-align: center; margin: 0 0 4px; font-size: 19px; }
.login-card p.sub { text-align: center; color: var(--text-muted); font-size: 12.5px; margin: 0 0 22px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 11.5px; color: var(--text-muted); }
.demo-creds { background: #f8fafc; border-radius: 8px; padding: 10px 12px; font-size: 11.5px; margin-top: 16px; color: var(--text-muted); line-height: 1.9; }

.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.mb-0 { margin-bottom: 0 !important; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mt-16 { margin-top: 16px; }
.small { font-size: 12px; }
.link-btn { color: var(--accent); font-weight: 600; }

.search-wrap { position: relative; }
.search-results { position: absolute; z-index: 20; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.1); max-height: 260px; overflow-y: auto; display: none; margin-top: 4px; }
.search-item { padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #f1f5f9; cursor: pointer; }

.print-page { max-width: 720px; margin: 0 auto; background: #fff; }
.letterhead { display: flex; align-items: center; gap: 14px; }
.letterhead-logo { max-height: 64px; max-width: 120px; object-fit: contain; }
.letterhead-name { font-size: 19px; font-weight: 800; }
.letterhead-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.letterhead-rule { border: none; border-top: 2px solid var(--primary); margin: 12px 0 20px; }
.print-body { min-height: 120px; }
.signature-footer { display: flex; justify-content: space-between; margin-top: 50px; padding-top: 14px; border-top: 1px dashed #94a3b8; }
.signature-line { font-size: 12.5px; color: var(--text-muted); }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
}
