/* Sổ Việc Thợ Ảnh */
:root {
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1c201e;
  --ink-2: #5a615d;
  --ink-3: #8a908c;
  --line: #e7e2d9;
  --line-2: #d6cfc3;
  --brand: #1f4d3a;
  --brand-ink: #ffffff;
  --logo-bg: #1f4d3a;
  --logo-ink: #f6c66a;
  --am: #c98118;          /* buổi sáng */
  --am-soft: #fcf1dc;
  --am-ink: #8a5508;
  --pm: #c0533a;          /* buổi chiều */
  --pm-soft: #fbe8e1;
  --pm-ink: #94371f;
  --ok: #2e7d57;
  --due: #b4532a;
  --danger: #c0392b;
  --on-accent: #ffffff;
  --toast-bg: #1c201e;
  --toast-ink: #f3f1ec;
  --shadow: 0 1px 2px rgba(28, 32, 30, .05), 0 6px 18px rgba(28, 32, 30, .05);
  --r: 14px;
  --t-cuoi: #d0517a;
  --t-sukien: #8a5cd0;
  --t-chandung: #3b78c4;
  --t-sanpham: #1f9a8a;
  --t-quay: #5a5fd6;
  --t-hauky: #b8741a;
  --t-giao: #2e8b57;
  --t-gapkhach: #64748b;
  --t-khac: #8a908c;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111412;
    --surface: #191d1a;
    --surface-2: #1f2420;
    --ink: #ebe8e1;
    --ink-2: #a9afaa;
    --ink-3: #7b827d;
    --line: #2a302c;
    --line-2: #3b433e;
    --brand: #7cc6a0;
    --brand-ink: #0f1a14;
    --logo-bg: #234f3c;
    --logo-ink: #f6c66a;
    --am: #f0ae4c;
    --am-soft: #2a2316;
    --am-ink: #f3c27a;
    --pm: #ee8a6a;
    --pm-soft: #2d1e19;
    --pm-ink: #f4a68d;
    --ok: #5cc28d;
    --due: #f0956b;
    --danger: #ef6f60;
    --on-accent: #17130e;
    --toast-bg: #ebe8e1;
    --toast-ink: #111412;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .2);
    --t-cuoi: #ec7fa0;
    --t-sukien: #b192ee;
    --t-chandung: #73a8ea;
    --t-sanpham: #4cc5b4;
    --t-quay: #8f93f0;
    --t-hauky: #e3a54c;
    --t-giao: #5cc28d;
    --t-gapkhach: #9aa7b8;
    --t-khac: #9aa09c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

svg.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.warn {
  background: #fff3cd; color: #6b4e00;
  padding: 8px 16px; font-size: 13.5px; text-align: center;
}

/* ---------- đầu trang ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 8px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; border-radius: 10px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: var(--logo-bg); color: var(--logo-ink);
  display: grid; place-items: center;
}
.logo svg { width: 21px; height: 21px; }
.brand-text { min-width: 0; }
.brand b { display: block; font-size: 16.5px; line-height: 1.15; letter-spacing: -.01em; }
.brand small { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  display: grid; place-items: center; padding: 0;
  transition: border-color .15s, color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 14px;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 500; font-size: 14px;
  white-space: nowrap; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--line-2); }
.btn:disabled { opacity: .5; }
.btn svg { width: 17px; height: 17px; }
a.btn { text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { height: 36px; padding: 0 11px; font-size: 13.5px; border-radius: 10px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

/* ---------- chọn ngày ---------- */
.datebar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 20px 0 12px; }
.date-title { flex: 1 1 200px; min-width: 0; }
.dow-line { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--brand); }
.rel {
  font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 99px;
  background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand);
}
.datebar h1 { margin: 2px 0 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 700; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.today-btn { height: 40px; }
.pick { position: relative; display: inline-flex; }
.pick input { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; pointer-events: none; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.wd {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 6px 0 7px; min-height: 64px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  transition: border-color .15s, background .15s;
}
.wd:hover { border-color: var(--line-2); }
.wd-n { font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.wd-d { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.dots { display: flex; gap: 3px; height: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; }
.d-am { background: var(--am); }
.d-pm { background: var(--pm); }
.wd.today .wd-d, .wd.today .wd-n { color: var(--brand); }
.wd.sel { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.wd.sel .wd-n, .wd.sel .wd-d { color: inherit; }
.wd.sel .wd-n { opacity: .85; }

/* ---------- tóm tắt ---------- */
.summary {
  display: grid; gap: 10px; margin-bottom: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.stat .lbl { font-size: 12.5px; color: var(--ink-2); }
.stat b { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.3; }
.stat b small { font-size: 14px; font-weight: 500; color: var(--ink-3); }
.stat b.due { color: var(--due); }
.stat .sub { font-size: 12px; color: var(--ink-3); }
.bar { height: 5px; border-radius: 9px; background: var(--line); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .3s; }
.stat.money { grid-column: 1 / -1; }
.sum-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.sum-actions .btn { flex: 1; }
@media (min-width: 720px) {
  .summary { grid-template-columns: 1fr 1.2fr 1.5fr auto; }
  .stat.money, .sum-actions { grid-column: auto; }
  .sum-actions { flex-direction: column; justify-content: center; }
  .sum-actions .btn { flex: none; }
}

/* ---------- hai buổi ---------- */
.sessions { display: grid; gap: 16px; align-items: start; }
@media (min-width: 880px) { .sessions { grid-template-columns: 1fr 1fr; } }

.session {
  --a: var(--am); --a-soft: var(--am-soft); --a-ink: var(--am-ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow); overflow: hidden;
}
.session.chieu { --a: var(--pm); --a-soft: var(--pm-soft); --a-ink: var(--pm-ink); }
.s-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, var(--a-soft), var(--surface));
}
.s-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: var(--a); color: var(--on-accent); display: grid; place-items: center;
}
.s-icon svg { width: 22px; height: 22px; }
.s-head h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.s-head .range { font-size: 12.5px; color: var(--ink-2); }
.s-head .count {
  margin-left: auto; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--a-ink); background: color-mix(in srgb, var(--a) 14%, transparent);
  padding: 3px 10px; border-radius: 99px;
}
.s-head .count:empty { display: none; }

.jobs { list-style: none; margin: 0; padding: 4px 12px; display: flex; flex-direction: column; gap: 8px; }
.empty { padding: 16px 8px 10px; text-align: center; color: var(--ink-2); font-size: 14px; }
.empty span { font-size: 13px; color: var(--ink-3); }
kbd {
  font: inherit; font-size: 12.5px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; color: var(--ink-2);
}

/* thẻ công việc */
.job {
  --c: var(--t-khac);
  position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.job::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--c);
}
.job:hover { border-color: var(--line-2); }
.job.open {
  border-color: color-mix(in srgb, var(--a) 55%, var(--line));
  box-shadow: 0 8px 26px -10px color-mix(in srgb, var(--a) 40%, transparent);
}
.job.new { animation: flash 1s ease-out; }
@keyframes flash { from { background: var(--a-soft); } }

.job-row { display: flex; gap: 10px; padding: 10px 12px 10px 13px; align-items: flex-start; }
.check {
  flex: none; width: 26px; height: 26px; margin-top: 1px; padding: 0;
  border-radius: 50%; border: 2px solid var(--line-2); background: transparent;
  display: grid; place-items: center; color: transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.check svg { width: 15px; height: 15px; stroke-width: 3; }
.check:hover { border-color: var(--ok); color: color-mix(in srgb, var(--ok) 55%, transparent); }
.job.done .check { background: var(--ok); border-color: var(--ok); color: var(--on-accent); }

.job-main { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; }
.line1 { display: flex; gap: 10px; align-items: baseline; }
.time { flex: none; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; color: var(--a-ink); }
.title { font-weight: 600; overflow-wrap: anywhere; }
.title em { font-weight: 400; color: var(--ink-3); }
.job.done .title { text-decoration: line-through; text-decoration-color: var(--ink-3); color: var(--ink-2); }
.job.done .time { color: var(--ink-3); }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 5px; font-size: 13px; color: var(--ink-2); }
.meta .m { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.meta .m svg { width: 14px; height: 14px; }
.meta a.m { color: inherit; text-decoration: none; }
.meta a.m:hover { color: var(--ink); text-decoration: underline; }
.meta .ok { color: var(--ok); }
.meta .due { color: var(--due); font-weight: 600; }
.tag {
  font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; white-space: nowrap;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 78%, var(--ink));
}
.note-prev {
  margin: 5px 0 0; font-size: 13px; color: var(--ink-2); white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* phần sửa chi tiết */
.job-edit { border-top: 1px dashed var(--line-2); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f > span { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.f > span small { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.f input, .f select, .f textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
  font-size: 15px;
}
.f textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
.f input:focus, .f select:focus, .f textarea:focus,
.quick input:focus, #dayNote:focus, #gearText:focus {
  outline: none; border-color: var(--a, var(--brand)); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--a, var(--brand)) 18%, transparent);
}
.due-line { grid-column: 1 / -1; margin: -2px 0 0; font-size: 13px; color: var(--ink-2); }
.due-line b { color: var(--due); }
.due-line .ok { color: var(--ok); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; height: 32px;
  border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; color: var(--ink-2); overflow: hidden;
}
.chip > button {
  height: 100%; border: 0; background: none; color: inherit; font-size: inherit;
  display: inline-flex; align-items: center; gap: 5px; padding: 0 3px 0 11px;
}
.chip > button.x { padding: 0 9px 0 5px; font-size: 16px; color: var(--ink-3); }
.chip > button.x:hover { color: var(--danger); }
.chip svg { width: 13px; height: 13px; stroke-width: 3; display: none; }
.chip.on { background: color-mix(in srgb, var(--ok) 13%, transparent); border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); font-weight: 500; }
.chip.on svg { display: block; }
button.chip.add { gap: 5px; padding: 0 12px; border-style: dashed; }
button.chip.add svg { display: block; stroke-width: 2.5; }
.f .gear-add {
  width: 160px; height: 32px; min-height: 0; padding: 0 12px;
  border: 1px dashed var(--line-2); border-radius: 99px; background: transparent; font-size: 13px;
}
.f .gear-add:focus { border-style: solid; box-shadow: none; }

