:root {
  --sidebar-w: 250px;
  --sidebar-bg: #16213a;
  --sidebar-fg: #b9c3d8;
  --accent: #3b6fd8;
  --bg: #f3f5f9;
}

html { font-size: 15px; }
body { font-family: 'Sarabun', system-ui, sans-serif; background: var(--bg); min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--sidebar-bg); color: var(--sidebar-fg);
  overflow-y: auto; z-index: 1040; transition: transform .2s;
}
.sidebar .brand {
  display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.2rem;
  color: #fff; text-decoration: none; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand i { font-size: 1.8rem; color: #6ea0ff; }
.sidebar .brand small { display: block; font-weight: 400; font-size: .75rem; color: var(--sidebar-fg); }
.sidebar .nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; padding: 1rem 1.2rem .3rem; color: #6c7894; }
.sidebar .nav-link { color: var(--sidebar-fg); padding: .55rem 1.2rem; display: flex; gap: .7rem; align-items: center; border-left: 3px solid transparent; }
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar .nav-link.active { color: #fff; background: rgba(110,160,255,.15); border-left-color: #6ea0ff; }
.sidebar .nav-link i { font-size: 1.1rem; width: 1.2rem; }

.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1030; background: #fff; height: 58px;
  display: flex; align-items: center; padding: 0 1.25rem; border-bottom: 1px solid #e3e7ef;
}
.topbar .page-title { font-weight: 600; font-size: 1.1rem; margin-right: 1.5rem; white-space: nowrap; }
.top-menu { list-style: none; margin: 0; padding: 0; gap: .25rem; }
.top-menu a { color: #4a5470; text-decoration: none; padding: .4rem .75rem; border-radius: .4rem; }
.top-menu a:hover { background: #eef2fb; color: var(--accent); }

.content { padding: 1.25rem; flex: 1; }
.footer { padding: .8rem 1.25rem; color: #8a94a6; font-size: .85rem; border-top: 1px solid #e3e7ef; background: #fff; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrap { margin-left: 0; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1035; }
}

/* ---------- Cards / KPI ---------- */
.card { border: 0; border-radius: .7rem; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f5; font-weight: 600; }
.kpi { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; }
.kpi .icon { width: 48px; height: 48px; border-radius: .6rem; display: grid; place-items: center; font-size: 1.4rem; }
.kpi .value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.kpi .label { color: #6c7894; font-size: .85rem; }

/* ---------- Dock monitor ---------- */
.dock-tile { border-radius: .7rem; padding: .9rem 1rem; color: #fff; height: 100%; }
.dock-tile.free { background: linear-gradient(135deg,#2e9d5b,#40b872); }
.dock-tile.reserved { background: linear-gradient(135deg,#3b6fd8,#5b8ae8); }
.dock-tile.busy { background: linear-gradient(135deg,#e08a00,#f0ad1e); }
.dock-tile.plan { background: linear-gradient(135deg,#55607a,#74809c); }
.dock-tile .name { font-weight: 700; font-size: 1.1rem; }
.dock-tile .state { font-size: .8rem; background: rgba(255,255,255,.25); border-radius: 1rem; padding: .1rem .6rem; }
.dock-tile .detail { font-size: .85rem; opacity: .95; margin-top: .4rem; }

/* ---------- Tables ---------- */
.table thead th { background: #f6f8fc; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.table td { vertical-align: middle; font-size: .9rem; }

/* ---------- Slot board ---------- */
.slot-table { table-layout: fixed; }
.slot-table th.time, .slot-table td.time { width: 80px; text-align: center; font-weight: 600; background: #f6f8fc; }
.slot-table td { height: 38px; padding: .25rem .4rem; }
.slot-table td.empty a { display: block; height: 100%; color: transparent; text-decoration: none; }
.slot-table td.empty:hover { background: #eef4ff; }
.slot-table td.empty:hover a { color: var(--accent); }
.slot-booking { border-radius: .4rem; padding: .3rem .5rem; height: 100%; font-size: .82rem; color: #fff; display: block; text-decoration: none; }
.slot-booking:hover { color: #fff; filter: brightness(1.08); }
.slot-booking .plate { font-weight: 700; font-size: .9rem; }

.form-label { font-weight: 500; font-size: .9rem; }
.end-time-box { font-size: 1.3rem; font-weight: 700; color: var(--accent); }

/* ---------- Print ---------- */
@media print {
  .no-print, .sidebar, .topbar, .footer { display: none !important; }
  .main-wrap { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; font-size: 12px; }
  .card { box-shadow: none; border: 0; }
  .slot-booking { color: #000 !important; background: none !important; border: 1px solid #999; }
  .page-break { page-break-after: always; }
  .table td, .table th { border: 1px solid #555 !important; }
}

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #16213a 0%, #2a3f6e 100%); }
.login-box { width: 100%; max-width: 400px; padding: 1rem; }
.login-brand { display: flex; align-items: center; gap: .8rem; color: #fff; margin-bottom: 1.2rem; justify-content: center; }
.login-brand i { font-size: 2.6rem; color: #6ea0ff; }
.login-foot { color: rgba(255,255,255,.55); }

/* ---------- Group permissions ---------- */
.perm-section { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: #6c7894; margin: .4rem 0 .3rem; font-weight: 600; }
.perm-item { display: flex; align-items: center; padding: .5rem .7rem; border: 1px solid #e3e7ef; border-radius: .5rem; cursor: pointer; width: 100%; }
.perm-item:hover { background: #f6f8fc; }
.perm-item:has(input:checked) { border-color: #9db8f0; background: #eef4ff; }

/* ---------- Logs ---------- */
.log-table td { font-size: .84rem; }
.log-detail { max-height: 260px; overflow: auto; font-size: .75rem; background: #f6f8fc; padding: .5rem; border-radius: .4rem; white-space: pre-wrap; margin: .3rem 0 0; }

/* ---------- Logo ---------- */
.brand-logo { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: .5rem; padding: 3px; flex-shrink: 0; }
.login-brand .brand-logo { width: 64px; height: 64px; padding: 5px; border-radius: .8rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* ---------- QR / daily password ---------- */
.qr-reader { width: 100%; min-height: 60px; border-radius: .5rem; overflow: hidden; background: #f6f8fc; }
.qr-img { width: 260px; max-width: 100%; image-rendering: pixelated; border: 1px solid #e3e7ef; border-radius: .5rem; padding: .4rem; background: #fff; }
.daily-value { font-family: Consolas, 'Courier New', monospace; font-size: 1.35rem; font-weight: 700; letter-spacing: .06em; background: #f6f8fc; border-radius: .4rem; padding: .35rem .6rem; }
.print-only { display: none; }
@media print {
  .print-only { display: inline-block; }
  .daily-card { max-width: 420px; margin: 0 auto; border: 1px dashed #999 !important; }
}
