/* ==========================================================================
   CHAMAN CHECKLIST — app.css  (design system, 2026.09.07.1)
   Mobile-first. Breakpoints: base = phone, >=600px tablet, >=1024px desktop.
   Load on every page. Keep element IDs / data-label attrs intact in markup.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* brand blues */
  --brand-50:  #eef4fe;
  --brand-100: #dbe7fb;
  --brand-200: #b8cff6;
  --brand-400: #4f86dc;
  --brand-500: #2f6bd1;
  --brand-600: #2356a6;   /* primary */
  --brand-700: #1b4689;
  --brand-800: #143a73;   /* dark */
  --brand-900: #0f2b56;

  /* neutrals ("ink") */
  --ink-900: #17212f;
  --ink-700: #2f3b4d;
  --ink-500: #5b6778;
  --ink-400: #7c8797;
  --ink-300: #a9b2bf;
  --ink-200: #d5dbe4;
  --ink-100: #e8ecf2;
  --ink-50:  #f4f6fa;

  --bg:        #f0f4f9;
  --surface:   #ffffff;
  --surface-2: #f7f9fc;

  /* semantic (muted) */
  --success:     #2e7d52;  --success-bg: #e8f5ee;  --success-line: #bfe3cd;
  --danger:      #c43d36;  --danger-bg:  #fdecea;  --danger-line:  #f3c2be;
  --warning:     #c8801f;  --warning-bg: #fff4e3;  --warning-line: #f4d8ad;
  --slate:       #4a5e85;  --slate-bg:   #eaeef7;  --slate-line:   #c9d3e6;
  --wa:          #1da851;  --wa-bg:      #e6f7ec;  --wa-dark:      #178a42;
  --done:        #6b7785;  --done-bg:    #eef1f5;

  /* shape */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* elevation (soft, layered) */
  --shadow-1: 0 1px 2px rgba(23,33,47,.05), 0 1px 3px rgba(23,33,47,.08);
  --shadow-2: 0 2px 6px rgba(23,33,47,.06), 0 8px 24px rgba(23,33,47,.08);
  --shadow-3: 0 12px 40px rgba(23,33,47,.18);
  --ring:     0 0 0 3px rgba(47,107,209,.18);

  /* type */
  --font: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-base: 16px;
  --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px;
  --lh: 1.5;

  /* spacing scale */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --tap: 44px;               /* minimum touch target */
  --sidebar-w: 250px;
  --topbar-h: 56px;
  --container-w: 1120px;

  --z-drawer: 1100;
  --z-modal:  1300;
  --z-toast:  1500;
  --z-boot:   2000;
}

/* ---------- 2. Base / reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-base); line-height: var(--lh);
  color: var(--ink-900); background: var(--bg); min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; color: var(--ink-900); }
h2 { font-size: var(--fs-lg); font-weight: 700; }
h3 { font-size: var(--fs-base); font-weight: 700; }
a { color: var(--brand-600); }
button { font-family: inherit; }
img, svg { max-width: 100%; display: inline-block; vertical-align: middle; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-500); }
.small { font-size: var(--fs-sm); }
.text-center { text-align: center; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.stack > * + * { margin-top: var(--sp-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- 3. App shell: topbar, sidebar/drawer, main ---------- */
.app-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: calc(var(--z-drawer) - 1);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3);
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); color: #fff;
  box-shadow: 0 2px 10px rgba(20,58,115,.25);
}
.app-topbar .brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: 800; font-size: var(--fs-md); min-width: 0; flex: 1; }
.app-topbar .brand .brand-sub { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; position: relative;
  width: var(--tap); height: var(--tap); border-radius: var(--radius); border: 0; cursor: pointer;
  background: rgba(255,255,255,.12); color: #fff; transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.24); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--brand-700);
}

.app-overlay { position: fixed; inset: 0; background: rgba(15,43,86,.45); z-index: var(--z-drawer); opacity: 0; pointer-events: none; transition: opacity .2s; }
.app-overlay.is-open { opacity: 1; pointer-events: auto; }

.app-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 300px); z-index: calc(var(--z-drawer) + 1);
  background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
  transform: translateX(-104%); transition: transform .22s ease; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.app-sidebar.is-open { transform: none; }