.edit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.edit-actions .sp { flex: 1; }

/* ô thêm nhanh */
.quick { display: flex; gap: 8px; padding: 8px 12px 14px; }
.quick input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px;
  border: 1px dashed var(--line-2); border-radius: 12px; background: var(--surface-2);
  font-size: 15px;
}
.quick input:focus { border-style: solid; }
.quick button {
  width: 44px; height: 44px; flex: none; padding: 0;
  border: 0; border-radius: 12px; background: var(--a); color: var(--on-accent);
  display: grid; place-items: center;
}
.quick button svg { width: 22px; height: 22px; stroke-width: 2.4; }
.quick button:hover { filter: brightness(1.07); }

/* ---------- ghi chú ngày + sắp tới ---------- */
.lower { display: grid; gap: 16px; margin: 16px 0 6px; align-items: start; }
@media (min-width: 880px) { .lower { grid-template-columns: 1fr 1fr; } }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px 16px; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 svg { color: var(--ink-3); }
.card h3 small { font-weight: 400; font-size: 12.5px; color: var(--ink-3); margin-left: auto; }
#dayNote {
  display: block; width: 100%; min-height: 132px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  resize: vertical; line-height: 1.55;
}
.hint { margin: 0; font-size: 13px; color: var(--ink-3); }

