/* =====================================================================
   JJ Diary – styles (tablet-first, high contrast, S-Pen friendly)
   Brand colours: change --brand / --accent to match jiwanjyothiindustry.com
   ===================================================================== */
:root {
  --brand: #14284b; --brand-2: #1f3b6e; --accent: #e8590c; --accent-2: #ff922b;
  --bg: #eef1f6; --surface: #ffffff; --surface-2: #f6f8fb; --line: #d9e0ea; --text: #111a2b; --muted: #5f6b7d;
  --pending: #1971c2; --progress: #7048e8; --done: #2f9e44; --postponed: #f08c00; --overdue: #e03131;
  --high: #e03131; --medium: #f08c00; --low: #2f9e44;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.07);
  --top: 58px; --nav: 92px; --tap: 44px;
  font-size: 16px;
}
[data-theme="dark"] {
  --bg: #0e1420; --surface: #172030; --surface-2: #1d2839; --line: #2c3a50; --text: #e8edf5; --muted: #9aa8bc; --brand: #0b1730; --brand-2: #22406f;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
[data-theme="contrast"] {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #ffffff; --line: #000000; --text: #000000; --muted: #222222; --brand: #000000; --accent: #c92a2a;
  --shadow: none;
}
[data-theme="contrast"] .card, [data-theme="contrast"] .task, [data-theme="contrast"] .btn { border-width: 2px !important; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", Roboto, "Noto Sans", system-ui, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--pending); }
h2 { margin: 0; font-size: 1.45rem; } h3 { margin: 0; font-size: 1.05rem; } h4 { margin: 18px 0 8px; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .pad { padding: 24px; } .grow { flex: 1; }
mark { background: #ffe066; color: #000; border-radius: 3px; padding: 0 2px; }

/* ---------------- buttons & inputs ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--tap); padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; touch-action: manipulation; }
.btn:hover { border-color: var(--brand-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--overdue); border-color: var(--overdue); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--overdue); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn.xs { min-height: 28px; padding: 0 8px; font-size: .8rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; width: 100%; }
.btn:disabled { opacity: .45; }
.icon-btn { width: var(--tap); height: var(--tap); border-radius: 10px; border: 0; background: transparent; font-size: 1.25rem; cursor: pointer; display: inline-grid; place-items: center; position: relative; flex: none; }
.icon-btn:hover { background: rgba(127,127,127,.12); }
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea) {
  min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,89,12,.15); }
textarea { resize: vertical; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .78rem; white-space: nowrap; cursor: pointer; }
.chip.cust { background: #e7f5ff; border-color: #a5d8ff; color: #1864ab; } .chip.model { background: #f3f0ff; border-color: #d0bfff; color: #5f3dc4; }
.chip.money { background: #ebfbee; border-color: #b2f2bb; color: #2b8a3e; } .chip.warn { background: #fff4e6; border-color: #ffd8a8; color: #d9480f; }
.chip.post { background: #fff9db; border-color: #ffec99; color: #e67700; } .chip.tag { color: var(--muted); } .chip.t { font-weight: 600; }
[data-theme="dark"] .chip.cust, [data-theme="dark"] .chip.model, [data-theme="dark"] .chip.money, [data-theme="dark"] .chip.warn, [data-theme="dark"] .chip.post { background: var(--surface-2); }

/* ---------------- login ---------------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), #2a4a85 60%, var(--accent)); overflow: auto; padding: 20px; }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 18px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-card label { text-align: left; font-weight: 600; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.login-logo { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto; }
.login-card h1 { margin: 0; color: var(--brand); }
.adv { text-align: left; } .adv summary { cursor: pointer; color: var(--muted); padding: 6px 0; } .adv > * { margin-top: 8px; }
.note-box, .err-box, .ok-box { padding: 10px 14px; border-radius: 10px; text-align: left; }
.note-box { background: #e7f5ff; color: #1864ab; } .err-box { background: #fff5f5; color: #c92a2a; border: 1px solid #ffc9c9; } .ok-box { background: #ebfbee; color: #2b8a3e; }

/* ---------------- app shell ---------------- */
.app { display: grid; grid-template-columns: var(--nav) 1fr; grid-template-rows: var(--top) 1fr; height: 100vh; height: 100dvh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--brand); color: #fff; z-index: 20; padding-top: env(safe-area-inset-top); }
.topbar .icon-btn { color: #fff; } .topbar .icon-btn:hover { background: rgba(255,255,255,.12); }
.brand { display: flex; align-items: center; gap: 10px; } .brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand b { display: block; font-size: 1.05rem; line-height: 1.1; } .brand small { font-size: .72rem; opacity: .75; }
.top-date { flex: 1; text-align: center; font-size: .95rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.nav-toggle { display: none; }
.badge { position: absolute; top: 3px; right: 1px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--overdue); color: #fff; font-size: .7rem; font-weight: 700; display: grid; place-items: center; animation: pulse 2s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.sync { font-size: .75rem; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.14); margin-right: 6px; white-space: nowrap; }
.sync::before { content: '●'; margin-right: 5px; } .sync.ok::before { color: #69db7c; } .sync.pend::before { color: #ffd43b; } .sync.off::before { color: #ff8787; } .sync.local::before { color: #74c0fc; }
.sidenav { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px 6px; gap: 2px; overflow-y: auto; z-index: 15; }
.sidenav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px; border-radius: 12px; cursor: pointer; font-size: .74rem; font-weight: 600; color: var(--muted); text-decoration: none; user-select: none; }
.sidenav a i { font-style: normal; font-size: 1.4rem; }
.sidenav a:hover { background: var(--surface-2); }
.sidenav a.on { background: var(--brand); color: #fff; }
.view { overflow-y: auto; padding: 18px 22px 40px; -webkit-overflow-scrolling: touch; position: relative; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .head-acts input[type=date] { width: auto; }
.row { display: flex; gap: 8px; align-items: center; } .row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------------- dashboard ---------------- */
.warn-banner { background: #fff4e6; border: 1px solid #ffc078; color: #a33a00; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.warn-banner.sm { padding: 6px 10px; font-size: .85rem; margin: 6px 0; }
[data-theme="dark"] .warn-banner { background: #3a2410; border-color: #7a4310; color: #ffc078; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.stats.small { grid-template-columns: repeat(5, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--brand-2); border-radius: var(--radius); padding: 12px 14px; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; } .stat span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat.s-pending { border-left-color: var(--pending); } .stat.s-in_progress { border-left-color: var(--progress); } .stat.s-overdue { border-left-color: var(--overdue); }
.stat.s-overdue b { color: var(--overdue); } .stat.s-completed { border-left-color: var(--done); } .stat.s-postponed { border-left-color: var(--postponed); } .stat.s-pay { border-left-color: #2b8a3e; }
.quick-add { display: flex; gap: 8px; margin-bottom: 16px; background: var(--surface); padding: 10px; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
.quick-add input { flex: 1; } .quick-add select { width: auto; }
.dash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card.span2 { grid-column: span 2; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; font-size: .9rem; }
.money-total { color: #2b8a3e; font-size: 1.2rem; }

/* ---------------- tasks ---------------- */
.tasks { display: flex; flex-direction: column; gap: 6px; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--line); border-left: 5px solid var(--medium); border-radius: 10px; background: var(--surface); }
.task.pr-high { border-left-color: var(--high); } .task.pr-low { border-left-color: var(--low); }
.task.st-completed { opacity: .62; } .task.st-completed .ttitle { text-decoration: line-through; }
.task.st-overdue { background: #fff5f5; border-color: #ffc9c9; border-left-color: var(--overdue); }
[data-theme="dark"] .task.st-overdue { background: #3b1a1a; border-color: #6e2a2a; }
.tcheck { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--muted); background: var(--surface); flex: none; cursor: pointer; font-weight: 800; color: #fff; display: grid; place-items: center; margin-top: 1px; }
.tcheck.on { background: var(--done); border-color: var(--done); }
.tmain { flex: 1; min-width: 0; cursor: pointer; }
.ttitle { font-weight: 600; word-break: break-word; } .tdetails { font-size: .85rem; color: var(--muted); margin-top: 2px; white-space: pre-line; }
.tchips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.task.compact { padding: 7px 8px; } .task.compact .tchips { margin-top: 3px; }
.tacts { display: flex; gap: 4px; flex: none; }
.tacts button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: .95rem; }
.sbadge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; color: #fff; text-transform: uppercase; letter-spacing: .02em; }
.s-pending { background: var(--pending); } .s-in_progress { background: var(--progress); } .s-completed { background: var(--done); } .s-postponed { background: var(--postponed); } .s-overdue { background: var(--overdue); }
.stat.s-pending, .stat.s-in_progress, .stat.s-completed, .stat.s-postponed, .stat.s-overdue { background: var(--surface); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; min-height: 40px; }
.tabs button span { margin-left: 6px; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; font-size: .8rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); } .tabs button.on span { background: rgba(255,255,255,.2); }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; } .filters input { flex: 1; min-width: 220px; } .filters select { width: auto; }
.grp { display: flex; align-items: center; gap: 8px; color: var(--brand-2); } .grp small { color: var(--muted); font-weight: 400; text-transform: none; } .grp.past { color: var(--overdue); }
[data-theme="dark"] .grp { color: #91a7d0; }
.pr-h-high { color: var(--high); } .pr-h-medium { color: var(--medium); } .pr-h-low { color: var(--low); }

/* reminders */
.rem { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--surface); }
.rem.due { background: #fff5f5; border-color: #ffa8a8; animation: glow 1.6s infinite; } .rem.done { opacity: .55; }
[data-theme="dark"] .rem.due { background: #3b1a1a; }
@keyframes glow { 50% { box-shadow: 0 0 0 3px rgba(224,49,49,.18); } }
.rem-ico { font-size: 1.4rem; } .rem-main { flex: 1; cursor: pointer; min-width: 0; }
.rem.k-payment { border-left: 5px solid #2b8a3e; }

/* ---------------- calendar ---------------- */
.cal-head h2 { min-width: 230px; text-align: center; font-size: 1.25rem; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 16px; min-height: 40px; cursor: pointer; font-weight: 600; }
.seg button.on { background: var(--brand); color: #fff; }
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.mhead { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--brand); color: #fff; font-weight: 600; font-size: .85rem; }
.mhead div { padding: 8px; text-align: center; }
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); }
.mcell { min-height: 112px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px; cursor: pointer; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.mcell:nth-child(7n) { border-right: 0; } .mcell:hover { background: var(--surface-2); }
.mcell.out { background: var(--surface-2); opacity: .55; } .mcell.sun .mnum span:first-child { color: var(--overdue); }
.mcell.today { background: #fff4e6; box-shadow: inset 0 0 0 2px var(--accent); } [data-theme="dark"] .mcell.today { background: #33240f; }
.mcell.has-over .mnum span:first-child::after { content: ' ⚠'; color: var(--overdue); font-size: .8rem; }
.mnum { display: flex; justify-content: space-between; font-weight: 700; font-size: .95rem; } .micons { font-size: .72rem; }
.mtask { font-size: .74rem; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; background: var(--pending); }
.mtask.st-in_progress { background: var(--progress); } .mtask.st-completed { background: var(--done); text-decoration: line-through; opacity: .75; } .mtask.st-postponed { background: var(--postponed); } .mtask.st-overdue { background: var(--overdue); }
.mmore { font-size: .72rem; color: var(--muted); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.lg::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--pending); }
.lg.st-in_progress::before { background: var(--progress); } .lg.st-completed::before { background: var(--done); } .lg.st-postponed::before { background: var(--postponed); } .lg.st-overdue::before { background: var(--overdue); }
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; }
.wcol { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 360px; display: flex; flex-direction: column; gap: 6px; }
.wcol.today { border: 2px solid var(--accent); }
.whead { display: flex; flex-direction: column; align-items: center; padding: 4px; border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.wcol .tasks { flex: 1; } .wcol .empty { padding: 6px; border: 0; } .wacts { display: flex; flex-direction: column; gap: 4px; }
.wcol .task { gap: 6px; padding: 6px; } .wcol .tcheck { width: 24px; height: 24px; } .wcol .tacts { display: none; } .wcol .chip { font-size: .7rem; padding: 1px 6px; } .wcol .sbadge { font-size: .62rem; }
.daycal { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; } .daycol { display: flex; flex-direction: column; gap: 14px; }
.hours { display: flex; flex-direction: column; } .hrow { display: flex; border-top: 1px solid var(--line); min-height: 48px; }
.hlabel { width: 78px; flex: none; font-size: .8rem; color: var(--muted); padding: 4px; } .hslot { flex: 1; padding: 3px 0; display: flex; flex-direction: column; gap: 4px; }
.pgrow, .sres, .logrow { padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; cursor: pointer; background: var(--surface); }
.pgrow:hover, .sres:hover, .logrow:hover { border-color: var(--accent); }
.logrow { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; } .logrow small { color: var(--muted); }

/* ---------------- forms & modals ---------------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; } .form.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.span2 { grid-column: span 2; } .span3 { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .86rem; }
.form label.chk { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; } .chk input { width: 22px; height: 22px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; } .form-actions.wrap { flex-wrap: wrap; justify-content: flex-start; } .form-actions.col { flex-direction: column; align-items: stretch; }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; } .quick-dates .chip { padding: 6px 12px; font-size: .85rem; }
.with-mic { display: flex; gap: 6px; align-items: flex-start; } .with-mic > :first-child { flex: 1; }
.mic { width: var(--tap); height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; flex: none; font-size: 1.1rem; }
.mic.rec, #micB.rec { background: var(--overdue); color: #fff; animation: pulse 1s infinite; }
.att-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.modal-back { position: fixed; inset: 0; background: rgba(10,18,34,.5); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 16px; width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.modal.wide { width: min(820px, 100%); } .modal.full { width: min(1400px, 100%); height: calc(100dvh - 32px); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; } .progress div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; } .rec-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--overdue); animation: pulse 1s infinite; } .rec-time { font-size: 2.4rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.warn-h { color: var(--overdue); }

/* toasts */
.toasts { position: fixed; bottom: 16px; left: calc(var(--nav) + 16px); display: flex; flex-direction: column; gap: 8px; z-index: 300; width: min(460px, calc(100% - 24px)); pointer-events: none; }
.toast { background: #1b2436; color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.3); pointer-events: auto; animation: up .2s; transition: opacity .3s, transform .3s; }
.toast span { flex: 1; } .toast button { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; font-weight: 600; min-height: 34px; }
.toast .x { background: transparent; } .toast.out { opacity: 0; transform: translateY(10px); }
.toast.ok { background: #2b8a3e; } .toast.err { background: #c92a2a; } .toast.warn { background: #d9480f; } .toast.alarm { background: #c92a2a; font-size: 1.05rem; padding: 14px 14px 14px 18px; animation: up .2s, shake .5s .2s 3; }
@keyframes up { from { transform: translateY(20px); opacity: 0; } } @keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------------- files ---------------- */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.mini-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.fcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; }
.fcard:hover { border-color: var(--accent); }
.fthumb { aspect-ratio: 4/3; background: var(--surface-2); display: grid; place-items: center; position: relative; overflow: hidden; }
.fthumb img, .fthumb video { width: 100%; height: 100%; object-fit: cover; }
.fthumb em { position: absolute; right: 6px; bottom: 6px; background: rgba(20,40,75,.85); color: #fff; font-style: normal; font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.fico { font-size: 2.6rem; } .fcard.mini .fico { font-size: 1.8rem; }
.fname { padding: 6px 8px 0; font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .fcard.mini .fname { padding-bottom: 6px; font-size: .75rem; }
.fmeta { padding: 0 8px 8px; font-size: .74rem; color: var(--muted); }
.drop-zone { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); margin-bottom: 14px; font-size: .9rem; } .drop-zone.over { border-color: var(--accent); background: #fff4e6; }
.pv-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 16px; height: 100%; } .pv-host { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface-2); border-radius: 12px; overflow: hidden; position: relative; }
.pv-img, .pv-media { max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; } .pv-audio { width: 90%; } .pv-pdf { width: 100%; height: 100%; min-height: 70dvh; border: 0; }
.pv-text { width: 100%; height: 100%; margin: 0; padding: 14px; overflow: auto; font-size: .8rem; white-space: pre-wrap; align-self: stretch; }
.pv-none { text-align: center; padding: 30px; max-width: 460px; } .pv-ico { font-size: 4rem; }
.pv-dxf { width: 100%; flex: 1; background: #10161f; color: #d0ebff; display: flex; } .pv-dxf svg { width: 100%; height: 100%; min-height: 60dvh; touch-action: none; }
.pv-3d { width: 100%; flex: 1; min-height: 60dvh; } .pv-3d canvas { display: block; width: 100% !important; height: 100% !important; touch-action: none; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; } .tbl th { background: var(--brand); color: #fff; text-align: left; padding: 9px; white-space: nowrap; } .tbl td { padding: 9px; border-top: 1px solid var(--line); } .tbl tr[data-log] { cursor: pointer; } .tbl tr[data-log]:hover td { background: var(--surface-2); }
.search-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; background: var(--surface); padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); }
.search-form input[type=search] { flex: 1 1 320px; } .search-form select { width: auto; } .search-form label { display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; gap: 2px; }
.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-top: 14px; }
.nb { display: flex; aspect-ratio: 3/4; border-radius: 6px 14px 14px 6px; background: var(--nb, var(--brand)); color: #fff; cursor: pointer; box-shadow: 4px 6px 16px rgba(0,0,0,.18); overflow: hidden; }
.nb-spine { width: 16px; background: rgba(0,0,0,.22); } .nb-body { padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.nb-body b { font-size: 1.15rem; word-break: break-word; } .nb-body span, .nb-body small { opacity: .85; font-size: .82rem; } .nb-body p { font-size: .78rem; opacity: .75; margin: auto 0 0; overflow: hidden; }
.nb.add { background: var(--surface); color: var(--muted); border: 2px dashed var(--line); box-shadow: none; align-items: center; text-align: center; } .nb.add b { font-size: 3rem; }

/* =====================================================================
   DIARY EDITOR
   ===================================================================== */
.view:has(.editor) { padding: 0; overflow: hidden; }
.editor { display: flex; flex-direction: column; height: 100%; background: #c9d1dc; }
[data-theme="dark"] .editor { background: #0a0f18; }
.ed-top { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ed-date { display: flex; align-items: center; gap: 4px; } .ed-date .date-jump { width: 44px !important; padding: 0 6px; color: transparent; cursor: pointer; } .ed-date .date-jump::-webkit-calendar-picker-indicator { margin: 0 auto; }
.ed-dtitle { display: flex; flex-direction: column; line-height: 1.15; min-width: 150px; } .ed-dtitle span { font-size: .8rem; color: var(--muted); }
.ed-pages { display: flex; gap: 4px; flex: 1; overflow-x: auto; min-width: 140px; }
.ptab { border: 1px solid var(--line); background: var(--surface-2); padding: 0 12px; min-height: 36px; border-radius: 9px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: .85rem; }
.ptab.on { background: var(--brand); color: #fff; border-color: var(--brand); } .ptab.add { color: var(--accent); border-style: dashed; }
.ed-acts { display: flex; gap: 6px; align-items: center; } .ed-acts select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .85rem; }
#saveBtn.dirty { border-color: var(--postponed); color: var(--postponed); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); padding: 6px; display: none; flex-direction: column; min-width: 250px; z-index: 50; }
.menu.open { display: flex; } .menu button { text-align: left; border: 0; background: transparent; padding: 11px 12px; border-radius: 8px; cursor: pointer; } .menu button:hover { background: var(--surface-2); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; flex: none; }
.toolbar::-webkit-scrollbar { display: none; }
.tgroup { display: flex; align-items: center; gap: 3px; padding: 0 6px; border-right: 1px solid var(--line); flex: none; } .tgroup:last-child { border-right: 0; }
.tgroup button { min-width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 1.25rem; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; position: relative; }
.tgroup button small { font-size: .55rem; color: var(--muted); margin-top: 1px; }
.tgroup button:hover { background: var(--surface-2); } .tgroup button.on { background: #fff4e6; border-color: var(--accent); } [data-theme="dark"] .tgroup button.on { background: #3a2410; }
.tgroup button:disabled { opacity: .3; }
.sw { width: 30px !important; min-width: 30px !important; height: 30px !important; border-radius: 50% !important; background: var(--c) !important; border: 3px solid var(--surface) !important; box-shadow: 0 0 0 1px var(--line); cursor: pointer; display: inline-block; position: relative; flex: none; }
.sw.on { box-shadow: 0 0 0 3px var(--accent); }
.sw.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red) !important; overflow: hidden; } .sw.custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.size input { width: 110px; accent-color: var(--accent); } .size-dot { display: inline-block; border-radius: 50%; border: 1px solid var(--muted); margin-left: 6px; flex: none; }
.zoom #zFit { font-size: .8rem; font-weight: 700; min-width: 58px; }
.ed-body { flex: 1; display: flex; min-height: 0; position: relative; }
.canvas-host { flex: 1; min-width: 0; position: relative; }
.page-scroller { position: absolute; inset: 0; overflow: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.page-stage { position: relative; margin: 0 auto; box-shadow: 0 4px 24px rgba(0,0,0,.25); background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
.page-stage canvas { position: absolute; left: 0; top: 0; }
.page-stage[data-tool="pen"], .page-stage[data-tool="highlighter"] { cursor: crosshair; } .page-stage[data-tool="eraser"] { cursor: cell; } .page-stage[data-tool="text"] { cursor: text; }
.el-layer { position: absolute; inset: 0; pointer-events: none; }
.el { position: absolute; pointer-events: auto; }
.page-stage:not([data-tool="select"]):not([data-tool="text"]) .el { pointer-events: none; }
.el-text { min-height: 1.4em; padding: 4px 6px; outline: none; line-height: 1.3; font-family: "Segoe UI", Roboto, sans-serif; white-space: pre-wrap; word-break: break-word; border: 1px dashed transparent; border-radius: 4px; user-select: text; -webkit-user-select: text; }
.page-stage[data-tool="text"] .el-text, .page-stage[data-tool="select"] .el-text { border-color: rgba(25,113,194,.35); }
.el.sel .el-text, .el.sel img { border-color: var(--accent) !important; outline: 2px solid rgba(232,89,12,.35); }
.el img { width: 100%; height: 100%; object-fit: contain; display: block; border: 1px dashed transparent; }
.el-move, .el-del, .el-size, .el-font { position: absolute; display: none; z-index: 2; }
.page-stage[data-tool="select"] .el.sel .el-move, .page-stage[data-tool="select"] .el.sel .el-del, .page-stage[data-tool="select"] .el.sel .el-size, .page-stage[data-tool="select"] .el.sel .el-font,
.page-stage[data-tool="text"] .el.sel .el-move, .page-stage[data-tool="text"] .el.sel .el-del, .page-stage[data-tool="text"] .el.sel .el-font { display: grid; }
.el-move, .el-del { width: 34px; height: 34px; border-radius: 50%; place-items: center; color: #fff; font-size: 16px; cursor: pointer; top: -40px; }
.el-move { left: 0; background: var(--brand-2); cursor: move; touch-action: none; } .el-del { right: 0; background: var(--overdue); }
.el-size { right: -12px; bottom: -12px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; cursor: nwse-resize; touch-action: none; }
.el-font { top: -40px; left: 42px; display: none; gap: 4px; grid-auto-flow: column; } .el-font b { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; font-size: 13px; cursor: pointer; color: var(--text); }
.side { width: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--line); transition: width .25s; display: flex; flex-direction: column; flex: none; }
.editor.side-open .side { width: 360px; }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; } .side-tabs button { flex: 1; border: 0; background: transparent; padding: 12px 4px; cursor: pointer; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.side-tabs button.on { border-bottom-color: var(--accent); color: var(--accent); }
.side-body { padding: 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 340px; }
.side-add { display: flex; gap: 6px; } .side-foot { display: flex; flex-wrap: wrap; gap: 6px; }
.side .tacts button { width: 32px; height: 32px; }
.focus-exit { display: none; }

/* full page / distraction-free mode */
body.focus .topbar, body.focus .sidenav, body.focus .ed-top, body.focus .side { display: none !important; }
body.focus .app { grid-template-columns: 1fr; grid-template-rows: 1fr; }
body.focus .view { grid-column: 1; grid-row: 1; }
body.focus .focus-exit { display: block; position: fixed; right: 12px; bottom: 16px; z-index: 60; border: 0; border-radius: 999px; padding: 10px 16px; background: rgba(20,40,75,.85); color: #fff; font-weight: 600; cursor: pointer; }

/* ---------------- floating calculator ---------------- */
.calc { position: fixed; right: 24px; bottom: 24px; width: 330px; min-width: 280px; max-width: 95vw; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.35); z-index: 250; border: 1px solid var(--line); resize: horizontal; overflow: hidden; outline: none; }
.calc-head { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; background: var(--brand); color: #fff; cursor: move; touch-action: none; user-select: none; }
.calc-title { font-weight: 700; font-size: .9rem; flex: 1; white-space: nowrap; }
.calc-modes { display: flex; background: rgba(255,255,255,.12); border-radius: 8px; } .calc-modes button { border: 0; background: transparent; color: #fff; padding: 5px 9px; border-radius: 8px; cursor: pointer; font-size: .8rem; font-weight: 600; } .calc-modes button.on { background: var(--accent); }
.calc-hbtn { width: 32px; height: 32px; border: 0; background: transparent; color: #fff; cursor: pointer; border-radius: 8px; font-size: 1rem; } .calc-hbtn:hover { background: rgba(255,255,255,.15); }
.calc.min .calc-body { display: none; } .calc.min { width: 260px !important; resize: none; }
.calc-body { padding: 10px; }
.calc-screen { background: #0f1b2e; color: #e9f1ff; border-radius: 12px; padding: 10px 12px; text-align: right; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.calc-expr { min-height: 20px; font-size: .9rem; color: #9fb3cf; word-break: break-all; } .calc-res { font-size: 2rem; font-weight: 700; word-break: break-all; line-height: 1.2; }
.calc-flags { display: flex; justify-content: space-between; font-size: .68rem; color: #74c0fc; }
.calc-keys, .calc-sci { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.calc-sci { grid-template-columns: repeat(5, 1fr); margin-bottom: 6px; display: none; } .calc[data-mode="sci"] .calc-sci { display: grid; }
.calc-body button[data-k], .calc-body button[data-c] { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.15rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.calc-sci button { min-height: 40px !important; font-size: .85rem !important; }
.calc .op { background: #e7f5ff !important; color: #1864ab; } .calc .fn { background: #f1f3f5 !important; } .calc .eq { background: var(--accent) !important; color: #fff; border-color: var(--accent) !important; }
.calc .mk { min-height: 34px !important; font-size: .8rem !important; color: var(--muted); }
[data-theme="dark"] .calc .op, [data-theme="dark"] .calc .fn { background: var(--surface-2) !important; color: var(--text); }
.calc-gst { display: none; flex-direction: column; gap: 8px; } .calc[data-mode="gst"] .calc-gst { display: flex; } .calc[data-mode="gst"] .calc-keys, .calc[data-mode="gst"] .calc-screen { display: none; }
.calc-gst label { display: flex; flex-direction: column; font-size: .82rem; font-weight: 600; gap: 3px; }
.gst-type label, .gst-igst { flex-direction: row !important; align-items: center; gap: 6px; font-weight: 500 !important; }
.gst-rates { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; } .gst-rates button { min-height: 38px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; cursor: pointer; font-weight: 700; font-size: .8rem; } .gst-rates button.on { background: var(--accent); color: #fff; }
.gst-out { width: 100%; border-collapse: collapse; font-size: .92rem; } .gst-out td { padding: 5px 2px; border-bottom: 1px solid var(--line); } .gst-out td:last-child { text-align: right; font-variant-numeric: tabular-nums; } .gst-out tr.tot td { font-weight: 800; font-size: 1.05rem; color: var(--accent); border: 0; }
.calc-foot { display: flex; gap: 6px; margin-top: 8px; } .calc-foot button { flex: 1; min-height: 38px !important; font-size: .8rem !important; }
.calc-hist { margin-top: 8px; max-height: 160px; overflow-y: auto; font-size: .85rem; border-top: 1px solid var(--line); } .hrow { padding: 6px 4px; border-bottom: 1px solid var(--line); cursor: pointer; text-align: right; } .hrow:hover { background: var(--surface-2); }

/* ---------------- responsive: portrait tablet & phone ---------------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .dash { grid-template-columns: 1fr 1fr; } .card.span2 { grid-column: 1 / -1; }
  .editor.side-open .side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.2); }
  .daycal { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --nav: 0px; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top) 1fr 64px; }
  .sidenav { grid-row: 3; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px; overflow-x: auto; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .sidenav a { min-width: 68px; padding: 4px; } .sidenav a i { font-size: 1.2rem; }
  .view { grid-row: 2; padding: 14px 14px 30px; }
  .toasts { bottom: 76px; left: 12px; }
  .top-date { display: none; } .brand small { display: none; } .sync { display: none; }
  .form.grid3 { grid-template-columns: 1fr 1fr; }
  .mcell { min-height: 84px; } .mtask { font-size: .66rem; }
  .pv-wrap { grid-template-columns: 1fr; } .ed-acts select { max-width: 120px; }
  body.focus .app { grid-template-rows: 1fr; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); } .dash { grid-template-columns: 1fr; }
  .form.grid2, .form.grid3 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: auto; }
  .quick-add { flex-wrap: wrap; } .quick-add input { flex-basis: 100%; }
  .cal-head h2 { min-width: 0; font-size: 1rem; } .mcell .mtask { display: none; } .mcell { min-height: 58px; }
  .mcell:has(.mtask)::after { content: '•'; color: var(--accent); font-size: 1.4rem; line-height: .5; }
  .week { grid-template-columns: repeat(7, 150px); }
  .ed-dtitle { min-width: 0; } .ed-dtitle b { font-size: .9rem; }
}

/* ---------------- print ---------------- */
#printArea { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body { overflow: visible; background: #fff; }
  body.printing > *:not(#printArea) { display: none !important; }
  body.printing #printArea { display: block; }
  .print-page { width: 100%; display: block; page-break-after: always; break-after: page; }
  .print-report { padding: 14mm; font-family: Arial, sans-serif; color: #000; }
  .print-report table { width: 100%; border-collapse: collapse; font-size: 10pt; } .print-report th, .print-report td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
  .print-report th { background: #eee; }
}