.sidebar-head { padding: var(--sp-4) var(--sp-4) var(--sp-3); display: flex; align-items: center; gap: var(--sp-3); border-bottom: 1px solid var(--ink-100); }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand-500), var(--brand-800)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; letter-spacing: .02em; flex-shrink: 0; box-shadow: 0 3px 8px rgba(35,86,166,.35); }
.sidebar-head .brand-name { font-weight: 800; font-size: var(--fs-md); line-height: 1.2; color: var(--ink-900); }
.sidebar-head .brand-sub { font-size: var(--fs-xs); color: var(--ink-400); }
.sidebar-close { margin-left: auto; background: var(--ink-50); color: var(--ink-500); }
.sidebar-close:hover { background: var(--ink-100); }

.nav-section { padding: var(--sp-3) var(--sp-3) 0; }
.nav-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-400); padding: var(--sp-2) var(--sp-3) var(--sp-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--tap); padding: 10px var(--sp-3);
  border: 0; border-radius: var(--radius); background: none; color: var(--ink-700); font-size: var(--fs-md); font-weight: 600;
  text-decoration: none; cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nav-ico { display: inline-flex; flex-shrink: 0; }
.nav-item svg { width: 20px; height: 20px; color: var(--ink-400); flex-shrink: 0; }
.nav-item:hover { background: var(--ink-50); color: var(--brand-700); }
.nav-item.is-current { background: var(--brand-50); color: var(--brand-700); }
.nav-item.is-current svg { color: var(--brand-600); }
.nav-item .nav-pill { margin-left: auto; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--success-bg); color: var(--success); }
.sidebar-foot { margin-top: auto; padding: var(--sp-3); border-top: 1px solid var(--ink-100); }
.user-card { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius); background: var(--surface-2); margin-bottom: var(--sp-2); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0; text-transform: uppercase; }
.user-card .user-name { font-weight: 700; font-size: var(--fs-md); line-height: 1.2; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .user-role { font-size: var(--fs-xs); color: var(--ink-400); text-transform: capitalize; }

.app-main { padding: calc(var(--topbar-h) + var(--sp-4)) var(--sp-3) calc(var(--sp-10) + 72px); min-height: 100vh; }
.container { max-width: var(--container-w); margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.page-head .page-title h1 { font-size: var(--fs-xl); }
.page-head .page-title p { color: var(--ink-500); font-size: var(--fs-sm); margin-top: 2px; }
.page-head .page-actions { display: none; gap: var(--sp-2); }

/* ---------- 4. Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); padding: var(--sp-4); }
.card + .card { margin-top: var(--sp-4); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-head h2 { font-size: var(--fs-base); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: var(--sp-4) var(--sp-4) 0; }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 10px; border: 1.5px solid transparent;
  font-size: var(--fs-md); font-weight: 700; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--ink-100); color: var(--ink-700); transition: background .15s, color .15s, border-color .15s, transform .08s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:hover { background: var(--ink-200); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 1px 3px rgba(35,86,166,.35); }
.btn-primary:hover { background: var(--brand-700); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #256742; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8322c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #a86a18; }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); }
.btn-outline { background: var(--surface); border-color: var(--ink-200); color: var(--ink-700); }
.btn-outline:hover { background: var(--ink-50); border-color: var(--ink-300); }
.btn-outline-success { background: var(--surface); border-color: var(--success-line); color: var(--success); }
.btn-outline-success:hover { background: var(--success); color: #fff; border-color: var(--success); }
.btn-outline-warning { background: var(--surface); border-color: var(--warning-line); color: var(--warning); }
.btn-outline-warning:hover { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-outline-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-outline-brand { background: var(--surface); border-color: var(--brand-200); color: var(--brand-700); }
.btn-outline-brand:hover { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }
.btn-outline-wa { background: var(--surface); border-color: #a9e2bf; color: var(--wa-dark); }
.btn-outline-wa:hover { background: var(--wa); color: #fff; border-color: var(--wa); }
.btn-ghost { background: transparent; color: var(--ink-500); }
.btn-ghost:hover { background: var(--ink-100); color: var(--ink-900); }
.btn-ghost-danger { background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-bg); }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: var(--fs-sm); border-radius: 9px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-lg { min-height: 50px; padding: 12px 24px; font-size: var(--fs-base); border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding-left: 10px; padding-right: 10px; min-width: var(--tap); }
.btn-sm.btn-icon { min-width: 38px; }
.btn-spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.45); border-top-color: currentColor; border-radius: 50%; animation: spin .6s linear infinite; }
.btn-outline .btn-spin, .btn-outline-success .btn-spin { border-color: var(--ink-200); border-top-color: currentColor; }

/* Floating action button (mobile) */
.fab {
  position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: calc(var(--z-drawer) - 2);
  display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 20px 0 16px; border-radius: 28px; border: 0;
  background: var(--brand-600); color: #fff; font-weight: 800; font-size: var(--fs-md); cursor: pointer;
  box-shadow: 0 8px 24px rgba(35,86,166,.4); transition: transform .12s, background .15s;
}
.fab svg { width: 22px; height: 22px; }
.fab:hover { background: var(--brand-700); }
.fab:active { transform: scale(.97); }

/* ---------- 6. Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.label, label.field-label { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); }
.help { font-size: var(--fs-sm); color: var(--ink-400); }
.input, .select, .textarea,
input[type="text"].input, input[type="date"].input, input[type="password"].input, input[type="number"].input, input[type="search"].input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  color: var(--ink-900); background: var(--surface); border: 1.5px solid var(--ink-200); border-radius: 10px;
  outline: none; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
.select { padding-right: 40px; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6778' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-500); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--ink-300); }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.input-with-icon { position: relative; }
.input-with-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--ink-400); pointer-events: none; }
.input-with-icon input.input, .input-with-icon .input { padding-left: 40px !important; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--sp-4); }
.form-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.form-actions .btn { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-md); font-weight: 600; cursor: pointer; min-height: var(--tap); }
.check input { width: 20px; height: 20px; accent-color: var(--brand-600); }
/* Inline field errors (Add task: new person's name / mobile number) */
.field-error { font-size: var(--fs-xs); font-weight: 700; color: var(--danger); margin: 0; }
.input.has-error, .select.has-error { border-color: var(--danger); background: var(--danger-bg); }
/* "+ Add a new person" panel inside the Add task form */
.new-person { border: 1.5px dashed var(--brand-200); background: var(--brand-50); border-radius: var(--radius); padding: var(--sp-3) var(--sp-3) var(--sp-1); margin-bottom: var(--sp-4); }

/* Report-progress modal: one big tappable choice per status */
.prog-choices { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.prog-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  min-height: 62px; padding: 10px 12px; border: 1.5px solid var(--ink-200); border-radius: var(--radius);
  background: var(--surface); color: var(--ink-700); font: inherit; transition: border-color .15s, background .15s, box-shadow .15s;
}
.prog-choice:hover { border-color: var(--ink-300); background: var(--ink-50); }
.prog-choice .pc-label { font-weight: 800; font-size: var(--fs-md); }
.prog-choice .pc-sub { font-size: 11.5px; color: var(--ink-400); line-height: 1.35; }
.prog-choice.is-active { box-shadow: var(--ring); }
.prog-choice.tone-warning.is-active { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); }
.prog-choice.tone-danger.is-active  { border-color: var(--danger);  background: var(--danger-bg);  color: var(--danger); }
.prog-choice.tone-slate.is-active   { border-color: var(--slate);   background: var(--slate-bg);   color: var(--slate); }
.prog-choice.is-active .pc-sub { color: inherit; opacity: .85; }
.prog-current { font-size: var(--fs-xs); color: var(--ink-500); margin: 0 0 var(--sp-3); }

/* ---------- 7. Chips, badges, notices ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .01em; white-space: nowrap; line-height: 1.3; border: 1px solid transparent;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.chip.no-dot::before { display: none; }
.chip-overdue  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-line); }
.chip-today    { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.chip-upcoming { background: var(--slate-bg);   color: var(--slate);   border-color: var(--slate-line); }
.chip-done     { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.chip-pending  { background: var(--brand-50);   color: var(--brand-700); border-color: var(--brand-100); }
.chip-doer     { background: var(--brand-50);   color: var(--brand-700); }
.chip-doer::before { display: none; }
/* Assignment-workflow progress chips — the tone names come from progressTone() in wa_lib.php */
.chip-tone-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.chip-tone-danger  { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-line); }
.chip-tone-slate   { background: var(--slate-bg);   color: var(--slate);   border-color: var(--slate-line); }
.chip-tone-success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.chip-stack { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.badge-repeat { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 6px; background: var(--warning-bg); color: var(--warning); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; vertical-align: middle; }
.notice { padding: 12px 14px; border-radius: var(--radius); font-size: var(--fs-sm); font-weight: 600; line-height: 1.45; border: 1px solid transparent; }
.notice-info    { background: var(--brand-50);   color: var(--brand-800); border-color: var(--brand-100); }
.notice-success { background: var(--success-bg); color: var(--success);   border-color: var(--success-line); }
.notice-danger  { background: var(--danger-bg);  color: var(--danger);    border-color: var(--danger-line); }
.notice-warning { background: var(--warning-bg); color: #8a5510;          border-color: var(--warning-line); }
.notice .btn { margin-top: 8px; }
mark, .hl { background: #fff1b8; color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---------- 8. Segmented control + stat tiles ---------- */
/* phone: wraps into two rows of three; tablet+: one row */
.segmented { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--ink-100); border-radius: 12px; }
.seg-btn {
  flex: 1 1 calc(33.333% - 4px); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 6px 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--ink-500); font-size: var(--fs-sm); font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg-btn:hover { color: var(--ink-900); }
.seg-btn.is-active { background: var(--surface); color: var(--brand-700); box-shadow: var(--shadow-1); }
.seg-count { min-width: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--ink-200); color: var(--ink-700); font-size: 11px; font-weight: 800; line-height: 20px; text-align: center; }
.seg-btn.is-active .seg-count { background: var(--brand-100); color: var(--brand-800); }
.seg-btn[data-tone="overdue"] .seg-count:not(:empty):not([data-zero]) { background: var(--danger-bg); color: var(--danger); }
.seg-btn[data-tone="today"]   .seg-count:not(:empty):not([data-zero]) { background: var(--warning-bg); color: var(--warning); }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.stat { background: var(--surface); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-1); border-left: 4px solid var(--ink-200); }
.stat .stat-num { font-size: var(--fs-2xl); font-weight: 800; line-height: 1.1; }
.stat .stat-lbl { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); margin-top: 2px; }
.stat-overdue { border-left-color: var(--danger); }  .stat-overdue .stat-num { color: var(--danger); }
.stat-today   { border-left-color: var(--warning); } .stat-today .stat-num { color: var(--warning); }
.stat-upcoming{ border-left-color: var(--slate); }   .stat-upcoming .stat-num { color: var(--slate); }
.stat-done    { border-left-color: var(--success); } .stat-done .stat-num { color: var(--success); }