.up, .left-list { list-style: none; margin: 0; padding: 0; }
.up li + li, .left-list li + li { border-top: 1px solid var(--line); }
.up button {
  width: 100%; display: flex; align-items: baseline; gap: 12px;
  padding: 9px 6px; border: 0; border-radius: 8px; background: none; text-align: left;
}
.up button:hover { background: var(--surface-2); }
.up-date { flex: none; width: 70px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.up-date b { color: var(--ink); font-weight: 600; }
.up-jobs { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-jobs b { font-variant-numeric: tabular-nums; }
.up-n {
  flex: none; font-size: 12px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px;
}
.left-card { border-color: color-mix(in srgb, var(--am) 40%, var(--line)); }
.left-card h3 svg { color: var(--am); }
.left-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.ll-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ll-date { font-size: 12px; color: var(--ink-3); }
.ll-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 14px 0 calc(40px + env(safe-area-inset-bottom)); font-size: 12.5px; color: var(--ink-3);
}
.foot button { border: 0; background: none; padding: 0; font-size: inherit; font-weight: 600; color: var(--brand); }
.foot button:hover { text-decoration: underline; }
.warn-text { color: var(--due); font-weight: 600; }

/* ---------- thông báo ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 10px 12px 10px 16px; border-radius: 12px;
  background: var(--toast-bg); color: var(--toast-ink); font-size: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; padding: 4px 6px; font-weight: 700; color: var(--am); white-space: nowrap; }

/* ---------- hộp thoại ---------- */
.dlg {
  width: min(560px, calc(100% - 24px)); max-height: min(84vh, 760px);
  padding: 0; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .28);
}
.dlg::backdrop { background: rgba(17, 20, 18, .45); }
.dlg-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.dlg-head h2 { margin: 0; font-size: 17px; }
.dlg-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 22px; }
.dlg-body h3 { margin: 0 0 4px; font-size: 15px; }
.dlg-body .hint { margin-bottom: 10px; }
.dlg-body .row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
#gearText {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); resize: vertical; line-height: 1.6;
}

