/* Rezident — Persian-first RTL clinical UI. Fonts are bundled locally (no CDN). */
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Variable.woff2') format('woff2-variations'), url('../fonts/Vazirmatn-Variable.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/InterVariable.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'VazirmatnStatic'; src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'VazirmatnStatic'; src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'VazirmatnStatic'; src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --fs: 1;
  --bg: #f6f8fa; --surface: #ffffff; --surface-2: #f1f4f7; --surface-3: #e8edf2;
  --text: #17212b; --text-2: #4a5a6a; --muted: #6b7a89; --border: #dde3ea; --border-strong: #c5cfd9;
  --accent: #0e7490; --accent-2: #0b5f76; --accent-soft: #e0f2f6; --on-accent: #fff;
  --sel: rgba(14,116,144,.10); --sel-border: #0e7490;
  --danger: #c0392b; --danger-soft: #fdecea; --warn: #b26a00; --warn-soft: #fff4e0; --ok: #1e7d4f; --ok-soft: #e5f5ec;
  --p-urgent: #c62828; --p-high: #d97706; --p-normal: #2563eb; --p-low: #7b8794;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06); --shadow-lg: 0 12px 32px rgba(16,24,40,.16);
  --sidenav: 220px; --topbar: 56px;
  color-scheme: light;
}
[data-theme=dark] {
  --bg: #0b1220; --surface: #111a2b; --surface-2: #16213a; --surface-3: #1d2a45;
  --text: #e5ebf2; --text-2: #b4c0cd; --muted: #8796a8; --border: #24324a; --border-strong: #33445f;
  --accent: #38bdd8; --accent-2: #67d0e6; --accent-soft: #11313c; --on-accent: #062029;
  --sel: rgba(56,189,216,.13); --sel-border: #38bdd8;
  --danger: #f2776a; --danger-soft: #3a1c1c; --warn: #f0b04a; --warn-soft: #3a2c12; --ok: #4fc58a; --ok-soft: #12301f;
  --p-urgent: #f26b6b; --p-high: #f0a24a; --p-normal: #6aa0ff; --p-low: #8a96a3;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { font-size: calc(15px * var(--fs)); -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Vazirmatn', 'VazirmatnStatic', Tahoma, sans-serif; font-feature-settings: normal; line-height: 1.7; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Bidi: user text decides its own direction per paragraph. Never reordered by script. */
input[dir=auto], textarea[dir=auto], [dir=auto] { unicode-bidi: plaintext; }
bdi { unicode-bidi: isolate; }
textarea { resize: vertical; }
a { color: var(--accent); }
.ic { width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.22em; }
.ic-xs { width: .9em; height: .9em; }
.muted { color: var(--muted); } .small { font-size: .85em; }
.skip { position: absolute; right: -999px; } .skip:focus { right: 8px; top: 8px; z-index: 999; background: var(--surface); padding: 6px 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidenav { width: var(--sidenav); flex: none; background: var(--surface); border-inline-end: 1px solid var(--border); position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 10px; gap: 2px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; padding: 6px 10px 14px; color: var(--accent); }
.brand-ic { width: 1.4em; height: 1.4em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-badge { margin-inline-start: auto; background: var(--danger); color: #fff; border-radius: 99px; font-size: .72rem; min-width: 1.4em; text-align: center; padding: 0 5px; line-height: 1.5; }
.nav-foot { margin-top: auto; padding: 10px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 10px; padding: 0 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.gsearch { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 0 14px; height: 38px; color: var(--muted); }
.gsearch input[type=search] { border: 0; outline: 0; box-shadow: none; min-height: 0; padding: 0; background: transparent; flex: 1; min-width: 0; color: var(--text); }
.hdr-actions { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.save-status { font-size: .78rem; color: var(--muted); padding: 0 8px; white-space: nowrap; }
.save-status[data-state=pending] { color: var(--warn); } .save-status[data-state=error] { color: var(--danger); font-weight: 700; }
.bell { position: relative; }
.bell-badge { position: absolute; top: 2px; left: 2px; background: var(--danger); color: #fff; font-size: .65rem; border-radius: 99px; min-width: 16px; height: 16px; line-height: 16px; text-align: center; padding: 0 3px; }
.view { padding: 18px 22px 90px; outline: none; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 800; }
.page-head .btn, .page-head .cap { margin-inline-start: auto; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.only-sm { display: none; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: .88rem; }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; }
.icon-btn.sm { width: 26px; height: 26px; }
.icon-btn.danger { color: var(--danger); }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 6px 10px; min-height: 36px; outline: none; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1.05em; height: 1.05em; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span:first-child { font-size: .86rem; color: var(--text-2); font-weight: 500; }
.form-grid { display: grid; gap: 4px 14px; }
.form-grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: .86rem; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chips .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-mini { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 10px; color: var(--muted); height: 36px; }
.search-mini input { border: 0; box-shadow: none !important; padding: 0; min-height: 0; background: transparent; }
.datefield { display: flex; gap: 4px; align-items: center; }
.datefield input { width: 8.5em; text-align: center; }
.time-input { width: 5.2em !important; text-align: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: start; }
.tag { font-size: .75rem; background: var(--surface-3); color: var(--text-2); padding: 1px 8px; border-radius: 99px; }
.tag.danger { background: var(--danger-soft); color: var(--danger); }
.notice { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); margin: 8px 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); } .notice.error { background: var(--danger-soft); color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { font-size: 1rem; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.sec { font-size: .95rem; margin: 16px 0 8px; color: var(--text-2); }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty .ic { width: 32px; height: 32px; opacity: .45; }
.empty p { margin: 6px 0; }
ul.plain { list-style: none; padding: 0; margin: 0; } ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--border); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 10px; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
table.simple { width: 100%; border-collapse: collapse; font-size: .92rem; } table.simple th, table.simple td { text-align: start; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; } table.simple th { color: var(--muted); font-weight: 500; }
mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; } [data-theme=dark] mark { background: #6b5310; }

/* priority */
.pri { font-size: .72rem; padding: 0 7px; border-radius: 99px; font-weight: 600; border: 1px solid currentColor; line-height: 1.6; }
.pri-urgent { color: var(--p-urgent); } .pri-high { color: var(--p-high); } .pri-normal { color: var(--p-normal); } .pri-low { color: var(--p-low); }
.pri-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pri-bg-urgent { background: var(--p-urgent); } .pri-bg-high { background: var(--p-high); } .pri-bg-normal { background: var(--p-normal); } .pri-bg-low { background: var(--p-low); }

/* ---------- banners / toasts / menus / modals ---------- */
.banners { padding: 0 22px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-top: 10px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); font-size: .9rem; }
.banner.warn { background: var(--warn-soft); } .banner.error { background: var(--danger-soft); }
.banner .banner-msg { flex: 1; } .banner-actions { display: flex; gap: 6px; }
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: #1f2937; color: #fff; padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .92rem; max-width: min(92vw, 560px); animation: tin .18s ease-out; }
.toast .btn { color: #7dd3fc; } .toast.warn { background: #7c4a03; } .toast.error { background: #7f1d1d; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.menu { position: fixed; z-index: 300; min-width: 200px; max-width: 320px; max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 5px; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: start; }
.menu-item:hover, .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item.danger { color: var(--danger); } .menu-item:disabled { opacity: .4; }
.menu-check { width: 1.2em; display: inline-flex; } .menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-head { font-size: .78rem; color: var(--muted); padding: 4px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.picker { padding: 10px; width: 280px; }
.pk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pk-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.pk-dow { font-size: .75rem; color: var(--muted); }
.pk-day { border: 0; background: none; height: 32px; border-radius: 6px; cursor: pointer; }
.pk-day:hover { background: var(--surface-2); } .pk-day.today { box-shadow: inset 0 0 0 1px var(--accent); } .pk-day.sel { background: var(--accent); color: var(--on-accent); }
.pk-foot { display: flex; justify-content: space-between; margin-top: 6px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(10,16,28,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow: auto; animation: fin .12s; }
.modal-backdrop.out { opacity: 0; transition: opacity .15s; }
@keyframes fin { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: 88vh; }
.modal.sm { max-width: 420px; } .modal.lg { max-width: 720px; }
.modal-head { display: flex; align-items: center; padding: 12px 16px 4px; }
.modal-title { flex: 1; margin: 0; font-size: 1.08rem; }
.modal-body { padding: 8px 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .btn-danger-ghost { margin-inline-end: auto; }
.confirm-body p { margin: 4px 0 8px; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px; text-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.stat:hover { border-color: var(--accent); }
.stat .ic { grid-row: span 2; width: 26px; height: 26px; color: var(--accent); }
.stat-n { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-l { font-size: .82rem; color: var(--muted); }
.stat-overdue .ic, .stat-overdue .stat-n { color: var(--danger); }
.stat-done .ic { color: var(--ok); }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 14px; }
.attention { border-color: var(--warn); background: var(--warn-soft); }
.rem-list-ul, .tl, .tlist, .notif-list, .cardlist { list-style: none; margin: 0; padding: 0; }
.rem-item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 6px; }
.rem-item:hover { background: var(--surface-2); }
.rem-time { display: flex; flex-direction: column; min-width: 92px; } .rem-time small { color: var(--muted); font-size: .76rem; }
.rem-what { flex: 1; min-width: 0; display: flex; flex-direction: column; } .rem-what small { color: var(--muted); }
.rem-desc { font-weight: 500; }
.rem-item.ringing { background: var(--warn-soft); } .rem-item.missed .rem-time b { color: var(--danger); }
.rem-btns { display: flex; gap: 4px; }
.tline { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--border); }
.tline-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: start; background: none; border: 0; cursor: pointer; padding: 0; }
.tline-main small { color: var(--muted); }
.tline.done .tline-desc { text-decoration: line-through; color: var(--muted); }
.tline.overdue .due, .due.overdue { color: var(--danger); font-weight: 600; }
.due { font-size: .85rem; color: var(--text-2); white-space: nowrap; display: inline-flex; gap: 4px; align-items: center; }
.tl.big .tline { padding: 9px 4px; }
.checkbtn { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border-strong); background: var(--surface); cursor: pointer; flex: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; color: #fff; }
.checkbtn:hover { border-color: var(--ok); } .checkbtn.on { background: var(--ok); border-color: var(--ok); } .checkbtn .ic { width: 14px; height: 14px; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.filters .search-mini { max-width: 420px; }
.env-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 6px; }
.cap { background: var(--accent-soft); color: var(--accent); padding: 2px 10px; border-radius: 99px; font-size: .86rem; font-weight: 600; } .cap.full { background: var(--danger-soft); color: var(--danger); }
.st { font-size: .8rem; padding: 1px 8px; border-radius: 99px; background: var(--surface-3); }
.st-scheduled { background: var(--accent-soft); color: var(--accent); } .st-ringing { background: var(--warn-soft); color: var(--warn); } .st-missed { background: var(--danger-soft); color: var(--danger); } .st-snoozed { background: var(--warn-soft); color: var(--warn); }
.nf { display: flex; gap: 10px; align-items: flex-start; padding: 8px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.nf.unread { background: var(--accent-soft); }
.nf-kind { font-size: .75rem; background: var(--surface-3); padding: 1px 8px; border-radius: 99px; flex: none; }
.nf-missed .nf-kind { background: var(--danger-soft); color: var(--danger); }
.nf-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row-card { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.trash-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.snip { color: var(--text-2); font-size: .88rem; white-space: pre-wrap; }
.welcome p { color: var(--text-2); }
.settings .card { max-width: 900px; }
.danger-zone { border-color: var(--danger); }

/* ---------- table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 10px; }
.quickadd { display: flex; gap: 6px; flex: 1 1 260px; max-width: 420px; }
.tb-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tb-group select { width: auto; }
.tb-actions { margin-inline-start: auto; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: var(--accent-soft); padding: 6px 10px; border-radius: var(--radius-sm); margin-bottom: 8px; }
.merge-hint { font-size: .84rem; margin: 0 0 6px; }
.grid-wrap { position: relative; overflow: auto; max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); outline: none; overscroll-behavior: contain; }
.grid-wrap:focus-visible { box-shadow: 0 0 0 2px var(--accent-soft); }
table.grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: .93rem; }
.grid th, .grid td { border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); padding: 0; vertical-align: top; background: var(--surface); }
.grid thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); font-weight: 600; text-align: start; height: 40px; vertical-align: middle; }
.grid .rh, .grid .corner { position: sticky; right: 0; z-index: 2; background: var(--surface-2); }
.grid thead .corner { z-index: 5; text-align: center; }
.grid.sticky-first .stick { position: sticky; right: 104px; z-index: 1; box-shadow: -1px 0 0 var(--border-strong); }
.grid.sticky-first thead .stick { z-index: 4; }
.ch { cursor: grab; }
.ch-inner { display: flex; align-items: center; gap: 4px; padding: 0 8px 0 2px; height: 100%; }
.ch-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-menu { width: 26px; height: 26px; opacity: .55; } .ch:hover .ch-menu { opacity: 1; }
.field-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.col-resizer { position: absolute; left: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 6; touch-action: none; }
.col-resizer:hover, .resizing-col .col-resizer { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
.ch.csel { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.ch.drop-before { box-shadow: inset -3px 0 0 var(--accent); } .ch.drop-after { box-shadow: inset 3px 0 0 var(--accent); }
.ch.col-dragging { opacity: .5; }
.add-col { text-align: center; }
.rh { width: 104px; position: relative; }
.rh-inner { display: flex; align-items: center; gap: 2px; padding: 4px; }
.rh.rsel { background: color-mix(in srgb, var(--surface-2) 70%, var(--accent-soft)); }
.rn { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); cursor: grab; user-select: none; touch-action: none; padding: 4px 0; border-radius: 4px; }
.rn:hover { background: var(--surface-3); color: var(--text); }
.row-menu { width: 24px; height: 24px; opacity: .6; }
.row-resizer { position: absolute; left: 0; right: 0; bottom: -4px; height: 8px; cursor: row-resize; z-index: 3; touch-action: none; }
.row-resizer:hover { background: linear-gradient(180deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
tr.row-dragging td, tr.row-dragging th { opacity: .45; }
.drop-line { position: absolute; right: 0; height: 3px; background: var(--accent); z-index: 10; pointer-events: none; border-radius: 2px; }
tr.row-archived td { color: var(--muted); }
tr.flash td, tr.flash th, .pcard.flash { animation: flash 1.6s; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } }
.cell { position: relative; cursor: cell; }
.cv { padding: 6px 8px; min-height: 34px; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; text-align: start; }
.cell.sel { background: var(--sel); }
.cell.active { box-shadow: inset 0 0 0 2px var(--sel-border); z-index: 1; }
.grid.sticky-first .cell.stick.sel { background: color-mix(in srgb, var(--surface) 88%, var(--accent)); }
.cell.merged .cv { display: flex; align-items: center; min-height: 100%; }
.cell.k-field .cv { font-weight: 500; }
.cell.editing { padding: 0; box-shadow: inset 0 0 0 2px var(--accent); }
.editor { display: block; width: 100%; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; padding: 6px 8px !important; min-height: 34px; resize: none; background: var(--surface); overflow: hidden; white-space: pre-wrap; line-height: inherit; font-size: inherit; }
.filler { background: var(--surface) !important; }
.grid-empty { padding: 30px !important; text-align: center; color: var(--muted); }
.add-row-btn { margin: 6px 4px; position: sticky; right: 0; }
.tchips { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 6px; }
.tchip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border: 1px solid var(--border); border-inline-start: 3px solid var(--p-normal); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; font-size: .82rem; cursor: pointer; text-align: start; }
.tchip:hover { border-color: var(--border-strong); }
.pri-b-urgent { border-inline-start-color: var(--p-urgent); } .pri-b-high { border-inline-start-color: var(--p-high); } .pri-b-low { border-inline-start-color: var(--p-low); }
.tchip.overdue { background: var(--danger-soft); }
.tchip-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tchip-due { color: var(--muted); font-size: .76rem; white-space: nowrap; direction: ltr; }
.tchip.overdue .tchip-due { color: var(--danger); }
.tchip-check { width: 12px; height: 12px; border: 1.5px solid var(--border-strong); border-radius: 3px; flex: none; background: var(--surface); }
.tchip-check:hover { border-color: var(--ok); background: var(--ok-soft); }
.tchip-add { border-style: dashed; border-inline-start-width: 1px; background: none; color: var(--muted); }
.tchip-done-count { font-size: .75rem; color: var(--muted); align-self: center; }
body.resizing-col, body.resizing-col * { cursor: col-resize !important; user-select: none; }
body.resizing-row, body.resizing-row * { cursor: row-resize !important; user-select: none; }

/* cards (mobile table) */
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow); }
.pcard.checked { border-color: var(--accent); }
.pcard-head { display: flex; align-items: center; gap: 8px; }
.pcard-name { flex: 1; text-align: start; background: none; border: 0; font-weight: 700; font-size: 1.02rem; cursor: pointer; padding: 4px 0; min-width: 0; }
.bed-badge { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 0 7px; font-weight: 700; font-size: .85rem; }
.pcard-dx { color: var(--text-2); font-size: .9rem; margin-bottom: 4px; }
.pc-field { padding: 5px 0; border-top: 1px dashed var(--border); cursor: pointer; }
.pc-label { font-size: .76rem; color: var(--muted); }
.pc-val { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; }
.pc-val.empty { color: var(--muted); font-size: .8rem; }
.pc-tasks { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.pc-task { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.pc-task-txt { flex: 1; text-align: start; background: none; border: 0; padding: 4px 0; cursor: pointer; min-width: 0; }
.pc-task.overdue .due { color: var(--danger); }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); border-inline-start: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 90; display: flex; flex-direction: column; animation: din .16s ease-out; }
@keyframes din { from { transform: translateX(-20px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px 4px 8px; }
.drawer-title { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.drawer-title h2 { margin: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { background: var(--surface-3); border-radius: 99px; padding: 0 6px; font-size: .75rem; }
.drawer-body { flex: 1; overflow: auto; padding: 12px 14px 80px; }
.task-quick { max-width: none; margin-bottom: 10px; }
.trow { display: flex; gap: 10px; align-items: flex-start; padding: 8px 2px; border-bottom: 1px solid var(--border); }
.trow .checkbtn { margin-top: 3px; }
.trow-main { flex: 1; min-width: 0; cursor: pointer; }
.trow-desc { font-weight: 500; white-space: pre-wrap; overflow-wrap: anywhere; }
.trow.done .trow-desc { text-decoration: line-through; color: var(--muted); }
.trow-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.trow-notes { font-size: .85rem; color: var(--text-2); white-space: pre-wrap; margin-top: 2px; }
.rem-ind { font-size: .8rem; color: var(--accent); display: inline-flex; align-items: center; gap: 2px; }
.done-block summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.pad { padding: 10px 0; }
.ev-form { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); padding: 10px; border-radius: var(--radius-sm); margin-bottom: 14px; }
.ev-form select { width: auto; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; right: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.ev { position: relative; padding: 0 26px 14px 0; }
.ev-dot { position: absolute; right: 2px; top: 7px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.ev-lab_req .ev-dot, .ev-lab_res .ev-dot { background: #7c3aed; } .ev-consult .ev-dot { background: #d97706; } .ev-procedure .ev-dot { background: #dc2626; } .ev-task_done .ev-dot { background: var(--ok); } .ev-note .ev-dot { background: var(--muted); }
.ev-meta { display: flex; gap: 8px; align-items: center; font-size: .85rem; color: var(--muted); flex-wrap: wrap; } .ev-meta b { color: var(--text); }
.ev-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* task editor */
.task-editor .quick-due .chips { margin-top: 2px; }
.rem-head { display: flex; align-items: baseline; gap: 10px; } .rem-cap.warn { color: var(--danger); font-weight: 700; }
.rem-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; background: var(--surface-2); }
.rem-row.off { opacity: .6; }
.rem-top { display: flex; align-items: center; gap: 10px; } .rem-top .icon-btn { margin-inline-start: auto; }
.rem-when { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.rem-when select { width: auto; }
.rem-opts { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: .9rem; margin-top: 4px; }
.rem-opts select { width: auto; min-height: 30px; padding: 2px 6px; } .rem-opts input[data-f=every] { width: 4em; min-height: 30px; text-align: center; }
.rem-opts label { display: inline-flex; align-items: center; gap: 6px; }
.col-list, .tpl-list { list-style: none; padding: 0; margin: 0 0 10px; }
.col-list li, .tpl-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.col-list .chk { flex: 1; margin: 0; } .col-list-actions, .tpl-actions { display: flex; gap: 2px; margin-inline-start: auto; }
.tpl-list li > div { flex: 1; min-width: 0; }

/* ---------- alarm ---------- */
.alarm-root { position: fixed; z-index: 350; top: 70px; left: 16px; width: min(420px, calc(100vw - 32px)); }
.alarm { background: var(--surface); border: 2px solid var(--warn); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--warn) 25%, transparent), var(--shadow-lg); } }
.alarm-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--warn-soft); color: var(--warn); }
.alarm-head .btn { margin-inline-start: auto; }
.alarm ul { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.alarm li { padding: 10px 12px; border-top: 1px solid var(--border); border-inline-start: 4px solid var(--p-normal); }
.alarm li.pri-l-urgent { border-inline-start-color: var(--p-urgent); } .alarm li.pri-l-high { border-inline-start-color: var(--p-high); }
.alarm-txt { display: flex; flex-direction: column; } .alarm-txt span { white-space: pre-wrap; } .alarm-txt small { color: var(--muted); }
.alarm-btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .alarm { animation: none; } * { animation-duration: .01s !important; } }

/* ---------- lock ---------- */
.lock-screen { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lock-box { background: var(--surface); padding: 28px; border-radius: 16px; box-shadow: var(--shadow-lg); width: min(380px, 100%); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.lock-box h1 { font-size: 1.2rem; margin: 0; } .lock-ic { width: 40px; height: 40px; color: var(--accent); margin: 0 auto; }
.lock-box input { text-align: center; font-size: 1.2rem; letter-spacing: .2em; }
.lock-err { color: var(--danger); min-height: 1.4em; margin: 0; }
body.locked .app, body.locked .bottomnav, body.locked .fab { visibility: hidden; }

/* ---------- mobile ---------- */
.bottomnav, .fab { display: none; }
@media (max-width: 900px) { .hide-sm { display: none; } }
@media (max-width: 760px) {
  .sidenav { display: none; }
  .only-sm { display: inline-flex; }
  .topbar { padding: 0 8px; gap: 4px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar) + env(safe-area-inset-top)); }
  .save-status { display: none; }
  .view { padding: 12px 12px calc(140px + env(safe-area-inset-bottom)); }
  .banners { padding: 0 12px; }
  .bottomnav { display: flex; position: fixed; bottom: 0; right: 0; left: 0; z-index: 80; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 6px; color: var(--muted); text-decoration: none; font-size: .72rem; position: relative; }
  .bn-item .ic { width: 22px; height: 22px; }
  .bn-item.on { color: var(--accent); }
  .bn-item .nav-badge { position: absolute; top: 3px; left: calc(50% - 22px); margin: 0; }
  .fab { display: inline-flex; position: fixed; z-index: 85; bottom: calc(70px + env(safe-area-inset-bottom)); left: 16px; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: var(--on-accent); border: 0; box-shadow: var(--shadow-lg); align-items: center; justify-content: center; }
  .fab .ic { width: 26px; height: 26px; }
  body.drawer-open .fab { display: none; }
  .drawer { width: 100vw; border: 0; }
  .grid-wrap { max-height: calc(100dvh - 250px); }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 16px 16px 0 0; max-width: none !important; }
  .alarm-root { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); left: 8px; right: 8px; width: auto; }
  .dash-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tb-actions { margin-inline-start: 0; }
  .quickadd { max-width: none; }
  .btn, .icon-btn { min-height: 40px; } .icon-btn { width: 40px; }
  .pcards { grid-template-columns: 1fr; }
  .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  table.simple { font-size: .82rem; }
}

/* ---------- print ---------- */
.print-root { display: none; }
@media print {
  body.printing > *:not(.print-root) { display: none !important; }
  body.printing .print-root { display: block; }
  .print-root { font-size: 10pt; color: #000; }
  .print-root h1 { font-size: 13pt; }
  .print-root table { width: 100%; border-collapse: collapse; }
  .print-root th, .print-root td { border: 1px solid #888; padding: 3pt 5pt; vertical-align: top; text-align: start; }
  .print-root thead { display: table-header-group; }
  .print-root tr { page-break-inside: avoid; }
  .print-root .pv { white-space: pre-wrap; unicode-bidi: plaintext; }
  .print-root ul { margin: 0; padding-inline-start: 12pt; }
  @page { size: A4 landscape; margin: 10mm; }
}
/* User-entered text keeps exactly the digits that were typed (no glyph localization). */
.cv, .pc-val, .pcard-dx, .bed-badge, textarea, input, .trow-desc, .trow-notes, .ev-text, .snip, .tchip-txt, .rem-desc, .tline-desc, .alarm-txt span, .print-root .pv { font-feature-settings: "locl" 0; }

/* ---------- simple shell ---------- */
.simple-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 6px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--border); }
.simple-top .brand { padding: 0; font-size: 1.1rem; margin-inline-end: auto; }
.simple-main { padding: 12px 14px 40px; }
.simple-main .toolbar { margin-bottom: 10px; }
.simple-main .search-mini { flex: 1; max-width: 340px; }
.simple-main .grid-wrap { max-height: calc(100dvh - 140px); }
.rem-btn { display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 6px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer; font-size: .74rem; white-space: nowrap; }
.rem-btn:hover { border-color: var(--accent); color: var(--accent); }
.rem-btn.has { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 700; }
.rem-btn.ringing { background: var(--warn); color: #fff; animation: pulse 1.4s infinite; }
.rn { flex: 0 0 auto; min-width: 22px; }
.rl-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rl-item.off { opacity: .55; }
.rl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rl-main small { color: var(--muted); }
.quick-timers { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.rem-form { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.rem-form .row > * { flex: none; }
.rem-form .row label { display: inline-flex; align-items: center; gap: 6px; }
.rem-form select { width: auto; }
@media (max-width: 760px) { .simple-main { padding: 8px 6px 30px; } .simple-main .grid-wrap { max-height: calc(100dvh - 130px); } }
.field-dot { display: none; }

/* ---------- roomy cells + phone-first ---------- */
.simple-main table.grid { font-size: 1rem; }
.simple-main .cv { min-height: 64px; padding: 10px 12px; line-height: 1.85; }
.simple-main .editor { min-height: 64px; padding: 10px 12px !important; line-height: 1.85; }
.simple-main .grid thead th { height: 46px; }
.fulled { position: fixed; inset: 0; z-index: 260; background: var(--surface); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.fulled-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.fulled-title { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.fulled-title b, .fulled-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fulled-title small { color: var(--muted); }
.fulled-ta { flex: 1; width: 100%; border: 0 !important; box-shadow: none !important; border-radius: 0 !important; resize: none; padding: 14px 16px !important; font-size: 17px; line-height: 1.9; background: var(--surface); font-feature-settings: "locl" 0; }
body.fulled-open { overflow: hidden; }
@media (max-width: 760px) {
  html { font-size: calc(16px * var(--fs)); }
  .simple-top { padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .simple-top .icon-btn { width: 42px; height: 42px; }
  .simple-main .toolbar { gap: 6px; position: sticky; top: 0; }
  .simple-main .toolbar .btn { height: 44px; font-size: 1rem; }
  .simple-main .search-mini { height: 44px; flex: 1 1 100%; max-width: none; order: 5; }
  .simple-main .grid-wrap { max-height: calc(100dvh - 175px); border-radius: 8px; -webkit-overflow-scrolling: touch; }
  .simple-main .cv { min-height: 76px; font-size: 16px; }
  .rh { width: 84px; } .grid.sticky-first .stick { right: 84px; }
  .rh-inner { flex-wrap: wrap; justify-content: center; gap: 4px; padding: 6px 2px; }
  .rem-btn { height: 34px; padding: 0 9px; font-size: .8rem; }
  .row-menu { width: 34px; height: 34px; opacity: .8; }
  .grid.sticky-first .stick { position: static; box-shadow: none; }
  .ch-menu { width: 34px; height: 34px; opacity: .8; }
  .col-resizer { width: 16px; left: -8px; }
  .row-resizer { height: 14px; bottom: -7px; }
  .add-row-btn { height: 48px; font-size: 1rem; }
  .modal input, .modal select, .modal textarea { font-size: 16px; }
}

/* ================= Look of the HPI Assistant: white grouped cards on soft grey, one blue accent ================= */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f3; --surface-3: #e7e9ee;
  --text: #14171f; --text-2: #5b6270; --muted: #5b6270; --border: #e7e9ee; --border-strong: #d3d7de;
  --accent: #2456e8; --accent-2: #4b75f0; --accent-soft: #eaf0ff; --on-accent: #ffffff;
  --sel: rgba(36,86,232,.07); --sel-border: #2456e8;
  --danger: #d93a3a; --danger-soft: #fdecec; --warn: #8a5a12; --warn-soft: #fdf4e3; --ok: #1f8a5b; --ok-soft: #e6f4ec;
  --radius: 18px; --radius-sm: 12px; --shadow: none; --shadow-lg: 0 4px 14px rgba(20,23,31,.07), 0 -8px 28px rgba(20,23,31,.10);
}
[data-theme=dark] {
  --bg: #0d0f14; --surface: #171a21; --surface-2: #20242d; --surface-3: #262b35;
  --text: #eef0f4; --text-2: #a0a6b2; --muted: #a0a6b2; --border: #262b35; --border-strong: #353b47;
  --accent: #6d8fff; --accent-2: #8fa9ff; --accent-soft: #1a2647; --on-accent: #0a1430;
  --sel: rgba(109,143,255,.10); --sel-border: #6d8fff;
  --danger: #ff7a6e; --danger-soft: #3a1714; --warn: #fdd68a; --warn-soft: #3a2c10; --ok: #6ce9a6; --ok-soft: #12301f;
  --shadow-lg: 0 4px 16px rgba(0,0,0,.45), 0 -8px 28px rgba(0,0,0,.5);
}
body { font-family: 'Vazirmatn', 'VazirmatnStatic', Tahoma, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.7; }
.simple-top { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); padding-top: max(10px, env(safe-area-inset-top)); }
.simple-top .brand { display: flex; align-items: baseline; gap: 6px; color: var(--accent); }
.brand-en { font-family: 'Inter', 'Vazirmatn', sans-serif; font-weight: 600; letter-spacing: .02em; font-size: 1.05rem; }
.brand small { color: var(--muted); font-weight: 500; font-size: .75rem; }
.simple-top .save-status { display: inline; font-size: .72rem; }
.simple-main { max-width: none; padding: 14px max(16px, env(safe-area-inset-right)) calc(150px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.btn { min-height: 48px; height: auto; border-radius: 12px; border: 1px solid var(--border); font-weight: 700; padding: 0 16px; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-sm { min-height: 38px; font-size: .85rem; padding: 0 12px; }
.btn.block { width: 100%; }
.chip { min-height: 42px; padding: 6px 14px; font-weight: 600; font-size: .9rem; border: 1px solid var(--border); }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea { border: 1px solid var(--border); border-radius: 12px; min-height: 48px; padding: 11px 12px; }
.field > span:first-child { font-size: .82rem; font-weight: 700; color: var(--muted); }
.card { border-radius: 18px; box-shadow: none; }
.simple-main .toolbar { position: static; margin-bottom: 12px; }
.simple-main .search-mini { flex: 1 1 100%; max-width: 640px; height: 48px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.simple-main .grid-wrap { border-radius: 18px; border: 1px solid var(--border); background: var(--surface); max-height: calc(100dvh - 255px); touch-action: pan-x pan-y; }
.grid th, .grid td { border-color: var(--border); }
.grid thead th, .grid .rh, .grid .corner { background: var(--surface-2); }
.grid thead th { font-weight: 700; color: var(--text); }
.ch-title { font-weight: 700; }
.cell.active { box-shadow: inset 0 0 0 2px var(--accent); }
.rem-btn { border-radius: 999px; }
.rem-btn.has { background: var(--accent); color: var(--on-accent); }
.rem-btn.ringing { background: var(--danger); }
.add-row-btn { color: var(--accent); }
/* bottom action bar (like the HPI app) */
.bar { position: fixed; inset: auto 0 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--border); padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.bar-in { max-width: 640px; margin: 0 auto; display: grid; gap: 6px; }
.bar-row { display: flex; gap: 8px; }
.bar-row > .btn { flex: 1; padding: 0 6px; font-size: .88rem; }
.zoom { flex: 1.3; display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.zoom .btn { border: 0; border-radius: 0; min-width: 44px; flex: 1; font-size: 1.25rem; padding: 0; }
.zoom-v { border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; font-size: .82rem; min-width: 56px; cursor: pointer; font-variant-numeric: tabular-nums; }
/* dialogs as bottom sheets */
.modal { border-radius: 18px; }
.modal-foot .btn { min-height: 44px; }
.rem-form { background: var(--surface-2); border-radius: 12px; }
.toast { border-radius: 12px; background: #14171f; }
.toasts { bottom: calc(150px + env(safe-area-inset-bottom)); }
.alarm { border-radius: 18px; border-color: var(--danger); }
.alarm-head { background: var(--danger-soft); color: var(--danger); }
.alarm-root { bottom: calc(150px + env(safe-area-inset-bottom)); top: auto; }
.fulled-head .btn { min-height: 44px; }
.banners { padding: 0 16px; } .banner { border-radius: 12px; }
@media (max-width: 760px) {
  .simple-main { padding: 10px 10px calc(150px + env(safe-area-inset-bottom)); }
  .simple-main .grid-wrap { max-height: calc(100dvh - 250px); }
  .simple-main .toolbar .btn { height: auto; }
  .modal-backdrop { align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; }
  .alarm-root { left: 10px; right: 10px; }
}
.search-mini input[type=search] { border: 0 !important; box-shadow: none !important; min-height: 0; padding: 0; background: transparent; height: 100%; }
.simple-top .brand { white-space: nowrap; }
@media (max-width: 420px) { .simple-top .brand small { display: none; } .simple-top .save-status { display: none; } }
.bar-row { display: grid; grid-template-columns: 1fr 1.35fr 1fr; gap: 8px; }
.bar-row > * { min-width: 0; }
.zoom .btn { min-width: 0; }
.zoom-v { min-width: 0; flex: 1.2; }
.add-row-btn { display: none; }

/* long text: smaller font, clamped preview, first-run hint */
.cell.fs1 .cv { font-size: .93em; line-height: 1.75; }
.cell.fs2 .cv { font-size: .86em; line-height: 1.7; }
.cell.fs3 .cv { font-size: .8em; line-height: 1.65; }
.cell.fs4 .cv { font-size: .75em; line-height: 1.6; }
.cell.clamp .cv { max-height: 15.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.more-tag { display: block; padding: 0 12px 8px; color: var(--accent); font-size: .78rem; font-weight: 700; }
.first-run { display: grid; gap: 6px; max-width: 420px; margin: 0 auto; line-height: 1.9; }
.first-run b { font-size: 1.05rem; color: var(--text); }
.grid-empty { padding: 40px 16px !important; }
.ch { cursor: pointer; }
.fulled-fs { display: flex; gap: 2px; }
.fulled-fs .icon-btn { font-weight: 700; font-family: 'Inter', sans-serif; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; }
.cv:empty::after { content: ''; display: block; }
.grid-empty-out { position: sticky; right: 0; width: min(100%, calc(100vw - 40px)); padding: 36px 16px; text-align: center; color: var(--muted); }

/* ================= compact layout: more room for the table ================= */
.simple-top { padding-block: 6px; }
.simple-top .icon-btn { width: 40px; height: 40px; }
.simple-main .toolbar { display: none; margin: 0 0 8px; }
body.show-search .simple-main .toolbar { display: flex; }
.simple-main { padding: 8px max(10px, env(safe-area-inset-right)) calc(72px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.simple-main .grid-wrap { max-height: calc(100dvh - 140px); }
body.show-search .simple-main .grid-wrap { max-height: calc(100dvh - 196px); }
.simple-main .cv { min-height: 52px; padding: 8px 10px; }
.bar { padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.bar-one { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: 1.15fr 1fr 1.5fr 48px; gap: 6px; }
.bar-one > * { min-width: 0; }
.bar-one .btn { min-height: 48px; padding: 0 8px; font-size: .92rem; gap: 4px; }
.btn-icon { padding: 0 !important; }
.toasts, .alarm-root { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
@media (max-width: 760px) {
  .simple-main { padding: 0 0 calc(66px + env(safe-area-inset-bottom)); }
  .simple-main .grid-wrap { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; max-height: calc(100dvh - 118px); }
  body.show-search .simple-main .toolbar { padding: 6px 8px 0; }
  body.show-search .simple-main .grid-wrap { max-height: calc(100dvh - 172px); }
  .simple-main .cv { min-height: 56px; padding: 8px 10px; font-size: 15.5px; }
  .simple-main .grid thead th { height: 42px; }
  .rh { width: 84px; }
  .rh-inner { padding: 4px 2px; gap: 2px; }
}
/* row bell with countdown */
.rem-btn { min-height: 32px; font-weight: 700; }
.rem-btn.has { padding: 0 8px; }
/* one-tap alarm sheet */
.alarm-sheet { display: grid; gap: 10px; }
.as-label { min-height: 48px; }
.as-hint { margin: 0; color: var(--muted); font-size: .8rem; }
.as-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.as-chip { font: inherit; font-weight: 700; min-height: 54px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.as-chip:active { background: var(--accent); color: var(--on-accent); transform: scale(.97); }
.as-chip:last-child { grid-column: span 3; background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.as-custom { background: var(--surface-2); border-radius: 14px; padding: 4px 12px; }
.as-custom summary { cursor: pointer; font-weight: 700; padding: 10px 0; color: var(--accent); }
.as-form { display: grid; gap: 10px; padding-bottom: 12px; }
.as-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.as-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.as-row select { width: auto; }
.as-every { width: 4em !important; text-align: center; }
.as-list { display: grid; gap: 6px; }
.as-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.as-item.ring { border-color: var(--danger); background: var(--danger-soft); }
.as-item.off { opacity: .5; }
.as-main { flex: 1; min-width: 0; display: grid; } .as-main small { color: var(--muted); }
/* big alarm card */
.alarm li { padding: 14px; }
.alarm-txt b { font-size: 1.05rem; }
.alarm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.alarm-btns .btn { min-height: 50px; }
.alarm-btns .btn-primary { grid-column: span 2; min-height: 56px; font-size: 1.05rem; }

/* =====================================================================
   REDESIGN v2 — calm "sheet" look (HPI Assistant palette), phone first
   ===================================================================== */
.simple-top { gap: 2px; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left)); padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.tb-title { display: flex; align-items: baseline; gap: 8px; margin-inline-end: auto; min-width: 0; }
.tb-title h1 { margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.tb-count { color: var(--muted); font-size: .85rem; font-weight: 600; }
.simple-top .icon-btn { width: 42px; height: 42px; border-radius: 12px; color: var(--text); }
.simple-top .save-status { display: none; }
.simple-main { padding: 0 0 calc(96px + env(safe-area-inset-bottom)) !important; }
.simple-main .toolbar { padding: 8px 12px 0; }
.simple-main .grid-wrap { border: 0 !important; border-radius: 0 !important; background: var(--bg); max-height: calc(100dvh - 58px) !important; }
body.show-search .simple-main .grid-wrap { max-height: calc(100dvh - 120px) !important; }
@media (min-width: 761px) { .simple-main { padding: 12px 16px 96px !important; } .simple-main .grid-wrap { border: 1px solid var(--border) !important; border-radius: 16px !important; max-height: calc(100dvh - 90px) !important; } }

table.grid.sheet { border-collapse: separate; border-spacing: 0; background: var(--surface); }
.grid.sheet th, .grid.sheet td { border: 0; border-bottom: 1px solid var(--border); border-inline-start: 1px solid var(--border); background: var(--surface); }
.grid.sheet thead th { height: 40px; background: var(--surface); color: var(--muted); font-size: .8rem; font-weight: 700; border-bottom: 1px solid var(--border-strong); }
.grid.sheet .ch-inner { padding: 0 12px; }
.grid.sheet .ch-title { font-weight: 700; color: var(--text-2); }
.grid.sheet th.ch:active { background: var(--surface-2); }
.grid.sheet .stick { position: sticky; right: 0; z-index: 2; box-shadow: -1px 0 0 var(--border-strong); }
.grid.sheet thead .stick { z-index: 4; }
.grid.sheet .cv { min-height: 0 !important; padding: 12px 14px !important; font-size: 15px; line-height: 1.8; color: var(--text); }
.grid.sheet td.cell { cursor: pointer; }
.grid.sheet td.cell:active { background: var(--surface-2); }
.grid.sheet .cell.sel { background: var(--accent-soft); }
.grid.sheet .cell.active { box-shadow: inset 0 0 0 2px var(--accent); }
.grid.sheet tbody tr { height: 64px; }
.head-cell .hc { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 4px; }
.head-cell .hc .cv { padding: 0 !important; font-weight: 700; font-size: 15.5px; flex: 1; min-width: 0; }
.head-cell .ph { color: var(--muted); font-weight: 500; }
.hc-n { flex: none; min-width: 22px; height: 22px; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 800; display: grid; place-items: center; margin-top: 2px; }
.rem-pill { display: inline-flex; align-items: center; gap: 4px; margin: 2px 12px 10px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .76rem; font-weight: 800; }
.rem-pill.ringing { background: var(--danger); color: #fff; animation: pulse 1.3s infinite; }
.add-col { background: var(--surface) !important; text-align: center; vertical-align: middle !important; }
.add-col-btn { width: 32px; height: 32px; border-radius: 10px; border: 1.5px dashed var(--border-strong); background: none; color: var(--accent); cursor: pointer; display: inline-grid; place-items: center; }
.filler { background: var(--surface) !important; border-inline-start: 0 !important; }
.grid-empty-out { padding: 60px 24px; }
.first-run { line-height: 2.1; color: var(--muted); }
.first-run b { color: var(--text); }
.col-resizer { display: none; }
@media (min-width: 761px) { .col-resizer { display: block; } }
.bar { display: none !important; }
.fab-add { position: fixed; z-index: 50; left: max(18px, env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 24px rgba(36,86,232,.35); display: grid; place-items: center; cursor: pointer; }
.fab-add .ic { width: 28px; height: 28px; stroke-width: 2.4; }
.fab-add:active { transform: scale(.94); }
.toasts { bottom: calc(92px + env(safe-area-inset-bottom)) !important; }
.alarm-root { bottom: calc(92px + env(safe-area-inset-bottom)) !important; }

/* bottom sheet */
.modal.sheet { max-width: 560px; }
.modal.sheet .modal-head { padding: 14px 18px 2px; }
.modal.sheet .modal-title { font-size: 1.2rem; font-weight: 800; }
.modal.sheet .modal-body { padding: 6px 16px calc(18px + env(safe-area-inset-bottom)); }
.modal.sheet::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 8px auto 0; }
.rs-sec { font-size: .78rem; font-weight: 800; color: var(--muted); margin: 6px 4px -2px; }
.rs-list { background: var(--surface-2); border-radius: 16px; overflow: hidden; display: grid; }
.rs-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; font-weight: 600; color: var(--text); text-align: start; cursor: pointer; }
.rs-item:last-child { border-bottom: 0; }
.rs-item:active { background: var(--surface-3); }
.rs-item:disabled { opacity: .35; }
.rs-item.danger { color: var(--danger); }
.rs-item .ic { width: 20px; height: 20px; color: var(--accent); }
.rs-item.danger .ic { color: var(--danger); }
.as-grid { gap: 8px; }
.as-chip { min-height: 50px; border-radius: 14px; background: var(--surface-2); border: 0; font-size: .95rem; }
.as-chip:last-child { background: var(--accent-soft); }
.as-label { background: var(--surface-2) !important; border: 0 !important; }
.as-hint { display: none; }
.alarm-sheet { gap: 10px; }
.rem-pill { flex-wrap: wrap; line-height: 1.6; }

/* ================= «ستونی» layout ================= */
.tgrid-wrap { overflow: auto; max-height: calc(100dvh - 58px); background: var(--bg); scroll-snap-type: x proximity; overscroll-behavior: contain; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
body.show-search .tgrid-wrap { max-height: calc(100dvh - 120px); }
table.tgrid { border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--surface); }
.tgrid th, .tgrid td { border-bottom: 1px solid var(--border); vertical-align: top; background: var(--surface); }
.tgrid td, .tgrid thead th.pt-head { border-inline-start: 1px solid var(--border); }
/* sticky field titles (right) */
.tgrid .f-label { position: sticky; right: 0; z-index: 2; background: var(--surface-2); text-align: start; padding: 12px 10px 12px 8px; font-size: .8rem; font-weight: 800; color: var(--text-2); line-height: 1.5; cursor: pointer; box-shadow: -1px 0 0 var(--border-strong); overflow-wrap: anywhere; }
.tgrid .f-label span { display: block; position: sticky; top: 72px; }
.tgrid .f-label:active { background: var(--surface-3); }
/* sticky patient headers (top) */
.tgrid thead th { position: sticky; top: 0; z-index: 3; }
.tgrid .t-corner { right: 0; z-index: 5; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; vertical-align: middle; text-align: center; box-shadow: -1px 0 0 var(--border-strong), 0 1px 0 var(--border-strong); }
.tgrid .pt-head { background: var(--surface); text-align: start; padding: 10px 12px 8px; cursor: pointer; scroll-snap-align: start; scroll-margin-right: 96px; box-shadow: 0 1px 0 var(--border-strong); }
.tgrid .pt-head:active { background: var(--surface-2); }
.pt-in { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pt-n { flex: none; min-width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 800; display: grid; place-items: center; }
.pt-name { font-size: 1.02rem; font-weight: 800; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.pt-bed { flex: none; background: var(--surface-2); color: var(--text-2); border-radius: 7px; padding: 0 7px; font-size: .78rem; font-weight: 700; }
.tgrid .rem-pill { margin: 6px 0 0; }
.tgrid .tcell { cursor: pointer; }
.tgrid .tcell .cv { padding: 12px 14px; min-height: 52px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.8; }
.tgrid .tcell:active { background: var(--surface-2); }
.tgrid .tcell.fs1 .cv { font-size: 14px; } .tgrid .tcell.fs2 .cv { font-size: 13.2px; } .tgrid .tcell.fs3 .cv { font-size: 12.5px; } .tgrid .tcell.fs4 .cv { font-size: 12px; }
.tgrid .tcell.clamp .cv { max-height: 15.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.tgrid tr.add-field-row td, .tgrid tr.add-field-row th { border-bottom: 0; background: var(--bg); box-shadow: none; }
.tgrid .add-f button { display: flex; align-items: center; gap: 4px; border: 1.5px dashed var(--border-strong); background: var(--surface); color: var(--accent); border-radius: 10px; font: inherit; font-size: .78rem; font-weight: 800; padding: 6px 8px; cursor: pointer; width: 100%; justify-content: center; }
.tgrid .flash { animation: flash 1.6s; }
.tgrid .empty-col { background: var(--bg) !important; border: 0 !important; box-shadow: none !important; }
@media (min-width: 761px) { .tgrid-wrap { border: 1px solid var(--border); border-radius: 16px; max-height: calc(100dvh - 90px); } }

/* ===== v3: vertical, high-contrast titles + obvious "add" affordances ===== */
.tgrid .f-label { width: 46px; padding: 0 !important; background: var(--accent) !important; color: var(--on-accent) !important; box-shadow: -1px 0 0 var(--accent) !important; border-bottom: 1px solid rgba(255,255,255,.25) !important; vertical-align: top; text-align: center; }
.tgrid .f-label .vt { position: sticky; top: 70px; display: inline-block; writing-mode: vertical-rl; text-orientation: mixed; font-size: .88rem; font-weight: 800; letter-spacing: .02em; padding: 14px 0; line-height: 46px; height: auto; max-height: 70vh; white-space: nowrap; color: inherit; }
.tgrid .f-label:active { background: var(--accent-2) !important; }
.tgrid .t-corner { background: var(--accent) !important; box-shadow: none !important; }
.tgrid tr.add-field-row th.f-label { background: var(--bg) !important; box-shadow: none !important; }
.tgrid .add-f-cell { background: var(--bg) !important; border: 0 !important; padding: 10px; }
.ghost-add { font: inherit; font-weight: 800; color: var(--accent); background: var(--surface); border: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.ghost-add .ic { width: 20px; height: 20px; }
.ghost-add.row { width: 100%; min-height: 52px; font-size: .9rem; position: sticky; right: 56px; max-width: calc(100vw - 70px); }
.tgrid .ghost-head { background: var(--bg) !important; border: 0 !important; box-shadow: none !important; vertical-align: top; padding: 10px 10px 10px 12px; position: static; }
.tgrid .ghost-head .ghost-add { flex-direction: column; width: 100%; min-height: 120px; font-size: .85rem; position: sticky; top: 10px; }
.tgrid .tcell .ph { color: var(--muted); opacity: .55; font-size: .85rem; }
.tgrid .tcell .cv { min-height: 64px; }
/* alarm sheet v3 */
.as-step { font-size: .8rem; font-weight: 800; color: var(--text-2); margin: 4px 2px -4px; }
.as-step small { color: var(--muted); font-weight: 600; }
.segs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg { font: inherit; border: 0; background: none; border-radius: 11px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-size: .8rem; font-weight: 700; color: var(--muted); cursor: pointer; line-height: 1.4; }
.seg.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(20,23,31,.12); }
.rchips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.rchip { flex: none; font: inherit; font-size: .85rem; font-weight: 700; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.rchip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.as-exact { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 14px; padding: 8px 10px; }
.as-exact > span:first-child { font-weight: 700; font-size: .88rem; white-space: nowrap; }
.as-exact .time-input { flex: 1; width: auto !important; min-height: 44px; font-size: 1.05rem; }
.as-exact .btn { min-height: 44px; }
.as-custom { display: none; }
.tgrid .ghost-cell { background: var(--bg) !important; border: 0 !important; }
.tgrid .ghost-head .ghost-add { min-height: 64px; }
.alarm-sheet > * { min-width: 0; }
.modal-body { overflow-x: hidden; }
.as-exact { flex-wrap: nowrap; } .as-exact .time-input { min-width: 0; }
.tgrid .ghost-cell .ghost-add.row { min-height: 64px; position: static; max-width: none; }
.as-exact .slot-t { flex: 1 1 0; min-width: 0; }
.as-exact .slot-t .time-input { width: 100% !important; }
.as-exact .btn { flex: none; }

/* v4: wider, clearer title strip + handy "add title" button in the corner */
.tgrid .f-label { width: 62px; }
.tgrid .f-label .vt { font-size: 1rem; line-height: 62px; padding: 16px 0; }
.ghost-add.row { right: 72px; max-width: calc(100vw - 86px); }
.tgrid .t-corner { padding: 6px !important; vertical-align: middle !important; }
.corner-add { width: 100%; min-height: 64px; border: 0; border-radius: 12px; background: rgba(255,255,255,.18); color: #fff; font: inherit; font-size: .72rem; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.corner-add .ic { width: 22px; height: 22px; stroke-width: 2.4; }
.corner-add:active { background: rgba(255,255,255,.32); }

/* v5: pasted/long content can never spill outside its own cell */
.tgrid td, .tgrid th { overflow: hidden; overflow: clip; }
.tgrid .tcell .cv, .tgrid .pt-name, .cv { overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
.tgrid .f-label .vt { white-space: normal; word-break: break-word; max-height: none; max-inline-size: 60vh; }
.tgrid .pt-head .pt-in { max-width: 100%; overflow: hidden; }
.fulled-ta { overflow-wrap: anywhere; }
.menu-head, .modal-title { overflow-wrap: anywhere; }

/* v6: bed in a blue box beside the name, full titles, visible delete */
.pt-in { align-items: flex-start; }
.pt-name { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; line-height: 1.5; padding-top: 4px; overflow-wrap: anywhere; }
.pt-n { display: none; }
.pt-bedbox { flex: none; min-width: 48px; min-height: 48px; padding: 2px 6px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; cursor: pointer; font: inherit; }
.pt-bedbox small { font-size: .62rem; font-weight: 700; opacity: .85; }
.pt-bedbox b { font-size: 1.05rem; font-weight: 800; max-width: 86px; overflow-wrap: anywhere; }
.pt-bedbox.empty { background: var(--accent-soft); color: var(--accent); border: 1.5px dashed var(--accent); }
.pt-bedbox:active { transform: scale(.95); }
.tgrid th.f-label { overflow: visible !important; }
.tgrid .f-label .vt { position: static !important; white-space: normal !important; word-break: normal; overflow-wrap: anywhere; max-inline-size: none !important; padding: 14px 0; line-height: 1.5; }
.sheet-del { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); color: var(--danger); border-radius: 12px; min-height: 40px; padding: 0 14px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; justify-self: end; }
.sheet-del .ic { width: 18px; height: 18px; }
.toast { width: min(92vw, 440px); justify-content: space-between; }
.toast .toast-msg { flex: 1; min-width: 0; }

/* v7: continuous vertical titles (one unbroken line), editable table name, generic wording */
.tgrid .f-label .vt { white-space: nowrap !important; overflow-wrap: normal !important; word-break: keep-all !important; writing-mode: vertical-rl; text-orientation: mixed; padding: 16px 0 !important; line-height: 62px; font-size: .95rem; }
.tb-name { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; min-width: 0; text-align: start; }
.tb-name h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.sheet-top { display: flex; gap: 8px; }
.sheet-edit { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--accent); border-radius: 12px; min-height: 40px; padding: 0 14px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.sheet-edit .ic { width: 18px; height: 18px; }

/* v8: companion alarm/done column next to every column + room to scroll past the last row */
.tgrid .side-head { background: var(--surface-2) !important; text-align: center; vertical-align: middle; padding: 4px 2px; box-shadow: 0 1px 0 var(--border-strong); border-inline-start: 1px dashed var(--border) !important; }
.tgrid .side-head span { color: var(--accent); display: block; }
.tgrid .side-head small { display: block; font-size: .58rem; font-weight: 700; color: var(--muted); line-height: 1.3; }
.tgrid .side-cell { background: var(--surface-2) !important; border-inline-start: 1px dashed var(--border) !important; padding: 8px 4px; text-align: center; vertical-align: top; }
.done-box { width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--border-strong); background: var(--surface); color: #fff; cursor: pointer; display: grid; place-items: center; margin: 0 auto 8px; padding: 0; }
.done-box .ic { width: 20px; height: 20px; stroke-width: 3; }
.done-box.on { background: var(--ok); border-color: var(--ok); }
.cell-alarm { width: 100%; min-height: 54px; border-radius: 10px; border: 1.5px dashed var(--border-strong); background: var(--surface); color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 4px 2px; font: inherit; line-height: 1.25; }
.cell-alarm.has { border: 0; background: var(--accent-soft); color: var(--accent); }
.cell-alarm.ring { background: var(--danger); color: #fff; animation: pulse 1.3s infinite; }
.cell-alarm b { font-size: .82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.cell-alarm small { font-size: .62rem; font-weight: 700; }
.cell-alarm .ca-ic { font-size: .95rem; line-height: 1.2; }
.cell-alarm .ca-type { opacity: .8; }
.ca-add { display: flex; flex-direction: column; align-items: center; color: var(--accent); }
.tgrid .tcell.is-done { background: var(--ok-soft) !important; }
.tgrid .tcell.is-done .cv { color: var(--text-2); }
.tgrid .side-cell.is-done { background: var(--ok-soft) !important; }
.scroll-spacer { height: 45vh; }
.tgrid-wrap { padding-bottom: env(safe-area-inset-bottom); }
.tgrid .add-f-cell { padding: 12px 10px 16px; }
.ghost-add.row { min-height: 56px; }

/* v9: brand + live clock/date box on top; roomier, smaller-font alarm cells */
.simple-top { flex-direction: column; align-items: stretch; gap: 8px; padding-bottom: 6px; }
.hero { display: flex; align-items: stretch; gap: 10px; }
.hero-brand { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.hero-brand b { font-family: 'Inter', 'Vazirmatn', sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--accent); letter-spacing: -.01em; direction: ltr; text-align: right; }
.hero-brand small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.hero-clock { flex: none; background: var(--accent); color: #fff; border-radius: 14px; padding: 6px 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 128px; line-height: 1.25; }
.hc-time { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.hc-date { font-size: .7rem; font-weight: 700; opacity: .9; white-space: nowrap; }
.bar2 { display: flex; align-items: center; gap: 2px; }
.bar2 .tb-title h1 { font-size: 1.1rem; }
.simple-main .tgrid-wrap, .tgrid-wrap { max-height: calc(100dvh - var(--hdr, 120px)) !important; }
body.show-search .tgrid-wrap { max-height: calc(100dvh - var(--hdr, 120px) - 62px) !important; }
.tgrid .side-cell { padding: 6px 4px; }
.done-box { width: 30px; height: 30px; border-radius: 9px; margin-bottom: 6px; }
.done-box .ic { width: 17px; height: 17px; }
.cell-alarm { min-height: 48px; }
.cell-alarm b { font-size: .74rem; }
.cell-alarm small { font-size: .56rem; }
.cell-alarm .ca-ic { font-size: .8rem; }
.tgrid .side-head small { font-size: .54rem; }
.as-clock { background: var(--surface-2); border-radius: 14px; padding: 10px; display: grid; gap: 10px; }
.day-chips { display: flex; gap: 6px; }
.day-chips .rchip { flex: 1; }
.hm { display: flex; align-items: center; justify-content: center; gap: 8px; direction: ltr; }
.hm select { width: 96px !important; min-height: 58px; font-size: 1.6rem; font-weight: 800; text-align: center; text-align-last: center; border-radius: 14px; background: var(--surface); font-variant-numeric: tabular-nums; }
.hm b { font-size: 1.6rem; font-weight: 800; }
.as-exact { display: none !important; }
.as-chip { min-height: 44px; font-size: .88rem; }

.hm input { width: 92px !important; min-height: 64px; font-size: 2rem !important; font-weight: 800; text-align: center; border-radius: 14px; font-variant-numeric: tabular-nums; padding: 0 !important; }
.hm-hint { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: .74rem; }
.droid { min-height: 44px !important; font-size: .85rem; color: var(--text-2); }

/* v11: message + "put it on the phone" step */
.as-msg-l { font-size: .82rem; font-weight: 800; color: var(--text-2); margin-bottom: -4px; }
.as-msg-l small { font-weight: 600; color: var(--muted); }
textarea.as-label { min-height: 74px !important; resize: none; line-height: 1.8; font-size: 15px; }
.done-step { display: grid; gap: 10px; text-align: center; padding: 4px 0 6px; }
.ok-ic { width: 56px; height: 56px; border-radius: 18px; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto; }
.ok-ic .ic { width: 30px; height: 30px; stroke-width: 3; }
.done-step > b { font-size: 1.05rem; }
.ds-when { color: var(--accent); font-weight: 800; }
.ds-msg { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; margin: 0; white-space: pre-wrap; text-align: start; }
.ds-box { display: grid; gap: 8px; background: var(--accent-soft); border-radius: 16px; padding: 12px; text-align: start; }
.ds-box small { color: var(--text-2); line-height: 1.7; }

/* v12: dual calendar clock, help, footer */
.hero-clock { padding: 6px 14px; }
.hc-gdate { font-size: .66rem; font-weight: 700; opacity: .85; font-family: 'Inter', 'Vazirmatn', sans-serif; white-space: nowrap; }
.help-btn { font-weight: 800; font-size: 1.1rem; font-family: 'Inter', 'Vazirmatn', sans-serif; }
.help { display: grid; gap: 10px; }
.hp-lead { margin: 0; background: var(--accent-soft); border-radius: 14px; padding: 10px 12px; line-height: 1.9; }
.hp-sec { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.hp-ic { font-size: 1.3rem; line-height: 1.6; flex: none; }
.hp-sec > div > b { display: block; margin-bottom: 2px; }
.hp-sec p { margin: 0; font-size: .88rem; color: var(--text-2); line-height: 1.9; }
.app-foot { position: sticky; right: 0; width: min(100vw, 640px); box-sizing: border-box; padding: 28px 18px calc(110px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.af-brand { font-family: 'Inter', 'Vazirmatn', sans-serif; font-weight: 800; color: var(--accent); font-size: 1.05rem; direction: ltr; }
.af-brand span { font-family: 'Vazirmatn', sans-serif; color: var(--muted); font-weight: 600; font-size: .75rem; }
.af-by { margin: 0; color: var(--text); }
.af-save { margin: 0; font-size: .78rem; color: var(--ok); font-weight: 700; }
.af-legal { margin: 0; font-size: .7rem; line-height: 1.9; max-width: 520px; }
.fulled-auto { font-size: .68rem; color: var(--ok); font-weight: 700; white-space: nowrap; }
.scroll-spacer { display: none; }

/* v13: locked default zoom (two columns), free scrolling, no page zoom */
html, body { touch-action: pan-x pan-y; }
.tgrid-wrap { scroll-snap-type: none !important; }
.tgrid .tcell .cv { font-size: 16px; }
.ds-how { background: var(--surface); border-radius: 12px; padding: 4px 12px; }
.ds-how summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 8px 0; font-size: .86rem; }
.ds-how p { margin: 0 0 8px; font-size: .84rem; line-height: 1.9; color: var(--text-2); }

.ds-note, .as-open-note { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 8px 12px; font-size: .8rem; line-height: 1.8; text-align: start; margin: 0; }
.snd-save { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; margin-top: 6px; }
.snd-save p { font-size: .8rem; color: var(--text-2); line-height: 1.8; margin: 4px 0 8px; }
.snd-save .row { gap: 6px; }
.snd-save a.btn { text-decoration: none; }

/* v14: images in cells + per-alarm sound chips */
.cell-imgs { display: grid; gap: 6px; padding: 0 10px 10px; }
.cell-img { display: block; width: 100%; height: auto; max-width: 100%; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); cursor: zoom-in; min-height: 40px; object-fit: contain; }
.cell-img.missing { min-height: 0; display: none; }
.tgrid .tcell .cv:empty { min-height: 10px; padding-bottom: 4px; }
.fulled-imgs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.fulled-imgs .fi { position: relative; flex: none; }
.fulled-imgs img { height: 72px; width: auto; border-radius: 10px; display: block; border: 1px solid var(--border); }
.fulled-imgs button { position: absolute; top: -6px; left: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-weight: 800; cursor: pointer; line-height: 1; }
.fe-img { white-space: nowrap; }
.imgview { position: fixed; inset: 0; z-index: 500; background: rgba(5,8,14,.94); display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.iv-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.iv-bar .iv-hint { flex: 1; color: #aab; font-size: .75rem; text-align: center; }
.iv-bar .btn { background: rgba(255,255,255,.1); color: #fff; border-color: transparent; }
.iv-bar .btn-danger-ghost { color: #ff8a80; }
.iv-stage { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: pan-x pan-y; }
.iv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.snd-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.rchip.snd { font-size: .8rem; }
.imgview { z-index: 190 !important; }
.tgrid tr.add-field-row td, .tgrid tr.add-field-row th { background: var(--bg) !important; border: 0 !important; }

/* logo */
.hero-logo { width: 46px; height: 46px; flex: none; align-self: center; border-radius: 12px; box-shadow: 0 4px 12px rgba(36,86,232,.25); }
.hero { align-items: center; }
.hero-brand b { text-align: start; direction: ltr; }
.af-logo { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 6px 18px rgba(36,86,232,.25); }
.af-brand { color: var(--text) !important; } .af-brand i { font-style: normal; color: var(--accent); }
.hp-logo { display: flex; align-items: center; gap: 10px; justify-content: center; direction: ltr; }
.hp-logo img { width: 52px; height: 52px; border-radius: 14px; }
.hp-logo b { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 1.4rem; } .hp-logo span { color: var(--accent); }
table.tgrid { background: transparent !important; }