/* ---------- 9. Quick actions ---------- */
/* phone: compact 3-up tiles (icon over label); tablet+: roomy rows with a subtitle */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: var(--sp-2); }   /* auto-fit: a lone tile (non-manager) spans the row */
.qa-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px 8px; min-height: 92px;
  border: 0; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-1); text-align: center; cursor: pointer;
  color: var(--ink-900); font: inherit; text-decoration: none; transition: transform .1s, box-shadow .15s;
}
.qa-btn:hover { box-shadow: var(--shadow-2); }
.qa-btn:active { transform: scale(.99); }
.qa-btn:disabled { opacity: .6; cursor: not-allowed; }
.qa-btn .qa-ico { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; }
.qa-btn .qa-ico svg { width: 20px; height: 20px; }
.qa-btn .qa-text { display: flex; flex-direction: column; min-width: 0; }
.qa-btn .qa-title { display: block; font-weight: 800; font-size: var(--fs-sm); line-height: 1.2; }
.qa-btn .qa-sub { display: none; font-size: var(--fs-xs); color: var(--ink-500); margin-top: 2px; }
.qa-add .qa-ico { background: linear-gradient(135deg, var(--brand-500), var(--brand-800)); }
.qa-today .qa-ico { background: linear-gradient(135deg, #34b56a, #1f7a4d); }
.qa-overdue .qa-ico { background: linear-gradient(135deg, #e08a3a, #b85f15); }

/* ---------- 10. Data table -> stacked cards on phones ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
/* phone: cards */
.data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
.data-table thead { display: none; }
.data-table tbody tr {
  background: var(--surface); border: 1px solid var(--ink-100); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3); box-shadow: var(--shadow-1); position: relative;
}
.data-table td { padding: 6px 0; border: 0; display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); text-align: right; }
.data-table td::before { content: attr(data-label); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); flex-shrink: 0; text-align: left; }
.data-table td:not([data-label])::before { content: none; }
.data-table td[data-label="Task"] { flex-direction: column; align-items: flex-start; text-align: left; padding: 8px 0 10px; border-bottom: 1px solid var(--ink-100); margin-bottom: 4px; }
.data-table td.col-created { display: none; }
.data-table.show-created td.col-created { display: flex; }
.data-table td[data-label="Task"]::before { margin-bottom: 4px; }
.data-table td[data-label="Actions"] { flex-direction: column; align-items: stretch; padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--ink-100); }
.data-table td[data-label="Actions"]::before { display: none; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.row-actions .btn { flex: 1 1 auto; min-height: var(--tap); }
.row-actions .btn-icon { flex: 0 0 auto; min-width: 52px; }
.row-actions .btn-success, .row-actions .btn-outline-warning { flex: 1 1 100%; }  /* phone: "Done" / "Reopen" get their own full-width row */
/* phone: "Need more time?" also gets its own row so the label never wraps at 375px.
   The 600px block below resets .row-actions .btn to `flex: 0 0 auto`, which wins from there up. */
.row-actions .btn-newdate { flex: 1 1 100%; white-space: nowrap; }
.task-title { font-weight: 700; font-size: var(--fs-md); line-height: 1.4; color: var(--ink-900); word-break: break-word; }
.task-remarks { font-size: var(--fs-xs); color: var(--ink-500); margin-top: 4px; line-height: 1.4; word-break: break-word; }
.task-remarks b { color: var(--ink-400); font-weight: 700; }
/* Assignment workflow: who gave the task, and the latest thing the doer reported */
.task-assigner { font-size: var(--fs-xs); color: var(--ink-400); margin-top: 4px; }
.task-assigner .you-tag { background: var(--brand-50); color: var(--brand-700); border-radius: 5px; padding: 0 5px; font-weight: 800; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.task-progress {
  margin-top: 6px; padding: 6px 10px; border-radius: var(--radius-sm); border-left: 3px solid var(--slate);
  background: var(--slate-bg); color: var(--ink-700); font-size: var(--fs-xs); line-height: 1.45; word-break: break-word;
}
.task-progress.tone-warning { background: var(--warning-bg); border-left-color: var(--warning); }
.task-progress.tone-danger  { background: var(--danger-bg);  border-left-color: var(--danger); }
.task-progress.tone-slate   { background: var(--slate-bg);   border-left-color: var(--slate); }
.task-progress b { font-weight: 800; }
.task-progress .progress-by { display: block; margin-top: 2px; color: var(--ink-400); font-size: 11px; font-weight: 600; }
/* Activity log: a "progress" entry = status chip + the note the person wrote */
.progress-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.progress-detail .progress-note { color: var(--ink-700); }
.due-main { font-weight: 700; color: var(--ink-900); white-space: nowrap; }
.due-sub { display: block; font-size: var(--fs-xs); color: var(--ink-400); }
.date-cell { color: var(--ink-500); white-space: nowrap; }
.data-table th.col-created, .data-table td.col-created { display: none; }   /* Created column: only in the "All" bucket */
.data-table.show-created th.col-created, .data-table.show-created td.col-created { display: table-cell; }
tr.task-row.is-overdue { border-left: 4px solid var(--danger); }
tr.task-row.is-today   { border-left: 4px solid var(--warning); }
tr.task-row.is-upcoming{ border-left: 4px solid var(--slate-line); }
tr.task-row.is-done    { opacity: .8; }
tr.task-row.is-done .task-title { color: var(--ink-500); text-decoration: line-through; text-decoration-color: var(--ink-300); }
tr.task-row.is-marking { opacity: .55; }
tr.task-row.is-done-flash { animation: rowDone .6s ease forwards; }
@keyframes rowDone { 0% { background: var(--success-bg); } 100% { background: var(--success-bg); opacity: .3; transform: translateX(6px); } }
.th-sort { background: none; border: 0; padding: 0; font: inherit; font-weight: 800; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.th-sort .sort-arrow { font-size: 10px; color: var(--ink-300); }
.th-sort.is-sorted { color: var(--brand-700); }
.th-sort.is-sorted .sort-arrow { color: var(--brand-600); }
.list-meta { font-size: var(--fs-sm); color: var(--ink-500); font-weight: 600; min-height: 20px; }

/* ---------- 11. Empty / loading / skeleton ---------- */
.empty { text-align: center; padding: var(--sp-8) var(--sp-4); color: var(--ink-500); }
.empty .empty-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; margin-bottom: var(--sp-3); color: var(--ink-300); }
.empty .empty-ico svg { width: 28px; height: 28px; }
.empty h3 { color: var(--ink-700); margin-bottom: 4px; }
.empty p { font-size: var(--fs-sm); }
/* Celebratory empty state — used when the person doing the work has nothing pending (ui.php, User View) */
.empty.is-cheer .empty-ico { background: var(--success-bg); color: var(--success); width: 68px; height: 68px; }
.empty.is-cheer .empty-ico svg { width: 34px; height: 34px; }
.empty.is-cheer h3 { color: var(--success); font-size: var(--fs-lg); }
/* Encouraging one-liner under the page heading, and the friendly lead-in inside "Pick a new date" */
.cheer-line { margin-top: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--success); }
.due-lead { font-size: var(--fs-md); color: var(--ink-700); margin-bottom: var(--sp-3); line-height: 1.45; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--ink-200); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: var(--sp-6); color: var(--ink-500); font-size: var(--fs-sm); display: flex; align-items: center; justify-content: center; gap: 10px; }
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--ink-100) 25%, var(--ink-50) 50%, var(--ink-100) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-row { height: 84px; margin-bottom: var(--sp-3); }
.htmx-indicator { opacity: 0; transition: opacity .15s; pointer-events: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; pointer-events: auto; }
.list-indicator { position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 5; display: flex; justify-content: center; height: 0; overflow: visible; }
.list-indicator span { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); box-shadow: var(--shadow-2); border-radius: var(--radius-pill); padding: 6px 14px; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-500); }
.is-refreshing { opacity: .6; transition: opacity .15s; }