.dlg-search { margin-top: 8vh; overflow: hidden; display: none; }
.dlg-search[open] { display: flex; flex-direction: column; }
.search-field { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.sf-icon { color: var(--ink-3); display: grid; }
.search-field input { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; font-size: 16px; outline: none; }
.search-field input::-webkit-search-cancel-button { display: none; }
.results { list-style: none; margin: 0; padding: 6px; overflow: auto; }
.results li.pad { padding: 14px 12px; }
.results button {
  width: 100%; display: flex; flex-direction: column; gap: 1px;
  padding: 9px 12px; border: 0; border-radius: 10px; background: none; text-align: left;
}
.results button:hover, .results button:focus-visible { background: var(--surface-2); }
.r-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.r-title { font-weight: 600; font-size: 14.5px; }
.r-sub { font-size: 13px; color: var(--ink-2); }

/* ---------- điện thoại ---------- */
@media (max-width: 640px) {
  .datebar { padding-top: 16px; }
  .datebar h1 { font-size: 23px; }
  .brand small { display: none; }
  input, select, textarea { font-size: 16px !important; }
  .edit-actions .btn.sm { flex: 1 1 auto; }
  .edit-actions .sp { display: none; }
  .wd { min-height: 58px; }
}
@media (max-width: 340px) {
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- in ra giấy ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --shadow: none; color-scheme: light; }
  body { font-size: 12px; background: #fff; color: #000; }
  .top, .week, .date-nav, .sum-actions, .quick, .side, .foot, .toast, .warn, .job-edit, .empty span { display: none !important; }
  .summary { grid-template-columns: repeat(3, 1fr); }
  .sessions { grid-template-columns: 1fr 1fr; }
  .lower { grid-template-columns: 1fr; }
  .session, .card, .stat, .job { box-shadow: none; break-inside: avoid; }
  #dayNote { border: 0; padding: 0; min-height: 0; resize: none; }
}

/* ---------- thanh chuyển chế độ xem + nút đồng bộ ---------- */
.top-sp { flex: 1; }
.tabs {
  display: flex; gap: 2px; padding: 3px; margin-left: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.tabs button {
  height: 32px; padding: 0 13px; border: 0; border-radius: 9px; background: none;
  font-size: 14px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current="page"] {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 0 0 1px var(--line), 0 1px 3px rgba(0, 0, 0, .06);
}
.sm-only { display: none; }

.sync-btn {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 40px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.sync-btn:hover { border-color: var(--line-2); color: var(--ink); }
.sync-btn.st-ok svg { color: var(--ok); }
.sync-btn.st-local { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.sync-btn.st-offline, .sync-btn.st-expired { color: var(--due); border-color: color-mix(in srgb, var(--due) 45%, var(--line)); }
.sync-btn.st-none { color: var(--ink-3); }
.st-syncing svg, [data-act="sync-now"]:disabled svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- tổng quan ---------- */
.kpis { display: grid; gap: 10px; margin-bottom: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 880px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis .stat .sub { margin-top: 2px; }
.ov-grid { display: grid; gap: 16px; align-items: start; }
@media (min-width: 960px) { .ov-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); } }
.ov-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-h { font-size: 12px; font-weight: 600; color: var(--ink-3); text-align: center; padding-bottom: 2px; }
.cal-d {
  position: relative; min-height: 86px; padding: 6px 7px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); text-align: left; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.cal-d:not(.lv0) { border-color: transparent; }
.cal-d:hover { border-color: var(--line-2); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
.cd-n { font-size: 12.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; border-radius: 99px; }
.cal-d.past:not(.today) .cd-n { color: var(--ink-3); }
.cal-d.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-d.today .cd-n { background: var(--brand); color: var(--brand-ink); padding: 0 7px; }
.cd-c { margin-top: auto; font-size: 18px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.cd-c small { font-size: 11.5px; font-weight: 500; }
.cd-s { display: flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 500; opacity: .85; font-variant-numeric: tabular-nums; }
.cd-s svg { width: 12px; height: 12px; }
.cd-s svg:not(:first-child) { margin-left: 6px; }
.cd-warn { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--due); box-shadow: 0 0 0 2px var(--surface); }
/* một màu, đậm dần theo số việc */
.lv1 { background: color-mix(in srgb, var(--brand) 11%, var(--surface)); }
.lv2 { background: color-mix(in srgb, var(--brand) 24%, var(--surface)); }
.lv3 { background: color-mix(in srgb, var(--brand) 42%, var(--surface)); }
.lv4 { background: color-mix(in srgb, var(--brand) 80%, var(--surface)); }
.cal-d.lv4, .cal-d.lv4 .cd-n { color: var(--brand-ink); }
.cal-d.lv4.today .cd-n { background: var(--brand-ink); color: var(--brand); }
.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.cal-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; }
.cal-legend i.lg-warn { width: 7px; height: 7px; border-radius: 50%; background: var(--due); }
.cal-legend svg { width: 14px; height: 14px; }

.meters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.meters li {
  display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr auto; align-items: center; gap: 10px;
  padding: 6px 6px; border-radius: 8px; outline-offset: 0;
}
.meters li:hover { background: var(--surface-2); }
.mt-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-bar { height: 10px; }
.mt-bar i { display: block; height: 100%; background: var(--brand); border-radius: 0 4px 4px 0; }
.mt-val { min-width: 2ch; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.owe { list-style: none; margin: 0; padding: 0; }
.owe li + li { border-top: 1px solid var(--line); }
.owe button {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 9px 6px; border: 0; border-radius: 8px; background: none; text-align: left;
}
.owe button:hover { background: var(--surface-2); }
.ow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ow-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ow-main b, .ow-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ow-main b { font-size: 14px; font-weight: 600; }
.ow-sub { font-size: 12.5px; color: var(--ink-2); }
.ow-amt { flex: none; font-weight: 700; color: var(--due); font-variant-numeric: tabular-nums; }

.tip {
  position: fixed; left: 0; top: 0; z-index: 70; max-width: 280px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--toast-bg); color: var(--toast-ink);
  font-size: 12.5px; line-height: 1.5; white-space: pre-line; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

/* ---------- hộp đồng bộ / đăng nhập ---------- */
#accBody { gap: 14px; }
#accBody p { margin: 0; }
.acc-card { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--logo-bg); color: var(--logo-ink);
  display: grid; place-items: center; font-size: 18px; font-weight: 700;
}
.acc-card b { display: block; font-size: 16px; line-height: 1.3; }
.acc-card div > span { font-size: 13px; color: var(--ink-2); }
.sync-line { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.sync-line.st-ok svg { color: var(--ok); }
.sync-line.st-offline svg { color: var(--due); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { height: 36px; border: 0; border-radius: 9px; background: none; font-weight: 500; color: var(--ink-2); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.seg button:disabled { opacity: .45; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form .btn { height: 44px; }
.form-err { padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); font-size: 13.5px; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--am-soft); color: var(--am-ink); font-size: 14px; }
.pw-box summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--brand); }
.pw-box[open] summary { margin-bottom: 12px; }

/* ---------- điện thoại: đầu trang gọn, lịch tháng nhỏ ---------- */
@media (max-width: 640px) {
  .brand-text { display: none; }
  .top .wrap { gap: 6px; }
  .tabs { margin-left: 6px; }
  .tabs button { padding: 0 11px; }
  .lg-only { display: none; }
  .sm-only { display: inline; }
  .top .icon-btn, .sync-btn { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 11px; }
  .sync-text { display: none; }
  .cal { gap: 4px; }
  .cal-d { min-height: 54px; padding: 4px 5px; border-radius: 8px; }
  .cd-c { font-size: 15px; }
  .cd-c small, .cd-s { display: none; }
  .cd-warn { top: 5px; right: 5px; width: 6px; height: 6px; }
  .meters li { grid-template-columns: minmax(0, 8rem) 1fr auto; }
}
@media print {
  .tabs, .tip { display: none !important; }
}
