:root {
  --bg: #e9edf2;
  --surface: #ffffff;
  --ink: #16202b;
  --muted: #5b6978;
  --line: #d3dae2;
  --navy: #14233a;
  --pending: #b7791f;
  --progress: #2563c9;
  --done: #2f855a;
  --alert: #d8432b;
  --radius: 10px;
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f161f; --surface: #172230; --ink: #e8edf3; --muted: #93a1b1;
    --line: #26354a; --navy: #5d8ff0;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--progress); outline-offset: 2px; }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--surface); padding: .5rem 1rem; border-radius: 8px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f161f; } }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--alert); border-color: transparent; background: transparent; }
.btn.sm { padding: .25rem .65rem; font-size: .82rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.link-btn { background: none; border: 0; color: var(--progress); cursor: pointer; padding: 0; font-weight: 600; font-size: .85rem; }

/* forms */
.form { display: grid; gap: .9rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
.form input, .form select, .form textarea, #search {
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; background: var(--surface); width: 100%; font-weight: 400;
}
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.form-error { color: var(--alert); min-height: 1.2em; font-size: .88rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 2rem; display: grid; gap: 1rem; }
.brand { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; color: var(--navy); }
.brand.small { font-size: 1.25rem; }
.auth-lead { color: var(--muted); }

/* tabs */
.tabs { display: flex; gap: .25rem; }
.tab { background: none; border: 0; padding: .45rem .9rem; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px 0 var(--navy); }
.auth-card .tabs { border-bottom: 1px solid var(--line); }

/* top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.view-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-switch button { background: none; border: 0; padding: .35rem .9rem; cursor: pointer; font-weight: 500; color: var(--muted); }
.view-switch button.active { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .view-switch button.active { color: #0f161f; } }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.whoami { font-weight: 600; }

/* bell */
.bell-wrap { position: relative; }
.icon-btn { position: relative; background: none; border: 1px solid var(--line); border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; }
.badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--alert); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.notif-panel { position: absolute; right: 0; top: 48px; width: min(380px, 92vw); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(10, 20, 35, .18); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
#notif-list { list-style: none; margin: 0; padding: 0; }
#notif-list li { display: flex; justify-content: space-between; gap: .8rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
#notif-list li.unread { background: color-mix(in srgb, var(--progress) 8%, var(--surface)); box-shadow: inset 3px 0 0 var(--progress); }
#notif-list .empty-note { color: var(--muted); justify-content: center; }
#notif-list button { white-space: nowrap; align-self: flex-start; }

/* page */
.page { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.toolbar { display: flex; gap: .8rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.toolbar .tabs { flex-wrap: wrap; }
.toolbar #search { max-width: 260px; margin-left: auto; }

/* cards & columns */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.column { background: color-mix(in srgb, var(--surface) 55%, transparent); border-radius: var(--radius); padding: .8rem; display: grid; gap: .7rem; border-top: 3px solid var(--line); }
.column.status-pending { border-top-color: var(--pending); }
.column.status-in_progress { border-top-color: var(--progress); }
.column.status-completed { border-top-color: var(--done); }
.column h2 { font-size: 1rem; display: flex; gap: .5rem; align-items: center; }
.count { background: var(--line); border-radius: 10px; padding: 0 .5rem; font-size: .8rem; }
.col-empty { text-align: center; padding: 1rem 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; display: grid; gap: .45rem; }
.card h3 { font-size: 1rem; }
.desc { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.meta { font-size: .8rem; color: var(--muted); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.due { font-size: .8rem; color: var(--muted); }
.due.overdue { color: var(--alert); font-weight: 600; }
.pill { font-size: .75rem; font-weight: 600; padding: .1rem .6rem; border-radius: 10px; color: #fff; white-space: nowrap; }
.pill.pending { background: var(--pending); }
.pill.in_progress { background: var(--progress); }
.pill.completed { background: var(--done); }

/* table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.empty { text-align: center; padding: 4rem 1rem; display: grid; gap: .3rem; }
.empty p:first-child { font-size: 1.15rem; font-weight: 600; }

/* dialog */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; width: min(520px, 94vw); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 20, 35, .5); }
dialog h2 { font-size: 1.3rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }

/* toasts */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: grid; gap: .5rem; z-index: 50; }
.toast { padding: .7rem 1rem; border-radius: 8px; color: #fff; background: var(--alert); max-width: 340px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.ok { background: var(--done); }

@media (max-width: 860px) {
  .kanban { grid-template-columns: 1fr; }
  .toolbar #search { max-width: none; margin-left: 0; flex: 1; }
  .row { grid-template-columns: 1fr; }
  .whoami { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: slide .2s ease-out; }
  @keyframes slide { from { transform: translateY(8px); opacity: 0; } }
}
