/* =====================================================================
   Tasks — stylesheet. Mobile-first, responsive, light + dark themes.
   ===================================================================== */

:root {
  --blue:#1a73e8; --blue-dark:#1557b0; --blue-soft:#e8f0fe;
  --bg:#ffffff; --bg-alt:#f1f3f4; --surface:#ffffff; --surface-2:#f8f9fa;
  --ink:#202124; --muted:#5f6368; --line:#dadce0; --line-soft:#e8eaed;
  --star:#f4b400; --danger:#d93025; --ok:#0f9d58;
  --shadow:0 1px 3px rgba(60,64,67,.15),0 1px 2px rgba(60,64,67,.1);
  --shadow-lg:0 4px 20px rgba(60,64,67,.2);
  --topbar-h:56px; --sidebar-w:280px; --radius:12px;
  --safe-b:env(safe-area-inset-bottom,0px);
  font-family:'Google Sans','Roboto',system-ui,-apple-system,Segoe UI,Arial,sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blue:#8ab4f8; --blue-dark:#aecbfa; --blue-soft:#283a5c;
    --bg:#202124; --bg-alt:#171717; --surface:#2a2b2e; --surface-2:#303134;
    --ink:#e8eaed; --muted:#9aa0a6; --line:#3c4043; --line-soft:#303134;
    --shadow:0 1px 3px rgba(0,0,0,.5); --shadow-lg:0 6px 24px rgba(0,0,0,.6);
  }
}
/* Manual theme override (set via the Settings toggle) — wins over the
   system preference in both directions. */
:root[data-theme="light"] {
  --blue:#1a73e8; --blue-dark:#1557b0; --blue-soft:#e8f0fe;
  --bg:#ffffff; --bg-alt:#f1f3f4; --surface:#ffffff; --surface-2:#f8f9fa;
  --ink:#202124; --muted:#5f6368; --line:#dadce0; --line-soft:#e8eaed;
  --shadow:0 1px 3px rgba(60,64,67,.15),0 1px 2px rgba(60,64,67,.1);
  --shadow-lg:0 4px 20px rgba(60,64,67,.2);
}
:root[data-theme="dark"] {
  --blue:#8ab4f8; --blue-dark:#aecbfa; --blue-soft:#283a5c;
  --bg:#202124; --bg-alt:#171717; --surface:#2a2b2e; --surface-2:#303134;
  --ink:#e8eaed; --muted:#9aa0a6; --line:#3c4043; --line-soft:#303134;
  --shadow:0 1px 3px rgba(0,0,0,.5); --shadow-lg:0 6px 24px rgba(0,0,0,.6);
}

* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { height:100%; }
body {
  margin:0; background:var(--bg-alt); color:var(--ink);
  font-size:15px; line-height:1.45; overscroll-behavior-y:none;
}
button { font-family:inherit; cursor:pointer; }
input,textarea,select { font-family:inherit; color:inherit; }
.ic { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2;
      stroke-linecap:round; stroke-linejoin:round; }
[hidden] { display:none !important; }

/* ---------- Buttons / inputs ---------- */
.btn { border:1px solid var(--line); background:var(--surface); color:var(--ink);
  border-radius:24px; padding:9px 18px; font-size:14px; font-weight:600; }
