/* ==========================================================================
   Task Tracker — UI stylesheet
   A clean, modern admin theme. Light mode, system font, soft-tinted statuses.
   ========================================================================== */

:root {
  /* Surfaces & neutrals */
  --bg: #eef1f6;
  --bg-grad-a: #eef2f8;
  --bg-grad-b: #e7ecf4;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6eaf1;
  --border-strong: #d2d9e4;
  --text: #16202e;
  --text-soft: #3c4a5c;
  --muted: #697689;
  --muted-2: #8995a6;

  /* Brand */
  --primary: #2f5fd6;
  --primary-dark: #244dba;
  --primary-soft: #e9f0ff;
  --primary-ring: rgba(47, 95, 214, .25);
  --danger: #dc3b3b;
  --danger-dark: #be2f2f;
  --danger-soft: #fdecec;

  /* Status palette: --x = accent/dot, --x-bg = pill background, --x-fg = pill text */
  --s-not-started: #94a3b8; --s-not-started-bg: #eef1f6; --s-not-started-fg: #526077;
  --s-in-process: #3b82f6;  --s-in-process-bg: #e8f1fe;  --s-in-process-fg: #1d4ed8;
  --s-on-hold: #f59e0b;     --s-on-hold-bg: #fdf0db;     --s-on-hold-fg: #b4650a;
  --s-deferred: #8b5cf6;    --s-deferred-bg: #f1ecfe;    --s-deferred-fg: #6d28d9;
  --s-completed: #22c55e;   --s-completed-bg: #e6f7ee;   --s-completed-fg: #15803d;

  --p-high: #ef4444;   --p-high-bg: #fdecec;   --p-high-fg: #c53030;
  --p-normal: #3b82f6; --p-normal-bg: #e8f1fe; --p-normal-fg: #2456c8;
  --p-low: #94a3b8;    --p-low-bg: #eef1f6;    --p-low-fg: #5b6775;

  /* Depth */
  --shadow-sm: 0 1px 2px rgba(22, 32, 46, .06);
  --shadow: 0 1px 3px rgba(22, 32, 46, .07), 0 4px 16px rgba(22, 32, 46, .05);
  --shadow-lg: 0 8px 30px rgba(22, 32, 46, .14);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b)) fixed;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 23px; letter-spacing: -.02em; margin: 0 0 3px; font-weight: 700; }
