/* ===========================================================================
   TOP1 — iPad front-desk app. Navigation rail (full menu) + master-detail.
   Layered on top of app.css tokens. Landscape iPad 1194×834.
   ========================================================================= */

/* ── Presentation stage + device bezel ─────────────────────────────────── */
body{background:radial-gradient(120% 90% at 50% -10%, #dfeaf2 0%, var(--canvas) 55%);
  min-height:100vh; display:flex; flex-direction:column; align-items:center; gap:14px; padding:24px 16px 36px;}
.stage-cap{display:flex; align-items:center; gap:8px; color:var(--muted); font-size:13px; font-weight:500;}
.stage-cap b{color:var(--fg-strong); font-family:var(--font-display);}
.device-tablet{width:min(1194px, 97vw); aspect-ratio:1194 / 834; background:#0c1420; border-radius:34px;
  padding:14px 16px; box-shadow:var(--shadow-lg), 0 0 0 2px #1d2735; position:relative;}
.device-tablet::before{content:""; position:absolute; top:50%; left:7px; transform:translateY(-50%);
  width:6px; height:64px; border-radius:6px; background:#1d2735;}
.screen{width:100%; height:100%; background:var(--canvas); border-radius:22px; overflow:hidden;
  display:grid; grid-template-columns:88px 1fr; position:relative;}

/* ── Navigation rail (full menu, like web sidebar) ─────────────────────── */
.rail{background:var(--surface); border-right:1px solid var(--border); display:flex; flex-direction:column;
  align-items:center; padding:14px 0; gap:4px;}
.rail-brand{width:40px; height:40px; border-radius:11px; display:grid; place-items:center; flex:none; margin-bottom:10px;
  background:linear-gradient(135deg,var(--brand-500),var(--brand-700)); color:#fff; font-family:var(--font-display); font-weight:800; font-size:15px;}
.rail-sep{width:40px; height:1px; background:var(--border); margin:6px 0;}
.rail-item{position:relative; width:64px; min-height:58px; border:0; background:transparent; border-radius:var(--radius-lg);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; color:var(--muted); padding:8px 2px;
  transition:background var(--dur-fast), color var(--dur-fast);}
.rail-item svg{width:22px; height:22px;}
.rail-item span{font-size:10px; font-weight:500; letter-spacing:-0.01em; line-height:1;}
.rail-item:hover{background:var(--surface-3); color:var(--fg);}
.rail-item.active{background:var(--primary-soft); color:var(--primary-soft-fg); font-weight:600;}
.rail-item.active::before{content:""; position:absolute; left:-1px; top:14px; bottom:14px; width:3px; border-radius:3px; background:var(--accent);}
.rail-item .badge-count{position:absolute; top:6px; right:8px; background:var(--accent); color:#fff; font-size:9px; font-weight:700;
  min-width:16px; height:16px; padding:0 4px; border-radius:99px; display:grid; place-items:center; font-family:var(--font-mono);}
.rail-foot{margin-top:auto; display:flex; flex-direction:column; align-items:center; gap:8px;}

/* ── Main column ───────────────────────────────────────────────────────── */
.fd-main{display:flex; flex-direction:column; min-width:0; min-height:0;}
.fd-top{display:flex; align-items:center; gap:16px; height:62px; padding:0 22px; background:var(--surface);
  border-bottom:1px solid var(--border); flex:none;}
.fd-top h1{font-size:var(--text-xl); font-weight:700; letter-spacing:-0.02em;}
.fd-top .crumb{font-size:11px; color:var(--subtle); font-family:var(--font-mono); text-transform:uppercase; letter-spacing:.05em;}
.fd-top .spacer{flex:1;}
.fd-clock{text-align:right; line-height:1.1;}
.fd-clock .t{font-family:var(--font-mono); font-weight:600; font-size:17px; color:var(--fg-strong);}
.fd-clock .d{font-size:11px; color:var(--muted);}
.fd-recep{display:flex; align-items:center; gap:9px; padding:5px 8px 5px 5px; border:1px solid var(--border); border-radius:var(--radius-full);}
.fd-recep .nm{font-size:13px; font-weight:600;}

/* touch button helpers */
.tbtn{height:44px; min-width:44px; padding:0 16px; border-radius:var(--radius-btn); font-weight:600; font-size:14px;
  display:inline-flex; align-items:center; justify-content:center; gap:7px; border:1px solid var(--border-strong); background:var(--surface); color:var(--fg);}
.tbtn.pri{background:var(--primary); color:var(--primary-fg); border-color:transparent;}
.tbtn.pri:active{background:var(--primary-active);}
.tbtn.ghost{border-color:transparent; background:var(--surface-3); color:var(--muted);}
.tbtn.ico{width:44px; padding:0;}
.tbtn svg{width:18px; height:18px;}
.tbtn.sm{height:38px; font-size:13px; padding:0 13px;}

/* ── View switching ────────────────────────────────────────────────────── */
.view{flex:1; min-height:0; overflow:hidden;}
.view[hidden]{display:none;}

/* ── Master-detail shell ───────────────────────────────────────────────── */
.md{height:100%; display:grid; grid-template-columns:340px 1fr;}
.md-master{border-right:1px solid var(--border); background:var(--surface); display:flex; flex-direction:column; min-height:0;}
.md-mtop{padding:14px 16px 10px; display:flex; flex-direction:column; gap:10px; flex:none; border-bottom:1px solid var(--border);}
.md-search{display:flex; align-items:center; gap:8px; height:42px; padding:0 13px; border:1px solid var(--border-strong);
  border-radius:var(--radius-md); background:var(--surface-2); color:var(--muted);}
.md-search input{border:0; background:transparent; outline:none; flex:1; font:inherit; font-size:14px; color:var(--fg);}
.md-mfilter{display:flex; gap:6px; overflow-x:auto; flex-wrap:nowrap; scrollbar-width:none; -webkit-overflow-scrolling:touch;}
.md-mfilter::-webkit-scrollbar{display:none;}
.md-mfilter .chip{flex:0 0 auto; white-space:nowrap;}
.md-list{overflow-y:auto; flex:1; padding:8px;}
.md-detail{overflow-y:auto; background:var(--canvas); padding:24px;}

/* master row */
.mrow{display:flex; align-items:center; gap:12px; width:100%; text-align:left; padding:11px 12px; border:1px solid transparent;
  border-radius:var(--radius-lg); background:transparent; min-height:60px; transition:background var(--dur-fast), border-color var(--dur-fast);}
.mrow:hover{background:var(--surface-2);}
.mrow.active{background:var(--primary-soft); border-color:var(--brand-200);}
.mrow .mr-main{flex:1; min-width:0;}
.mrow .mr-name{font-weight:600; color:var(--fg-strong); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:flex; align-items:center; gap:7px;}
.mrow .mr-sub{font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:1px;}
.mrow .mr-end{text-align:right; flex:none;}
.mrow .mr-amt{font-family:var(--font-mono); font-weight:600; font-size:14px; color:var(--fg-strong);}
.mrow .mr-meta{font-size:11px; color:var(--subtle); font-family:var(--font-mono);}
.mrow .swatch{width:10px; height:36px; border-radius:5px; flex:none;}

.md-mfoot{padding:10px 14px; border-top:1px solid var(--border); font-size:12px; color:var(--muted); flex:none; text-align:center;}

/* ── Detail panel building blocks ──────────────────────────────────────── */
.dhead{display:flex; align-items:flex-start; gap:16px; margin-bottom:22px;}
.dhead .d-id{flex:1; min-width:0;}
.dhead h2{font-size:var(--text-2xl); letter-spacing:-0.02em; display:flex; align-items:center; gap:10px; flex-wrap:wrap;}
.dhead .d-sub{color:var(--muted); font-size:14px; margin-top:4px;}
.dhead .d-act{display:flex; gap:9px; flex:none; flex-wrap:wrap; justify-content:flex-end;}

.dtiles{display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:12px; margin-bottom:22px;}
.dtile{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:14px 16px;}
.dtile .v{font-family:var(--font-display); font-weight:700; font-size:24px; letter-spacing:-0.02em; line-height:1; color:var(--fg-strong);}
.dtile .v .u{font-size:14px; color:var(--muted); font-weight:600;}
.dtile .l{font-size:12px; color:var(--muted); margin-top:6px;}

.dcard{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); margin-bottom:18px; overflow:hidden;}
.dcard-h{padding:13px 18px; border-bottom:1px solid var(--border); font-weight:600; font-size:15px; display:flex; align-items:center; justify-content:space-between;}
.dcard-b{padding:6px 18px;}
.dcard-b.pad{padding:18px;}

.kv{display:flex; justify-content:space-between; gap:14px; padding:11px 0; border-bottom:1px solid var(--border); font-size:14px;}
.kv:last-child{border-bottom:0;}
.kv .k{color:var(--muted);} .kv .v{font-weight:500; text-align:right;}

/* timeline / history list */
.tline{position:relative; padding:4px 0;}
.tline .ti{display:flex; gap:13px; padding:11px 0; border-bottom:1px solid var(--border);}
.tline .ti:last-child{border-bottom:0;}
.tline .ti .dot{width:9px; height:9px; border-radius:50%; background:var(--brand-400); margin-top:5px; flex:none;}
.tline .ti .tin{flex:1; min-width:0;}
.tline .ti .tt{font-weight:600; font-size:14px;}
.tline .ti .ts{font-size:12px; color:var(--muted);}
.tline .ti .tx{font-family:var(--font-mono); font-size:13px; font-weight:600; color:var(--fg);}

/* chips list (assignable staff / tags) */
.dchips{display:flex; gap:8px; flex-wrap:wrap;}
.dchip{display:inline-flex; align-items:center; gap:7px; height:34px; padding:0 12px; border-radius:var(--radius-full);
  border:1px solid var(--border); background:var(--surface); font-size:13px; font-weight:500;}

/* weekly availability mini-grid (staff) */
.av-grid{display:grid; grid-template-columns:repeat(7,1fr); gap:6px;}
.av-grid .d{aspect-ratio:1; border-radius:7px; display:grid; place-items:center; font-size:11px; font-family:var(--font-mono); font-weight:500;}
.av-grid .d.on{background:var(--primary-soft); color:var(--primary-soft-fg);}
.av-grid .d.off{background:var(--surface-3); color:var(--subtle);}

/* progress bar */
.prog{height:7px; border-radius:99px; background:var(--surface-3); overflow:hidden;}
.prog i{display:block; height:100%; background:linear-gradient(90deg,var(--brand-400),var(--brand-600));}

/* ── Dashboard / Reports (overview pages) ──────────────────────────────── */
.ov{height:100%; overflow-y:auto; padding:22px;}
.ov-grid{display:grid; gap:14px;}
.ov-grid.k4{grid-template-columns:repeat(4,1fr);}
.ov-grid.k3{grid-template-columns:repeat(3,1fr);}
.ov-grid.g21{grid-template-columns:2fr 1fr;}
.ovkpi{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:16px 18px; box-shadow:var(--shadow-xs);}
.ovkpi .l{font-size:13px; color:var(--muted); font-weight:500;}
.ovkpi .v{font-family:var(--font-display); font-weight:700; font-size:30px; letter-spacing:-0.03em; line-height:1; margin:10px 0 6px;}
.ovkpi .v .u{font-size:15px; color:var(--muted); font-weight:600;}
.ovkpi .t{font-size:12px; font-weight:600; font-family:var(--font-mono);}
.ovkpi .t.up{color:var(--success);} .ovkpi .t.down{color:var(--danger);} .ovkpi .t.flat{color:var(--muted);}

/* ── Settings (master-detail style sub-nav) ────────────────────────────── */
.set-nav{padding:10px;}
.set-nav .mrow{min-height:50px;}

/* ── Bottom sheet (shared composer) ────────────────────────────────────── */
.sheet-scrim{position:absolute; inset:0; background:var(--overlay); opacity:0; visibility:hidden; transition:opacity var(--dur-base); z-index:20; border-radius:22px;}
.sheet-scrim.open{opacity:1; visibility:visible;}
.sheet{position:absolute; left:0; right:0; bottom:0; background:var(--surface); border-radius:22px 22px 0 0; box-shadow:var(--shadow-lg);
  transform:translateY(100%); transition:transform var(--dur-slow) var(--ease-emphasized); z-index:21; padding:8px 26px 26px; max-height:86%; overflow-y:auto;}
.sheet.open{transform:none;}
.sheet .grip{width:42px; height:5px; border-radius:99px; background:var(--border-strong); margin:6px auto 14px;}
.sheet h3{font-size:var(--text-xl); margin-bottom:4px;}
.sheet .sub{color:var(--muted); font-size:13px; margin-bottom:18px;}
.sform{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.sform .full{grid-column:1 / -1;}
.sform .label{margin-bottom:6px;}
.sform .input,.sform .select{height:46px; font-size:15px;}
.pickrow{display:flex; gap:8px; flex-wrap:wrap;}
.pick{height:42px; padding:0 16px; border-radius:var(--radius-full); border:1px solid var(--border-strong); background:var(--surface); font-size:14px; font-weight:500; color:var(--fg);}
.pick.on{background:var(--primary-soft); border-color:var(--accent); color:var(--primary-soft-fg); font-weight:600;}
.sheet-foot{display:flex; gap:12px; margin-top:22px;}
.sheet-foot .tbtn{flex:1; height:50px; font-size:15px;}

/* ── Booking composer inside the bottom sheet ──────────────────────────── */
.sheet.book-sheet{padding:0; max-height:94%; display:flex; flex-direction:column; overflow:hidden;}
.book-sheet .sheet-head{padding:8px 24px 14px; border-bottom:1px solid var(--border); flex:0 0 auto;}
.book-sheet .sheet-head-row{display:flex; align-items:flex-start; gap:16px;}
.book-sheet .sheet-head-row .seg{margin-left:auto; flex:0 0 auto;}
.book-sheet h3{margin-bottom:2px;}
.book-sheet .sub{margin-bottom:0;}
/* the grid fills remaining height; each column scrolls on its own */
.book-sheet .book-grid{flex:1; min-height:0; grid-template-columns:1fr 332px;}
.book-sheet .book-form{overflow-y:auto;}
.book-sheet .book-summary{overflow-y:auto;}
/* roomier touch targets on iPad */
.book-sheet .pick-person,.book-sheet .pick-svc{min-height:42px;}
.book-sheet .time-slot{height:42px; font-size:14px;}
.book-sheet .mini-in input{height:38px;}

/* ── Appointment detail sheet (tap vào 1 lịch trên calendar) ───────────── */
.sheet.appt-sheet{padding:0; max-height:90%; display:flex; flex-direction:column; overflow:hidden;}
.appt-sheet .sheet-head{padding:8px 0 0; flex:0 0 auto;}
.appt-body{flex:1; min-height:0; overflow-y:auto; padding:4px 26px 26px;}
/* header: avatar + identity + status/time */
.appt-head{display:flex; align-items:center; gap:14px; padding:6px 0 18px; border-bottom:1px solid var(--border); margin-bottom:18px;}
.appt-head .ah-id{flex:1; min-width:0;}
.appt-head .ah-name{font-size:var(--text-xl); font-weight:600; line-height:1.2;}
.appt-head .ah-svc{color:var(--muted); font-size:14px; margin-top:2px;}
.appt-head .ah-meta{display:flex; flex-direction:column; align-items:flex-end; gap:7px; flex:0 0 auto;}
.appt-head .ah-time{font-size:13px; color:var(--muted); font-weight:600;}
/* two info cards side by side */
.appt-cards{display:grid; grid-template-columns:1fr 1fr; gap:18px;}
.appt-cards .dcard{margin-bottom:18px;}
.appt-body .dcard-b textarea.input{width:100%; resize:none; margin:10px 0 4px; font-family:inherit; font-size:14px; line-height:1.5;}
/* quick actions row */
.appt-actions{display:flex; flex-wrap:wrap; gap:10px; margin-bottom:4px;}
.appt-actions .tbtn{flex:1 1 0; height:46px; white-space:nowrap;}
.tbtn.danger-ghost{background:var(--danger-bg); color:var(--danger-fg); border-color:transparent;}
.tbtn.danger-ghost:active{filter:brightness(.94);}
.appt-sheet .sheet-foot{padding:0; margin-top:18px;}

/* ── Edit appointment sheet (màn "Sửa") ────────────────────────────────── */
.sheet.edit-sheet{padding:0; max-height:92%; display:flex; flex-direction:column; overflow:hidden;}
.edit-sheet .sheet-head{padding:8px 26px 14px; border-bottom:1px solid var(--border); flex:0 0 auto;}
.edit-sheet .sheet-head .sheet-head-row{margin-top:6px;}
.edit-sheet h3{font-size:var(--text-xl); margin-bottom:2px;}
.edit-sheet .sub{color:var(--muted); font-size:13px;}
.edit-body{flex:1; min-height:0; overflow-y:auto; padding:18px 26px 26px;}
/* read-only context strip */
.edit-ctx{display:flex; align-items:center; gap:13px; padding:12px 14px; margin-bottom:20px; background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius-lg);}
.edit-ctx .ec-name{font-weight:600; font-size:16px;}
.edit-ctx .ec-svc{color:var(--muted); font-size:13px; margin-top:1px;}
/* sections + labels */
.edit-sect{margin-bottom:20px;}
.edit-sect .es-h{font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--subtle); font-family:var(--font-mono); margin-bottom:9px;}
.edit-row{display:grid; grid-template-columns:1fr 1fr; gap:18px;}
.edit-row .input[type=date]{height:46px;}
/* duration stepper */
.dur-step{display:flex; align-items:center; gap:12px;}
.dur-step .tbtn.ico{font-size:22px; line-height:1; flex:0 0 auto;}
.dur-step .dur-val{font-size:15px; color:var(--fg);}
/* roomy touch targets, mirror the booking sheet */
.edit-sheet .pick-person{min-height:42px;}
.edit-sheet .time-slot{height:42px; font-size:14px;}
/* the chosen window: start slot solid, the rest of the span tinted */
.edit-grid .time-slot.in-span{background:var(--primary-soft); color:var(--primary-soft-fg); border-color:var(--brand-200);}
.time-grid-note.bad{color:var(--danger-fg);}
.edit-warn{display:inline-flex; align-items:center; gap:6px; color:var(--danger-fg);}
.edit-sheet .sheet-foot{padding:0; margin-top:6px;}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast{position:absolute; left:50%; bottom:22px; transform:translateX(-50%) translateY(20px); z-index:30; background:var(--fg-strong);
  color:#fff; padding:12px 18px; border-radius:var(--radius-btn); font-size:14px; font-weight:500; display:flex; align-items:center; gap:9px;
  box-shadow:var(--shadow-lg); opacity:0; visibility:hidden; transition:all var(--dur-base);}
.toast.show{opacity:1; visibility:visible; transform:translateX(-50%) translateY(0);}
.toast svg{width:18px; height:18px; color:var(--brand-300);}

/* status helpers reused for appointment swatches */
.sw-confirmed{background:var(--primary);} .sw-pending{background:var(--warning);}
.sw-done{background:var(--success);} .sw-cancelled{background:var(--subtle);} .sw-serving{background:var(--accent);}

/* ── Resource calendar host (Lịch hẹn) ─────────────────────────────────── */
.cal-host{height:100%; overflow:auto; padding:18px;}
.cal-foot{padding:12px 16px; border-top:1px solid var(--border);}
/* keep the day-nav arrows / segmented controls vertically aligned in the bar */
.cal-bar .cal-nav button{cursor:pointer;}
.cal-bar .tbtn.sm{height:34px;}
.cal-host .cal-staff{min-height:74px;} .cal-host .cal-lane{min-height:74px;}
.cal-host .appt{font-size:11px;}

/* ── Dashboard bar chart (operational, flat) ───────────────────────────── */
.tchart{display:flex; align-items:flex-end; gap:12px; height:170px; padding:6px 2px 0;}
.tchart .col{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:6px; height:100%;}
.tchart .cv{font-size:10px; color:var(--subtle); font-family:var(--font-mono);}
.tchart .bar{width:100%; max-width:38px; min-height:4px; border-radius:6px 6px 0 0; background:var(--brand-200);}
.tchart .bar.peak{background:linear-gradient(180deg,var(--accent),var(--brand-600));}
.tchart .cx{font-size:11px; color:var(--muted); font-family:var(--font-mono);}
.chart-legend{display:flex; gap:14px; align-items:center; font-size:12px; color:var(--muted);}
.chart-legend i{width:11px; height:11px; border-radius:3px; display:inline-block; margin-right:5px; vertical-align:-1px;}