/* ---------- 12. Modals, confirm, toasts ---------- */
.modal { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; align-items: flex-end; justify-content: center; padding: 0; background: rgba(15,43,86,.5); overflow-y: auto; }
.modal-box { background: var(--surface); width: 100%; max-width: 560px; border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-3); animation: sheetUp .2s ease; max-height: 92vh; display: flex; flex-direction: column; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-3); border-bottom: 1px solid var(--ink-100); }
.modal-head h2 { font-size: var(--fs-lg); color: var(--ink-900); }
.modal-close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink-50); color: var(--ink-500); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--ink-100); color: var(--danger); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { padding: var(--sp-4); overflow-y: auto; }
.modal-foot { padding: var(--sp-3) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--ink-100); display: flex; gap: var(--sp-2); }
.modal-foot .btn { flex: 1; }
.modal-sm .modal-box { max-width: 420px; }
.confirm-msg { color: var(--ink-700); font-size: var(--fs-md); line-height: 1.55; white-space: pre-line; }

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--ink-900); color: #fff; font-size: var(--fs-sm); font-weight: 600; line-height: 1.45; box-shadow: var(--shadow-3); animation: toastIn .2s ease; }
.toast-success { background: #1f5d3c; }
.toast-danger  { background: #9b2f29; }
.toast-warning { background: #8a5510; }
.toast .toast-close { margin-left: auto; background: none; border: 0; color: rgba(255,255,255,.7); cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 13. Login + boot screens ---------- */
.boot-screen { position: fixed; inset: 0; z-index: var(--z-boot); background: var(--bg); display: flex; align-items: center; justify-content: center; color: var(--ink-500); gap: 10px; font-weight: 600; }
.login-screen { position: fixed; inset: 0; z-index: var(--z-boot); background: linear-gradient(145deg, var(--brand-600), var(--brand-900)); display: flex; align-items: center; justify-content: center; padding: var(--sp-4); }
.login-box { background: var(--surface); border-radius: var(--radius-xl); padding: var(--sp-8) var(--sp-6); width: 100%; max-width: 400px; box-shadow: var(--shadow-3); }
.login-box .brand-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 18px; margin-bottom: var(--sp-4); }
.login-box h1 { font-size: var(--fs-xl); margin-bottom: 4px; }
.login-box .login-sub { color: var(--ink-500); font-size: var(--fs-sm); margin-bottom: var(--sp-6); }
.login-help { margin-top: var(--sp-5); font-size: var(--fs-xs); color: var(--ink-400); text-align: center; line-height: 1.6; }

/* ---------- 14. Notifications panel ---------- */
.notif-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(92vw, 400px); z-index: calc(var(--z-drawer) + 1); background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; transform: translateX(104%); transition: transform .22s ease; }
.notif-panel.is-open { transform: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--ink-100); }
.notif-list { overflow-y: auto; flex: 1; padding: var(--sp-2); }
.notif-item { padding: 10px 12px; border-radius: var(--radius); font-size: var(--fs-sm); color: var(--ink-700); line-height: 1.45; border-bottom: 1px solid var(--ink-50); }
.notif-item.is-unread { background: var(--brand-50); border-bottom-color: transparent; margin-bottom: 4px; }
.notif-item .who { font-weight: 800; color: var(--slate); }
.notif-item .what { font-weight: 800; color: var(--brand-700); }
.notif-item .when { display: block; font-size: var(--fs-xs); color: var(--ink-400); margin-top: 3px; }
.notif-item .details { display: block; color: var(--ink-500); font-size: var(--fs-xs); margin-top: 2px; }

/* ---------- 15. Filters row ---------- */
.filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.filters .field { margin: 0; }
.filters-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-top: var(--sp-3); }
.filters-more .field { margin: 0; }
.filters-more .field.span-2 { grid-column: 1 / -1; }

