/* =====================================================================
   SEPADU PPD Bera: gaya antara muka
   ===================================================================== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dfe4eb;
  --line2: #eef1f5;
  --tx: #18212e;
  --tx2: #3b4757;
  --mut: #6a7585;
  --pri: #1d4f91;
  --pri-h: #163f75;
  --pri-soft: #e9f0fa;
  --ok: #15703f;  --ok-soft: #e6f4ec;
  --warn: #9a5507; --warn-soft: #fdf2e1;
  --bad: #b42318; --bad-soft: #fdecea;
  --neu-soft: #eef0f3;
  --r: 6px;
  --side: 212px;
  --top: 48px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body {
  margin: 0;
  color: var(--tx);
  font: 12.5px/1.5 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}
a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.ic { flex: none; vertical-align: -2px; }
.m0 { margin: 0; }
.mut { color: var(--mut); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

/* ---------- Butang & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 28px; padding: 0 10px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--tx2);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f7f9fb; border-color: #cfd6df; text-decoration: none; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn-pri:hover { background: var(--pri-h); border-color: var(--pri-h); }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-bad:hover { background: #95190f; border-color: #95190f; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--line2); border-color: transparent; }
.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; }
.btn-block { width: 100%; height: 32px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 26px; height: 26px;
  border: 0; background: transparent; border-radius: var(--r); color: var(--mut); cursor: pointer;
}
.icon-btn:hover { background: var(--line2); color: var(--tx); }

.input, select.input, textarea.input,
.fld input, .fld select, .fld textarea {
  height: 30px; width: 100%; padding: 0 9px;
  font: inherit; font-size: 12.5px; color: var(--tx);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.fld textarea, textarea.input { height: auto; padding: 6px 9px; resize: vertical; line-height: 1.45; }
.input:focus, .fld input:focus, .fld select:focus, .fld textarea:focus {
  border-color: var(--pri); box-shadow: 0 0 0 3px rgba(29, 79, 145, .12);
}
.fld input[readonly] { background: var(--line2); color: var(--mut); }
.input.input-sm { height: 28px; font-size: 12px; width: auto; max-width: 100%; }
select.input, .fld select { padding-right: 24px; appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236a7585' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center; }
.search { position: relative; }
.search .ic { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--mut); }
.search .input { padding-left: 27px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx2); cursor: pointer; white-space: nowrap; }
.chk input { margin: 0; accent-color: var(--pri); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld > span { font-size: 11.5px; font-weight: 500; color: var(--tx2); }
.fld > span i { color: var(--bad); font-style: normal; }
.fld small, .hint { font-size: 11px; color: var(--mut); }
.span2 { grid-column: span 2; }
.row2 { display: flex; align-items: center; gap: 6px; }
.row2 > span { color: var(--mut); font-size: 11.5px; }

/* ---------- Lencana ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  background: var(--neu-soft); color: var(--tx2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.pri { background: var(--pri-soft); color: var(--pri); }
.badge.plain::before { display: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--pri)); flex: none; }

/* ---------- Amaran ---------- */
.alert { padding: 8px 10px; border-radius: var(--r); font-size: 12px; border: 1px solid; margin-bottom: 12px; }
.alert-bad { background: var(--bad-soft); border-color: #f5c6c1; color: #8c1d13; }
.alert-ok { background: var(--ok-soft); border-color: #bfe3cd; color: #0f5530; }
.alert-info { background: var(--pri-soft); border-color: #c9d9ef; color: #173f75; }

/* ---------- Kerangka aplikasi ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); z-index: 30;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.brand { display: flex; align-items: center; gap: 9px; height: var(--top); padding: 0 14px; border-bottom: 1px solid var(--line); }
.brand img { height: 28px; width: auto; }
.brand b { display: block; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.brand small { display: block; font-size: 10.5px; color: var(--mut); line-height: 1.2; }
.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.nav-lbl { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #8a94a3; padding: 12px 8px 5px; }
.nav-lbl:first-child { padding-top: 2px; }
.nav a {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; margin-bottom: 1px;
  border-radius: var(--r); color: var(--tx2); font-weight: 500;
}
.nav a:hover { background: var(--line2); text-decoration: none; }
.nav a.on { background: var(--pri-soft); color: var(--pri); }
.nav a .ic { color: #8a94a3; }
.nav a.on .ic { color: var(--pri); }
.side-foot { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--mut); }

.main { flex: 1; margin-left: var(--side); min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 18px 0;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.crumb { font-size: 12px; color: var(--mut); display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumb b { color: var(--tx); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-date { font-size: 11.5px; color: var(--mut); white-space: nowrap; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 6px 0 3px;
  border: 1px solid transparent; background: transparent; border-radius: var(--r);
  font: inherit; color: var(--tx); cursor: pointer;
}
.user-btn:hover { background: var(--line2); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pri); color: #fff; font-size: 10.5px; font-weight: 600; flex: none;
}
.user-btn .nm { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 500; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 210px; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 4px;
}
.dropdown .dd-h { padding: 8px 10px; border-bottom: 1px solid var(--line2); margin-bottom: 4px; }
.dropdown .dd-h b { display: block; font-size: 12px; }
.dropdown .dd-h small { color: var(--mut); font-size: 11px; word-break: break-all; }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 10px;
  border: 0; background: none; font: inherit; color: var(--tx2); border-radius: 5px; cursor: pointer; text-align: left;
}
.dropdown a:hover, .dropdown button:hover { background: var(--line2); text-decoration: none; }

.view { padding: 18px 20px 40px; max-width: 1320px; width: 100%; padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 16px; }
.page-head .sub { margin: 2px 0 0; font-size: 12px; color: var(--mut); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.loading { padding: 40px; text-align: center; color: var(--mut); }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  height: 32px; padding: 0 12px; border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 500;
  color: var(--mut); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--tx); }
.tabs button.on { color: var(--pri); border-bottom-color: var(--pri); }

/* ---------- Panel ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); margin-bottom: 14px; min-width: 0; }
.panel-h { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h3 { font-size: 12.5px; }
.panel-h .count { font-size: 11px; color: var(--mut); background: var(--line2); border-radius: 10px; padding: 0 7px; line-height: 18px; }
.panel-b { padding: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-gap { margin-bottom: 14px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .tb-title { font-weight: 600; font-size: 13px; margin-left: 4px; }
.toolbar label.mini { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--mut); }

/* ---------- Kad statistik ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .lbl { font-size: 11.5px; color: var(--mut); display: flex; align-items: center; gap: 6px; }
.stat .val { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; line-height: 1.3; }
.stat .val small { font-size: 12px; color: var(--mut); font-weight: 500; }
.stat .ft { font-size: 11px; color: var(--mut); margin-top: 2px; }

/* ---------- Jadual ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .04em;
  background: #f9fafb; padding: 7px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafbfc; }
.tbl td.act { text-align: right; white-space: nowrap; width: 1%; }
.tbl td .sm { display: block; font-size: 11px; color: var(--mut); }
.tbl tr.dim td { color: var(--mut); }
.tbl tr.dim td b { font-weight: 500; }
.tbl tr.click { cursor: pointer; }
.tbl b { font-weight: 600; }

.empty { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 26px 14px; color: var(--mut); font-size: 12px; }

/* ---------- Jadual masa bilik ---------- */
.tl-wrap { overflow-x: auto; }
.tl { min-width: 780px; }
.tl-row { display: flex; border-bottom: 1px solid var(--line2); }
.tl-row:last-child { border-bottom: 0; }
.tl-room { width: 170px; flex: none; padding: 10px 12px; border-right: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-start; }
.tl-room .dot { margin-top: 4px; }
.tl-room b { display: block; font-size: 12px; font-weight: 600; }
.tl-room small { display: block; font-size: 11px; color: var(--mut); line-height: 1.35; }
.tl-track {
  position: relative; flex: 1; min-height: 56px;
  background-image: linear-gradient(to right, var(--line2) 1px, transparent 1px);
  background-size: calc(100% / var(--n)) 100%;
}
.tl-click { cursor: copy; }
.tl-click:hover { background-color: #fbfcfe; }
.tl-head .tl-room { padding: 0 12px; height: 28px; align-items: center; font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; background: #f9fafb; }
.tl-head .tl-track { min-height: 28px; background-color: #f9fafb; }
.tl-hr { position: absolute; top: 7px; font-size: 10.5px; color: var(--mut); transform: translateX(4px); }
.tl-blk {
  position: absolute; top: 6px; bottom: 6px; min-width: 6px;
  padding: 4px 7px; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--c) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--c) 30%, #fff);
  border-left: 3px solid var(--c);
  border-radius: 4px; font-size: 11px; line-height: 1.3; color: var(--tx);
}
.tl-blk:hover { background: color-mix(in srgb, var(--c) 18%, #fff); z-index: 2; }
.tl-blk b { display: block; font-weight: 600; color: color-mix(in srgb, var(--c) 75%, #000); white-space: nowrap; }
.tl-blk span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-blk.mine { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, #fff); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid var(--bad); z-index: 3; pointer-events: none; }
.tl-now::before { content: ''; position: absolute; top: -1px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }
.tl-past { position: absolute; top: 0; bottom: 0; left: 0; background: repeating-linear-gradient(135deg, rgba(106, 117, 133, .05) 0 6px, transparent 6px 12px); pointer-events: none; }
.legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--mut); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* Senarai bilik (papan pemuka) */
.rooms { display: flex; flex-direction: column; }
.room-it { padding: 10px 14px; border-bottom: 1px solid var(--line2); }
.room-it:last-child { border-bottom: 0; }
.room-it .rh { display: flex; align-items: center; gap: 8px; }
.room-it .rh b { font-size: 12.5px; }
.room-it ul { list-style: none; margin: 6px 0 0 16px; padding: 0; }
.room-it li { font-size: 12px; color: var(--tx2); padding: 2px 0; display: flex; gap: 8px; }
.room-it li .t { color: var(--mut); width: 82px; flex: none; font-variant-numeric: tabular-nums; }
.room-it li.past { color: var(--mut); }
.room-it .none { font-size: 11.5px; color: var(--mut); margin: 4px 0 0 16px; }

/* Butiran (modal) */
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; margin: 0; font-size: 12.5px; }
.dl dt { color: var(--mut); }
.dl dd { margin: 0; word-break: break-word; }

/* Ketersediaan (dalam borang) */
.avail { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r); background: #fafbfc; }
.avail-h { padding: 7px 10px; font-size: 11.5px; font-weight: 500; color: var(--tx2); border-bottom: 1px solid var(--line2); display: flex; align-items: center; gap: 6px; }
.avail ul { list-style: none; margin: 0; padding: 6px 10px; }
.avail li { font-size: 12px; padding: 2px 0; display: flex; gap: 8px; }
.avail li .t { width: 82px; color: var(--mut); flex: none; }
.avail li.clash { color: var(--bad); font-weight: 500; }
.avail li.clash .t { color: var(--bad); }
.avail .none { padding: 8px 10px; font-size: 12px; color: var(--ok); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 35, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(6vh, env(safe-area-inset-top, 0px)) 16px 16px; overflow-y: auto;
  animation: fade .12s ease-out;
}
.modal { background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; margin: 0; animation: pop .14s ease-out; }
.modal.modal-sm { max-width: 400px; }
.modal.modal-lg { max-width: 720px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { font-size: 13.5px; }
.modal-b { padding: 16px 18px; }
.modal-f { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 18px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 10px 10px; flex-wrap: wrap; }
.modal-f .left { margin-right: auto; display: flex; gap: 6px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 200; display: flex; flex-direction: column; gap: 6px; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; min-width: 240px; max-width: 380px;
  background: #18212e; color: #fff; border-radius: 7px; box-shadow: var(--shadow-lg); font-size: 12px;
  animation: pop .15s ease-out; transition: opacity .3s, transform .3s;
}
.toast .ic { color: #6ee7a8; }
.toast-bad .ic { color: #fca5a5; }
.toast-info .ic { color: #93c5fd; }
.toast.out { opacity: 0; transform: translateY(4px); }

/* ---------- Log masuk ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line2); }
.auth-brand img { height: 40px; width: auto; }
.auth-brand b { display: block; font-size: 12.5px; line-height: 1.3; }
.auth-brand span { display: block; font-size: 11.5px; color: var(--mut); }
.auth h1 { font-size: 15px; }
.auth .sub { color: var(--mut); font-size: 12px; margin: 3px 0 16px; }
.auth form { display: flex; flex-direction: column; gap: 11px; }
.auth .links { display: flex; justify-content: space-between; font-size: 12px; margin-top: 2px; }
.auth .links button { background: none; border: 0; padding: 0; font: inherit; color: var(--pri); cursor: pointer; }
.auth .links button:hover { text-decoration: underline; }
.auth-foot { font-size: 11px; color: var(--mut); margin-top: 14px; text-align: center; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--mut); font-size: 11px; margin: 14px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.btn-google { width: 100%; height: 32px; gap: 8px; }
.notice { max-width: 420px; text-align: center; }
.notice h1 { margin-bottom: 6px; }

/* ---------- Responsif ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .side { transform: translateX(-100%); transition: transform .18s ease; box-shadow: none; }
  body.nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { position: fixed; inset: 0; z-index: 25; background: rgba(15, 23, 35, .3); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .top { padding-left: 10px; padding-right: 10px; }
  .top-date, .user-btn .nm { display: none; }
  .view { padding: 14px 16px 32px; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .val { font-size: 18px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 6px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .modal-bg { padding: 10px; }
  .tl-room { width: 118px; padding: 8px; }
  .tl-room small { display: none; }
}