h2 { font-size: 16px; letter-spacing: -.01em; margin: 0 0 16px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.req { color: var(--danger); }
.nowrap { white-space: nowrap; }
.icon { display: inline-block; vertical-align: -.18em; flex: 0 0 auto; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1440px; margin: 0 auto; padding: 0 22px; display: flex; align-items: center; gap: 26px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, #3f78ff, #2f5fd6); box-shadow: 0 4px 10px rgba(47, 95, 214, .35);
}
.brand-mark-lg { width: 54px; height: 54px; border-radius: 15px; }
.nav { display: flex; gap: 3px; flex: 1; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 9px;
  color: var(--muted); font-weight: 550; line-height: 1;
}
.nav a:hover { background: rgba(47, 95, 214, .07); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav a .icon { opacity: .9; }
.user-menu { display: flex; align-items: center; gap: 11px; }
.avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #596b85, #3c4a5c); color: #fff; font-weight: 700; font-size: 13px;
}
.user-name { font-weight: 600; color: var(--text-soft); }

/* ---------- Layout ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 28px 22px 72px; }
.container-wide { max-width: 1440px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 9px; flex-wrap: wrap; }
.crumbs { margin: 0 0 8px; font-size: 13px; }
.crumbs a { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-weight: 550; }
.crumbs a:hover { color: var(--primary); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }

/* ---------- KPI stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  color: var(--text); transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.stat-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; }
.ico-blue { background: var(--s-in-process-bg); color: var(--s-in-process-fg); }
.ico-amber { background: var(--s-on-hold-bg); color: var(--s-on-hold-fg); }
.ico-red { background: var(--p-high-bg); color: var(--p-high-fg); }
.ico-green { background: var(--s-completed-bg); color: var(--s-completed-fg); }
.stat-body { display: flex; flex-direction: column; line-height: 1.2; }
.stat-num { font-size: 24px; font-weight: 750; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.stat-alert { border-color: #f3c9c9; background: linear-gradient(0deg, #fff, #fff), var(--p-high-bg); }
.stat-alert .stat-num { color: var(--p-high-fg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-soft); font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; line-height: 1.2; font-family: inherit;
  transition: background .13s ease, border-color .13s ease, box-shadow .13s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn-primary { background: linear-gradient(180deg, #3f6fe0, var(--primary)); border-color: var(--primary-dark); color: #fff; box-shadow: 0 2px 6px rgba(47, 95, 214, .3); }
.btn-primary:hover { background: linear-gradient(180deg, #3867d6, var(--primary-dark)); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger-dark); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(22, 32, 46, .06); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; padding: 11px; font-size: 14.5px; }

/* ---------- Flash ---------- */
.flash { display: flex; align-items: center; gap: 8px; padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 550; border: 1px solid; }
.flash-success { background: var(--s-completed-bg); border-color: #bce6cb; color: #1a6e3a; }
.flash-error { background: var(--danger-soft); border-color: #f3c6c6; color: #a52f2f; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; display: flex; flex-direction: column; }
.field label { font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-soft); }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: #fff; width: 100%; transition: border-color .13s ease, box-shadow .13s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23697689' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-stack.narrow, .narrow { max-width: 430px; }
.form-actions { display: flex; gap: 10px; margin-top: 12px; align-items: center; }
.error { color: var(--danger); font-size: 12.5px; margin-top: 5px; font-weight: 550; }
.danger-zone { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.inline { display: inline; }
.row-inline { display: flex; gap: 6px; }
.row-inline input { min-width: 0; }

/* ---------- Auth pages ---------- */
.auth { max-width: 400px; margin: 7vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .brand-mark { margin: 0 auto 14px; }
.auth-brand h1 { margin-bottom: 2px; }
.auth .card { padding: 30px; }
.auth .card h1 { text-align: center; margin-bottom: 4px; }

/* ---------- Status filter chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft); font-size: 13px; font-weight: 600;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.chip:hover { border-color: var(--border-strong); text-decoration: none; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip.active b { color: #fff; }
.chip b { font-weight: 700; color: var(--muted); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 9px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 240px; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 12px; color: var(--muted-2); pointer-events: none; }
.search-box input[type=search] { padding-left: 36px; }
.filters select { width: auto; min-width: 150px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid thead th {
  background: var(--surface-2); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); white-space: nowrap; border-bottom: 1px solid var(--border);
}
table.grid thead th:first-child { border-top-left-radius: var(--radius); }
table.grid thead th:last-child { border-top-right-radius: var(--radius); }
table.grid thead th a { color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
table.grid thead th a:hover { color: var(--text); text-decoration: none; }
table.grid tbody tr { transition: background .1s ease; }
table.grid tbody tr:hover { background: #f7f9fc; }
table.grid .empty { text-align: center; padding: 54px 20px; color: var(--muted); }
.tracker .desc { max-width: 340px; }
.tracker .desc a { font-weight: 600; color: var(--text); }
.tracker .desc a:hover { color: var(--primary); }
.tracker .sender { max-width: 160px; word-break: break-word; color: var(--text-soft); font-weight: 550; }
.tracker .remarks { max-width: 220px; color: var(--muted); }
.tracker td.due, .tracker td.completed-on { font-variant-numeric: tabular-nums; }
.note-count { display: inline-flex; align-items: center; gap: 3px; color: var(--muted-2); font-size: 11.5px; margin-left: 6px; white-space: nowrap; font-weight: 600; }
.row-muted { opacity: .58; }
.row-actions { white-space: nowrap; }
tr.overdue .due { color: var(--p-high-fg); font-weight: 650; }
.tag-overdue { display: inline-block; background: var(--p-high-bg); color: var(--p-high-fg); font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: var(--radius-pill); vertical-align: middle; margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Badges: priority as soft pills with a dot ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.priority-high { background: var(--p-high-bg); color: var(--p-high-fg); }
.priority-normal { background: var(--p-normal-bg); color: var(--p-normal-fg); }
.priority-low { background: var(--p-low-bg); color: var(--p-low-fg); }
.badge.status-in-process { background: var(--s-in-process-bg); color: var(--s-in-process-fg); }
.badge.status-on-hold { background: var(--s-on-hold-bg); color: var(--s-on-hold-fg); }

/* Chip dots */
.dot.status-not-started { background: var(--s-not-started); }
.dot.status-in-process { background: var(--s-in-process); }
.dot.status-on-hold { background: var(--s-on-hold); }
.dot.status-deferred { background: var(--s-deferred); }
.dot.status-completed { background: var(--s-completed); }

.tag { background: var(--primary-soft); color: var(--primary-dark); font-size: 11px; padding: 1px 7px; border-radius: var(--radius-pill); font-weight: 650; margin-left: 4px; }

/* ---------- Inline status select (tracker) as a tinted pill ---------- */
select.status-select {
  width: auto; min-width: 128px; font-size: 12.5px; font-weight: 650; padding: 5px 28px 5px 24px;
  border-radius: var(--radius-pill); border: 1px solid transparent; cursor: pointer; position: relative;
  background-position: right 9px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23697689' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
/* colored leading dot via layered gradient background */
select.status-select { background-repeat: no-repeat, no-repeat; }
select.status-select.status-not-started { background-color: var(--s-not-started-bg); color: var(--s-not-started-fg); box-shadow: inset 11px 0 0 -8px var(--s-not-started); }
select.status-select.status-in-process { background-color: var(--s-in-process-bg); color: var(--s-in-process-fg); box-shadow: inset 11px 0 0 -8px var(--s-in-process); }
select.status-select.status-on-hold { background-color: var(--s-on-hold-bg); color: var(--s-on-hold-fg); box-shadow: inset 11px 0 0 -8px var(--s-on-hold); }
select.status-select.status-deferred { background-color: var(--s-deferred-bg); color: var(--s-deferred-fg); box-shadow: inset 11px 0 0 -8px var(--s-deferred); }
select.status-select.status-completed { background-color: var(--s-completed-bg); color: var(--s-completed-fg); box-shadow: inset 11px 0 0 -8px var(--s-completed); }
select.status-select:focus { box-shadow: 0 0 0 3px var(--primary-ring); border-color: var(--primary); }
tr.flash-saved { animation: flashsave 1s ease; }
@keyframes flashsave { from { background: #fff7d6; } to { background: transparent; } }

/* ---------- Notes ---------- */
.note-form { margin-bottom: 20px; }
.note { position: relative; border-left: 3px solid var(--border-strong); padding: 2px 0 12px 14px; margin-bottom: 12px; }
.note:last-child { margin-bottom: 0; }
.note-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.note-meta strong { color: var(--text-soft); }
.note-body { white-space: pre-wrap; color: var(--text-soft); }

/* ---------- Dropdown menu (user management) ---------- */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; z-index: 30; margin-top: 6px; background: #fff; border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px; width: 250px; display: flex; flex-direction: column; gap: 12px; }
.menu-body label { font-weight: 600; }
.reset-form { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 16px; justify-content: center; margin-top: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar-inner { gap: 10px; padding: 0 14px; }
  .container { padding: 20px 14px 56px; }
  .nav a span { display: none; }
  .nav a { padding: 8px 10px; }
  .user-name { display: none; }
  .brand-text { display: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  table.grid thead th { top: 0; }
}