/* ---------- 16. Print ---------- */
@media print {
  .app-topbar, .app-sidebar, .app-overlay, .fab, .toasts, .modal, .notif-panel, .no-print { display: none !important; }
  .app-main { padding: 0; }
  body { background: #fff; }
  .card, .data-table tbody tr { box-shadow: none; border: 1px solid #ddd; }
}

/* ==========================================================================
   >= 600px : tablet — real tables, two-column forms
   ========================================================================== */
@media (min-width: 600px) {
  .app-main { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .app-topbar .brand .brand-sub { display: inline; font-weight: 500; opacity: .8; font-size: var(--fs-sm); margin-left: 6px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .span-2 { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick-actions { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
  .qa-btn { flex-direction: row; justify-content: flex-start; text-align: left; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); min-height: 68px; }
  .qa-btn .qa-ico { width: 44px; height: 44px; }
  .qa-btn .qa-title { font-size: var(--fs-md); }
  .qa-btn .qa-sub { display: block; }
  .segmented { flex-wrap: nowrap; }
  .filters { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .filters-more { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters-more .field.span-2 { grid-column: auto; }
  .modal { align-items: center; padding: var(--sp-6); }
  .modal-box { border-radius: var(--radius-xl); animation: modalPop .18s ease; max-height: calc(100vh - 48px); }
  @keyframes modalPop { from { opacity: 0; transform: translateY(-10px) scale(.985); } to { opacity: 1; transform: none; } }
  .modal-foot { padding-bottom: var(--sp-4); }
  .modal-foot .btn { flex: 0 1 auto; min-width: 120px; }
  .modal-foot { justify-content: flex-end; }
  .toasts { left: auto; right: 20px; bottom: 20px; width: 360px; }
  .seg-btn { flex: 1 1 0; }
  .filters .field { margin: 0; }

  /* table mode */
  .data-table { display: table; }
  .data-table thead { display: table-header-group; }
  .data-table tbody { display: table-row-group; }
  .data-table tr { display: table-row; }
  .data-table td, .data-table th { display: table-cell; width: auto; }
  .data-table thead th { text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-400); padding: 10px 12px; border-bottom: 1.5px solid var(--ink-100); white-space: nowrap; background: var(--surface-2); }
  .data-table thead th:first-child { border-top-left-radius: var(--radius); }
  .data-table thead th:last-child { border-top-right-radius: var(--radius); }
  .data-table tbody tr { border: 0; border-bottom: 1px solid var(--ink-100); border-radius: 0; padding: 0; margin: 0; box-shadow: none; background: transparent; transition: background .12s; }
  .data-table tbody tr:hover { background: var(--surface-2); }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td { padding: 10px; text-align: left; vertical-align: middle; border: 0; }
  .data-table td::before { content: none !important; }
  .data-table td[data-label="Task"] { border: 0; margin: 0; padding: 10px; min-width: 200px; }
  /* Actions: fixed-width cell, buttons wrap onto a second line instead of ever clipping */
  .data-table td[data-label="Actions"] { border: 0; margin: 0; padding: 8px 10px; white-space: normal; min-width: 180px; width: 180px; }
  .data-table td[data-label="Due"] .due-sub { display: none; }   /* the status chip already says "3 days overdue" */
  .data-table td[data-label="Status"] { white-space: nowrap; }
  .data-table.show-created td.col-created { display: table-cell; }
  .data-table:not(.show-created) td.col-created, .data-table:not(.show-created) th.col-created { display: none; }
  .row-actions { flex-wrap: wrap; gap: 6px; width: auto; }
  .row-actions .btn, .row-actions .btn-success, .row-actions .btn-outline-warning { flex: 0 0 auto; min-height: 36px; padding-left: 10px; padding-right: 10px; }
  .row-actions .btn-icon { min-width: 36px; }
  tr.task-row.is-overdue, tr.task-row.is-today, tr.task-row.is-upcoming { border-left: 0; box-shadow: inset 4px 0 0 transparent; }
  tr.task-row.is-overdue { box-shadow: inset 4px 0 0 var(--danger); }
  tr.task-row.is-today { box-shadow: inset 4px 0 0 var(--warning); }
  tr.task-row.is-upcoming { box-shadow: inset 4px 0 0 var(--slate-line); }
  .task-title { font-size: var(--fs-sm); }
}

/* ==========================================================================
   >= 1024px : desktop — persistent sidebar, no topbar/FAB
   ========================================================================== */
@media (min-width: 1024px) {
  .app-topbar { display: none; }
  .app-overlay { display: none; }
  .app-overlay.is-open { display: block; }   /* still used behind the notifications panel */
  .app-sidebar { transform: none; width: var(--sidebar-w); box-shadow: none; border-right: 1px solid var(--ink-100); z-index: 50; }
  .sidebar-close { display: none; }
  .app-main { margin-left: var(--sidebar-w); padding: var(--sp-8) var(--sp-8) var(--sp-10); }
  .page-head { margin-bottom: var(--sp-5); }
  .page-head .page-title h1 { font-size: var(--fs-2xl); }
  .page-head .page-actions { display: flex; }
  .fab { display: none; }
  .card { padding: var(--sp-5); }
  .list-indicator { top: 12px; }
  .filters { grid-template-columns: minmax(280px, 1.4fr) minmax(200px, 1fr) auto; }
  .filters-more { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
  .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .data-table td[data-label="Task"] { min-width: 220px; }
  .data-table td[data-label="Actions"] { min-width: 250px; width: 250px; }
}

/* ---------- Shared guards + visibility utilities (promoted from page-local styles, 2026-09-06) ----------
   1) Grid tracks holding <input type="date"> / type="search" must be allowed to shrink on phones:
      those inputs have a wide min-content, so plain 1fr tracks overflow the card. All shared grids above
      now use minmax(0, 1fr); this also guards the field wrappers inside them.
   2) .only-phone / .until-desktop / .only-desktop: show controls in exactly one layout tier. */
.form-grid > *, .filters > *, .filters-more > *, .stats > * { min-width: 0; }
.form-grid input, .filters input, .filters-more input, .form-grid select, .filters select, .filters-more select { max-width: 100%; }
.only-desktop { display: none; }
@media (min-width: 600px)  { .only-phone { display: none !important; } }
@media (min-width: 1024px) { .until-desktop { display: none !important; } .only-desktop { display: initial; } }