.btn:hover { background:var(--surface-2); }
.btn-primary { background:var(--blue); border-color:var(--blue); color:#fff; }
.btn-primary:hover { background:var(--blue-dark); }
.btn-danger { color:var(--danger); border-color:transparent; background:transparent; }
.btn-text { background:transparent; border:0; color:var(--blue); font-weight:600; padding:9px 12px; }
.btn-block { width:100%; }
.icon-btn { display:grid; place-items:center; width:40px; height:40px; border:0;
  background:transparent; color:var(--ink); border-radius:50%; }
.icon-btn:hover { background:rgba(128,128,128,.14); }
.icon-btn.sm { width:32px; height:32px; }
.icon-btn.sm .ic { width:18px; height:18px; }
input[type=text],input[type=email],input[type=password],input[type=date],
input[type=time],textarea,select {
  width:100%; padding:11px 12px; background:var(--surface); border:1px solid var(--line);
  border-radius:8px; font-size:15px; outline:none;
}
input:focus,textarea:focus,select:focus { border-color:var(--blue); box-shadow:0 0 0 1px var(--blue); }
label { display:block; font-size:12.5px; color:var(--muted); margin:12px 0 4px; }

/* ===================================================================
   AUTH
   =================================================================== */
.auth-screen { min-height:100dvh; display:grid; place-items:center; padding:20px;
  background:linear-gradient(160deg,var(--blue-soft),var(--bg-alt)); }
.auth-card { width:100%; max-width:400px; background:var(--surface); border-radius:16px;
  box-shadow:var(--shadow-lg); padding:28px 26px; }
.auth-logo { display:flex; align-items:center; gap:12px; margin-bottom:6px; }
.auth-logo h1 { font-size:22px; margin:0; }
.auth-tabs { display:flex; gap:6px; margin:18px 0 8px; border-bottom:1px solid var(--line); }
.auth-tab { flex:1; background:transparent; border:0; padding:12px; font-size:14px; font-weight:600;
  color:var(--muted); border-bottom:2px solid transparent; margin-bottom:-1px; }
.auth-tab.active { color:var(--blue); border-bottom-color:var(--blue); }
.auth-form { margin-top:8px; }
.auth-form .two { display:flex; gap:12px; } .auth-form .two > div { flex:1; }
.auth-form .btn-block { margin-top:22px; }
.auth-error { color:var(--danger); font-size:13.5px; margin-top:14px; text-align:center; }

/* ===================================================================
   TOP BAR
   =================================================================== */
.app-shell { min-height:100dvh; display:flex; flex-direction:column; }
.topbar { position:sticky; top:0; z-index:30; height:var(--topbar-h);
  display:flex; align-items:center; gap:6px; padding:0 8px;
  background:var(--surface); border-bottom:1px solid var(--line-soft); }
.brand { font-size:20px; font-weight:500; margin-left:4px; }
.topbar-spacer { flex:1; }
/* Search bar (expands over the top bar) */
.searchbar { position:absolute; inset:0; z-index:5; display:flex; align-items:center;
  gap:6px; padding:0 8px; background:var(--surface); }
.searchbar input { border:0; background:transparent; font-size:16px; flex:1; }
.searchbar input:focus { box-shadow:none; }
.badge { position:absolute; top:4px; right:4px; min-width:16px; height:16px; padding:0 4px;
  background:var(--danger); color:#fff; border-radius:9px; font-size:10px; font-weight:700;
  display:grid; place-items:center; }
.bell-wrap,.acct-wrap { position:relative; }
.avatar-btn { border:0; background:transparent; padding:4px; border-radius:50%; }
.avatar { display:grid; place-items:center; width:32px; height:32px; border-radius:50%;
  background:var(--blue); color:#fff; font-size:14px; font-weight:600; }

/* Dropdowns */
.dropdown { position:absolute; top:48px; right:0; min-width:280px; max-width:92vw;
  background:var(--surface); border:1px solid var(--line-soft); border-radius:12px;
  box-shadow:var(--shadow-lg); z-index:40; overflow:hidden; }
.dd-head { display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px; border-bottom:1px solid var(--line-soft); font-weight:600; font-size:14px; }
.dd-item { display:flex; gap:10px; align-items:flex-start; width:100%; text-align:left;
  padding:11px 14px; border:0; background:transparent; color:var(--ink); font-size:14px; }
.dd-item:hover { background:var(--surface-2); }
.dd-sub { color:var(--muted); font-size:12.5px; }
.notif-list { max-height:60vh; overflow:auto; }
.notif { border-bottom:1px solid var(--line-soft); }
.notif.unread { background:var(--blue-soft); }
.notif-title { font-weight:600; font-size:13.5px; }
.notif-body { color:var(--muted); font-size:12.5px; }
.notif-empty { padding:26px 14px; text-align:center; color:var(--muted); font-size:13px; }

/* ===================================================================
   LAYOUT: sidebar + main
   =================================================================== */
.layout { flex:1; display:flex; min-height:0; }
.sidebar { width:var(--sidebar-w); flex-shrink:0; background:var(--surface);
  border-right:1px solid var(--line-soft); padding:10px 8px; display:flex; flex-direction:column;
  gap:2px; overflow:auto; }
.smart-views { display:flex; flex-direction:column; gap:2px; padding-bottom:8px;
  margin-bottom:6px; border-bottom:1px solid var(--line-soft); }
.side-item { display:flex; align-items:center; gap:12px; width:100%; text-align:left;
  border:0; background:transparent; color:var(--ink); padding:10px 14px; border-radius:24px;
  font-size:14px; font-weight:500; }
.side-item:hover { background:var(--surface-2); }
.side-item.active { background:var(--blue-soft); color:var(--blue-dark); font-weight:600; }
.side-item .si-ic { width:20px; text-align:center; font-size:15px; }
.side-item .count { margin-left:auto; color:var(--muted); font-size:12px; font-weight:600; }
.side-item .li-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cb-inline { display:flex; align-items:center; gap:8px; margin:14px 0 0; font-size:14px; color:var(--ink); }
.cb-inline input { width:auto; }
.side-item .dot { width:12px; height:12px; border-radius:50%; }
.side-head { display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px 4px; color:var(--muted); font-size:12px; font-weight:600;
  text-transform:uppercase; letter-spacing:.6px; }
.lists { display:flex; flex-direction:column; gap:2px; }
.sidebar-foot { margin-top:auto; padding-top:8px; border-top:1px solid var(--line-soft); }
.shared-badge { font-size:10px; background:var(--surface-2); color:var(--muted);
  border-radius:8px; padding:1px 6px; margin-left:6px; }

.main { flex:1; min-width:0; display:flex; flex-direction:column; overflow:auto;
  background:var(--bg); }
#task-view { max-width:720px; width:100%; margin:0 auto; padding:8px 12px 120px; }

/* List header */
.list-header { display:flex; align-items:center; gap:8px; padding:14px 6px 8px; }
.list-header h2 { margin:0; font-size:22px; font-weight:500; }
.list-header .lh-dot { width:14px; height:14px; border-radius:50%; flex-shrink:0; }
.list-header .lh-spacer { flex:1; }
.list-meta { color:var(--muted); font-size:12.5px; margin:-2px 6px 6px; }

/* Add task row */
.add-task-row { display:flex; align-items:center; gap:12px; padding:6px 8px;
  border-bottom:1px solid var(--line-soft); }
.add-plus { display:grid; place-items:center; width:38px; height:38px; border:0;
  border-radius:50%; background:transparent; color:var(--blue); }
.add-plus:hover { background:var(--blue-soft); }
#add-task-input { border:0; background:transparent; padding:12px 0; font-size:15px; }
#add-task-input:focus { box-shadow:none; }

/* Tasks */
.tasks { display:flex; flex-direction:column; }
.task { display:flex; align-items:flex-start; gap:12px; padding:11px 8px;
  border-bottom:1px solid var(--line-soft); }
.task.sub { margin-left:34px; }
.task.dragging { opacity:.5; }
.task.drag-over { border-top:2px solid var(--blue); }
.check { flex-shrink:0; width:22px; height:22px; margin-top:1px; border:2px solid var(--muted);
  border-radius:50%; background:transparent; display:grid; place-items:center; padding:0; }
.check:hover { border-color:var(--blue); }
.check svg { width:14px; height:14px; opacity:0; stroke:#fff; }
.task.done .check { background:var(--blue); border-color:var(--blue); }
.task.done .check svg { opacity:1; }
.task-body { flex:1; min-width:0; }
.task-title { font-size:15px; word-break:break-word; }
.task.done .task-title { text-decoration:line-through; color:var(--muted); }
.task-notes { color:var(--muted); font-size:13px; margin-top:2px; white-space:pre-wrap;
  overflow:hidden; text-overflow:ellipsis; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.chips { display:flex; flex-wrap:wrap; gap:6px; margin-top:5px; }
.chip { display:inline-flex; align-items:center; gap:4px; font-size:11.5px; padding:2px 8px;
  border-radius:12px; background:var(--surface-2); color:var(--muted); }
.chip.due { background:var(--blue-soft); color:var(--blue-dark); }
.chip.repeat { background:var(--surface-2); color:var(--muted); }
.chip.overdue { background:#fce8e6; color:var(--danger); }
@media (prefers-color-scheme: dark){ .chip.overdue{ background:#5c2b28; color:#f6aea9; } }
.chip.assignee .mini-av { width:14px; height:14px; border-radius:50%; color:#fff;
  display:grid; place-items:center; font-size:8px; }
.task-actions { display:flex; align-items:center; gap:2px; }
.star-btn { border:0; background:transparent; color:var(--muted); width:34px; height:34px;
  border-radius:50%; font-size:18px; }
.star-btn.on { color:var(--star); }
.star-btn:hover { background:rgba(128,128,128,.14); }
.subtasks { display:flex; flex-direction:column; }

.empty { text-align:center; color:var(--muted); padding:60px 20px; }
.empty .big { font-size:40px; }
.empty p { margin:10px 0 0; font-size:14px; }

/* ===================================================================
   FAB
   =================================================================== */
.fab { position:fixed; right:20px; bottom:calc(20px + var(--safe-b)); z-index:25;
  width:56px; height:56px; border:0; border-radius:18px; background:var(--blue); color:#fff;
  box-shadow:var(--shadow-lg); display:grid; place-items:center; }
.fab:hover { background:var(--blue-dark); }
.fab .ic { width:26px; height:26px; stroke-width:2.4; }

/* Install PWA pill */
.install-fab { position:fixed; right:20px; bottom:calc(88px + var(--safe-b)); z-index:25;
  display:flex; align-items:center; gap:8px; border:0; border-radius:24px;
  background:var(--surface); color:var(--blue); box-shadow:var(--shadow-lg);
  padding:10px 18px; font-size:14px; font-weight:600; }
.install-fab .ic { width:20px; height:20px; }
@media (min-width: 841px){ .install-fab{ bottom:20px; } }

/* Bulk selection bar */
.bulk-bar { position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(16px + var(--safe-b)); z-index:40; display:flex; align-items:center; gap:6px;
  background:var(--surface); border:1px solid var(--line-soft); border-radius:30px;
  box-shadow:var(--shadow-lg); padding:6px 10px; max-width:94vw; }
.bulk-bar .bulk-count { font-size:14px; font-weight:600; padding:0 6px; white-space:nowrap; }
.bulk-bar .bulk-spacer { width:6px; }
.bulk-bar .star { font-size:18px; }

/* Selection mode on task rows */
.task.selectable { cursor:pointer; }
.task.selectable .sel-box { flex-shrink:0; width:22px; height:22px; margin-top:1px; border:2px solid var(--muted);
  border-radius:6px; display:grid; place-items:center; }
.task.selected { background:var(--blue-soft); }
.task.selected .sel-box { background:var(--blue); border-color:var(--blue); }
.task.selected .sel-box svg { stroke:#fff; width:14px; height:14px; }

/* Attachments */
.att-list { display:flex; flex-direction:column; gap:4px; margin:4px 0; }
.att { display:flex; align-items:center; gap:8px; padding:6px 8px; background:var(--surface-2);
  border-radius:8px; font-size:13px; }
.att .att-name { flex:1; color:var(--ink); text-decoration:none; overflow:hidden;
  text-overflow:ellipsis; white-space:nowrap; }
.att .att-name:hover { text-decoration:underline; }
.att .att-size { color:var(--muted); font-size:11.5px; }
.att-actions { display:flex; align-items:center; gap:10px; margin-top:6px; }
.att-progress { height:5px; background:var(--surface-2); border-radius:3px; margin-top:8px; overflow:hidden; }
.att-progress > div { height:100%; width:0; background:var(--blue); transition:width .15s; }

/* Quota bar */
.quota-bar { height:8px; background:var(--surface-2); border-radius:5px; overflow:hidden; margin:6px 0; }
.quota-bar > div { height:100%; background:var(--blue); }
.quota-bar.warn > div { background:var(--danger); }

/* Activity timeline */
.activity-item { display:flex; gap:10px; padding:9px 0; border-bottom:1px solid var(--line-soft); font-size:13.5px; }
.activity-item .avatar { width:28px; height:28px; font-size:11px; flex-shrink:0; }
.activity-item .act-when { color:var(--muted); font-size:11.5px; }

/* Filter modal chips */
.filter-group { margin-bottom:14px; }
.filter-group > label { margin-bottom:6px; }
.chip-row { display:flex; flex-wrap:wrap; gap:6px; }
.fchip { border:1px solid var(--line); background:var(--surface); color:var(--muted);
  border-radius:16px; padding:6px 12px; font-size:13px; font-weight:500; }
.fchip.on { background:var(--blue-soft); border-color:var(--blue); color:var(--blue-dark); }
.filter-active-dot { position:absolute; top:6px; right:6px; width:8px; height:8px;
  border-radius:50%; background:var(--blue); }

/* ===================================================================
   MODALS / BOTTOM SHEETS
   =================================================================== */
.modal-overlay { position:fixed; inset:0; z-index:60; background:rgba(0,0,0,.45);
  display:flex; align-items:center; justify-content:center; padding:16px; }
.modal { width:100%; max-width:460px; max-height:92dvh; overflow:auto; background:var(--surface);
  border-radius:16px; box-shadow:var(--shadow-lg); }
.modal.wide { max-width:900px; }
.modal-head { display:flex; align-items:center; gap:8px; padding:14px 16px;
  border-bottom:1px solid var(--line-soft); position:sticky; top:0; background:var(--surface); z-index:1; }
.modal-head h3 { margin:0; font-size:17px; flex:1; }
.modal-body { padding:16px; }
.modal-foot { display:flex; justify-content:flex-end; gap:8px; padding:12px 16px;
  border-top:1px solid var(--line-soft); position:sticky; bottom:0; background:var(--surface); }
.form-row { display:flex; gap:12px; } .form-row > * { flex:1; }
.seg { display:flex; gap:6px; }
.seg button { flex:1; border:1px solid var(--line); background:var(--surface); border-radius:8px;
  padding:9px; font-size:13px; font-weight:600; color:var(--muted); }
.seg button.on { background:var(--blue-soft); border-color:var(--blue); color:var(--blue-dark); }

/* Members / share rows */
.member { display:flex; align-items:center; gap:10px; padding:9px 0; border-bottom:1px solid var(--line-soft); }
.member .avatar { width:30px; height:30px; font-size:12px; }
.member .m-name { flex:1; font-size:14px; }
.member .m-sub { color:var(--muted); font-size:12px; }
.autolist { border:1px solid var(--line); border-radius:8px; margin-top:6px; overflow:hidden; }
.autolist button { display:flex; align-items:center; gap:8px; width:100%; text-align:left;
  border:0; background:var(--surface); padding:9px 12px; font-size:13.5px; color:var(--ink); }
.autolist button:hover { background:var(--surface-2); }

/* Subtask editor list */
.sub-edit { display:flex; align-items:center; gap:8px; padding:6px 0; }
.sub-edit input { flex:1; }
.sub-edit.done input { text-decoration:line-through; color:var(--muted); }

/* ===================================================================
   ADMIN
   =================================================================== */
#admin-view { max-width:1000px; width:100%; margin:0 auto; padding:16px 16px 120px; }
.admin-head { display:flex; align-items:center; gap:10px; margin:8px 0 16px; }
.admin-head h2 { margin:0; font-size:22px; font-weight:500; flex:1; }
.stat-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(140px,1fr)); gap:12px; margin-bottom:20px; }
.stat { background:var(--surface); border:1px solid var(--line-soft); border-radius:12px; padding:14px 16px; }
.stat .num { font-size:26px; font-weight:600; }
.stat .lbl { color:var(--muted); font-size:12.5px; margin-top:2px; }
.table-wrap { overflow-x:auto; background:var(--surface); border:1px solid var(--line-soft); border-radius:12px; }
table.users { width:100%; border-collapse:collapse; min-width:640px; }
table.users th,table.users td { text-align:left; padding:11px 12px; border-bottom:1px solid var(--line-soft); font-size:13.5px; }
table.users th { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.4px; }
.pill { font-size:11px; font-weight:600; padding:2px 9px; border-radius:12px; }
.pill.admin { background:var(--blue-soft); color:var(--blue-dark); }
.pill.user { background:var(--surface-2); color:var(--muted); }
.pill.on { background:#e6f4ea; color:var(--ok); } .pill.off { background:#fce8e6; color:var(--danger); }
@media (prefers-color-scheme: dark){ .pill.on{background:#1e3a2a;color:#81c995} .pill.off{background:#5c2b28;color:#f6aea9} }
.row-actions { display:flex; gap:4px; flex-wrap:wrap; }

/* ===================================================================
   TOAST
   =================================================================== */
.toast { position:fixed; left:50%; transform:translateX(-50%);
  bottom:calc(88px + var(--safe-b)); z-index:80; background:#323232; color:#fff;
  padding:12px 18px; border-radius:8px; font-size:13.5px; box-shadow:var(--shadow-lg);
  max-width:90vw; display:flex; align-items:center; gap:14px; }
.toast .toast-act { color:#8ab4f8; font-weight:600; background:transparent; border:0; }

/* ===================================================================
   RESPONSIVE
   =================================================================== */
.scrim { position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:35; }
.menu-btn { display:none; }

@media (max-width: 840px) {
  .menu-btn { display:grid; }
  .sidebar { position:fixed; top:var(--topbar-h); bottom:0; left:0; z-index:38;
    width:min(84vw,300px); transform:translateX(-105%); transition:transform .22s ease;
    box-shadow:var(--shadow-lg); }
  .sidebar.open { transform:translateX(0); }
  #task-view { padding-bottom:120px; }
}
@media (min-width: 841px) {
  .scrim { display:none !important; }
  .fab { display:none; }        /* desktop uses the inline add row */
}

/* Larger tap targets on touch devices */
@media (pointer: coarse) {
  .side-item { padding:12px 14px; }
  .task { padding:13px 8px; }
}
