/*
 * Application-wide styles. Propshaft serves every stylesheet in this
 * directory; later declarations override earlier ones per normal cascade.
 */

:root {
  --ink: #1a202c;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }

/* --- Top navigation --- */
.topnav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topnav-brand { font-weight: 700; }
.topnav nav { display: flex; gap: 1.25rem; flex: 1; }
.topnav nav a { color: var(--ink); text-decoration: none; font-weight: 500; }
.topnav nav a:hover { color: var(--accent); }
.topnav-user { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.875rem; }

/* --- Flash messages --- */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash-notice { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-alert { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* --- Cards, tables --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2, .card h3 { margin-top: 0; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); }
table.list th, table.list td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
table.list th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.list tbody tr:hover { background: var(--bg); }

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-initiated { background: #eff6ff; color: #1d4ed8; }
.badge-in_progress { background: #fffbeb; color: #b45309; }
.badge-completed { background: #ecfdf5; color: #047857; }
.badge-closed { background: #f1f5f9; color: #475569; }
.badge-cancelled { background: #f1f5f9; color: #94a3b8; }
.badge-overdue { background: #fef2f2; color: #b91c1c; }
.badge-pending { background: #f1f5f9; color: #475569; }
.badge-skipped { background: #f5f3ff; color: #6d28d9; }
.badge-stubbed { background: #f5f3ff; color: #6d28d9; }
.badge-sent { background: #ecfdf5; color: #047857; }
.badge-failed { background: #fef2f2; color: #b91c1c; }
.badge-automated { background: #eff6ff; color: #1d4ed8; }
.badge-manual { background: #fdf4ff; color: #a21caf; }
table.list tr.unread td { background: #eff6ff; }

/* --- Role tabs (My Tasks) --- */
.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  margin-bottom: -1px;
}
.tab:hover { color: var(--accent); }
.tab.active {
  background: var(--card);
  border-color: var(--line);
  border-bottom: 1px solid var(--card);
  color: var(--ink);
  font-weight: 600;
}
.tab-count {
  background: var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.tab.active .tab-count { background: var(--accent); color: #fff; }
.role-heading { margin: 0 0 0.75rem; font-size: 1.1rem; color: var(--muted); }

/* --- Progress bar --- */
.progress { background: var(--line); border-radius: 999px; height: 8px; min-width: 80px; overflow: hidden; }
.progress-fill { background: var(--green); height: 100%; border-radius: 999px; transition: width 0.3s; }
.progress-label { font-size: 0.75rem; color: var(--muted); }

/* --- Buttons & forms --- */
.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.55rem 1.2rem; font-size: 0.95rem; font-weight: 600; }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 0.875rem; }
.btn-link:hover { color: var(--accent); }

form.stacked label { display: block; font-weight: 600; margin: 0.75rem 0 0.25rem; }
form.stacked input[type="text"], form.stacked input[type="email"], form.stacked input[type="date"],
form.stacked input[type="password"], form.stacked select, form.stacked textarea {
  width: 100%;
  max-width: 420px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

/* --- Checklist items --- */
.role-group { margin-bottom: 1.5rem; }
.role-group > h3 { margin-bottom: 0.5rem; }
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 0.5rem;
}
.task-item.task-done { opacity: 0.7; }
.task-body { flex: 1; }
.task-title { font-weight: 600; }
.task-meta { font-size: 0.8rem; color: var(--muted); }
.task-meta .overdue { color: var(--red); font-weight: 600; }
.task-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.task-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.task-actions form { display: inline; }
.task-comments { margin-top: 0.5rem; max-width: 420px; }
.task-comments .comment { padding: 0.4rem 0; font-size: 0.85rem; }
.task-comment-box { margin-top: 0.5rem; }
/* Post Comment sits below its textarea, separate from the status buttons above. */
.task-comment-box .task-actions { margin-top: 0.4rem; }
/* Compact by default (the comment is optional); grows when focused. */
.task-comment-box textarea { width: 100%; max-width: 420px; height: 2rem; min-height: 2rem; resize: none; padding: 0.4rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 0.85rem; }
.task-comment-box textarea:focus { min-height: 4.5rem; resize: vertical; }

/* --- Audit trail & comments --- */
.audit-entry { display: flex; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-size: 0.875rem; }
.audit-time { color: var(--muted); white-space: nowrap; }
.comment { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.comment-meta { font-size: 0.8rem; color: var(--muted); }

/* --- Page headers --- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 0.75rem; }
.page-head h1 { margin: 0; font-size: 1.4rem; }
.subtle { color: var(--muted); }

/* --- Auth pages --- */
.auth-card { max-width: 400px; margin: 4rem auto; }

/* --- Dashboard --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat { text-align: center; margin-bottom: 0; }
.stat-value { display: block; font-size: 1.9rem; font-weight: 700; }
.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-danger .stat-value { color: var(--red); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.chart-grid .card { margin-bottom: 0; }

/* --- Timesheets grid --- */
.month-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.25rem; }
.month-nav { display: flex; align-items: center; gap: 0.6rem; font-size: 1.05rem; }
.month-nav .eyebrow { font-weight: 500; font-size: 0.8rem; color: var(--muted); }

.grid-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.grid-toolbar .grid-filter { margin: 0; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle .toggle-btn {
  padding: 0.45rem 0.9rem; font-size: 0.85rem; font-weight: 600; text-decoration: none;
  color: var(--muted); background: var(--card); border-right: 1px solid var(--line);
}
.view-toggle .toggle-btn:last-child { border-right: none; }
.view-toggle .toggle-btn:hover { background: #eff6ff; }
.view-toggle .toggle-btn.is-active { background: var(--accent); color: #fff; }
.filter-select {
  padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 0.85rem; max-width: 15rem;
}

.week-accordion {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 0.75rem; overflow: hidden;
}
.week-accordion > summary {
  display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 1.1rem;
  cursor: pointer; list-style: none; font-weight: 700;
}
.week-accordion > summary::-webkit-details-marker { display: none; }
.week-accordion > summary::before { content: "▶"; font-size: 0.7rem; color: var(--muted); transition: transform 0.15s; }
.week-accordion[open] > summary::before { transform: rotate(90deg); }
.week-accordion > summary .subtle { font-weight: 500; }

.grid-scroll { overflow-x: auto; border-top: 1px solid var(--line); }
table.grid { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 0.87rem; }
.grid th.who-col, .grid td.who-cell { text-align: left; padding: 0.6rem 1.1rem; width: 260px; }
.grid th { text-align: center; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 0.7rem 0.4rem; border-bottom: 1px solid var(--line); }
.grid th.total-col, .grid td.row-total { text-align: right; padding-right: 1.1rem; }
.grid tbody tr, .grid tfoot tr { border-bottom: 1px solid var(--line); }
/* Styled by role, not by which of person/project it holds — the grid's two views
   swap what lands on each line. */
.grid .row-primary { font-weight: 600; }
.grid .row-secondary { color: var(--muted); font-size: 0.79rem; margin-top: 0.1rem; }
.grid .hour-cell { text-align: center; padding: 0.3rem; }
.grid .hour-cell form { margin: 0; }
.grid .hour-cell input {
  width: 3.1rem; text-align: center; padding: 0.35rem 0.2rem; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit;
}
.grid .hour-cell input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid .row-total { font-weight: 700; }
.grid tfoot .total-row td { background: #eaf1fb; font-weight: 700; padding: 0.7rem 1.1rem; }
.grid tfoot .total-row .row-total { color: var(--accent); }

.add-row { padding: 0.65rem 1.1rem; }
.add-row-btn {
  border: 1px dashed var(--accent); background: transparent; color: var(--accent);
  border-radius: 8px; padding: 0.4rem 0.75rem; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.add-row-btn:hover { background: #eff6ff; }

/* --- Report: date range --- */
.range-form { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.9rem; margin: 0 0 0.9rem; }
.range-field { display: flex; flex-direction: column; gap: 0.3rem; }
.range-field .field-label { margin: 0; }
.range-field input {
  padding: 0.45rem 0.7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 0.9rem;
}
.range-presets { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.range-presets .eyebrow { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 0.2rem; }
.range-presets .btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.range-summary { display: flex; align-items: baseline; gap: 0.6rem; margin: 1.1rem 0 0.9rem; }

.totals-row { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.6rem; font-size: 0.84rem; }
.totals-label { width: 150px; flex: none; color: var(--muted); }
.totals-bar { flex: 1; background: var(--line); border-radius: 999px; height: 8px; overflow: hidden; }
.totals-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.totals-value { width: 60px; text-align: right; font-weight: 600; }

/* --- Add Entry modal --- */
dialog.ts-modal {
  border: none; border-radius: 14px; padding: 1.5rem 1.6rem; width: min(760px, 92vw);
  max-height: 88vh; box-shadow: 0 20px 60px rgba(0,0,0,0.25); color: var(--ink); background: var(--card);
}
dialog.ts-modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.modal-head h2 { margin: 0; font-size: 1.1rem; }
.modal-close { border: none; background: none; font-size: 1.2rem; color: var(--muted); cursor: pointer; }
.field-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); display: block; margin-bottom: 0.4rem; }
.person-select { width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; margin-bottom: 1.1rem; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.modal-grid h4 { margin: 0 0 0.2rem; font-size: 0.92rem; }
.modal-grid .hint { color: var(--muted); font-size: 0.78rem; margin: 0 0 0.6rem; }
.search-box { display: flex; align-items: center; gap: 0.5rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem 0.7rem; margin-bottom: 0.6rem; background: var(--bg); }
.search-box input { border: none; background: transparent; outline: none; color: var(--ink); font: inherit; width: 100%; }
.project-list { border: 1px solid var(--line); border-radius: 8px; max-height: 220px; overflow-y: auto; }
.project-list .item { padding: 0.6rem 0.75rem; font-size: 0.85rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.project-list .item:last-child { border-bottom: none; }
.project-list .item:hover { background: #eff6ff; }
.selected-list { min-height: 220px; }
.selected-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.selected-item .remove { color: var(--red); cursor: pointer; font-weight: 700; flex: none; }
.selected-item .name { flex: 1; }
.selected-item input[type="number"] { width: 3.4rem; text-align: center; padding: 0.3rem; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); font: inherit; }
.modal-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--muted); margin: 0.9rem 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1rem; }
