/* PRED Daily Tasks */
:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --border: #dfe6ec;
  --text: #0f172a;
  --muted: #5b6b7d;
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --primary-soft: #e6f4f2;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06);
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-head: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font-body); }
h1, h2 { font-family: var(--font-head); margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
a { color: var(--primary); }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); font-weight: 400; }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; min-height: 56px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font: 700 1.05rem var(--font-head); color: var(--text); text-decoration: none; padding: 14px 0; }
.brand .icon { color: var(--primary); width: 24px; height: 24px; }
.nav-toggle { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer; color: var(--text); }
.nav { display: none; flex-direction: column; width: 100%; padding-bottom: 10px; }
.nav.is-open { display: flex; }
.nav a, .nav-logout button {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font: 500 .93rem var(--font-body); background: none; border: 0; cursor: pointer; width: 100%; text-align: left;
}
.nav a:hover, .nav-logout button:hover { background: var(--bg); color: var(--text); }
.nav a.is-active { background: var(--primary-soft); color: var(--primary-dark); }
.nav-logout { margin: 0; }

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 16px 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-title { padding: 16px 18px 0; }
.table-card { padding: 0; overflow: hidden; }
.auth-card { max-width: 400px; margin: 40px auto; }
.auth-card h1 { margin-bottom: 16px; }
.auth-alt { text-align: center; margin: 14px 0 0; font-size: .9rem; }
.install-card { max-width: 760px; margin: 20px auto; }
.install-card h1 { margin-bottom: 14px; }
.install-card h2 { margin-top: 22px; }

/* Alerts */
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; font-size: .93rem; }
.alert-success { background: var(--ok-soft); border-color: #bfe5cb; color: #14532d; }
.alert-error { background: var(--danger-soft); border-color: #f5c2c2; color: #7f1d1d; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 600 .9rem var(--font-body);
  text-decoration: none; cursor: pointer; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: #c3ced8; background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #f0c4c4; background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); border-color: #e6a8a8; }
.btn-link { border-color: transparent; background: none; color: var(--primary); padding-left: 6px; padding-right: 6px; }
.btn-link:hover { background: none; border-color: transparent; text-decoration: underline; }
.btn-block { width: 100%; margin-top: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Forms */
label { display: block; font-weight: 600; font-size: .86rem; margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=search], input[type=url], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5df; border-radius: 8px; background: #fff; color: var(--text);
  font: 400 .95rem var(--font-body); min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input[disabled] { background: #f1f5f9; color: var(--muted); }
.form-card > h2:first-of-type { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: .86rem; margin: 10px 0 0; }
.check-label { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; margin: 12px 0 0; cursor: pointer; }
.check-label input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex: none; }
fieldset.checks { border: 1px solid var(--border); border-radius: 8px; padding: 4px 14px 12px; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 0 18px; }
fieldset.checks legend { font-weight: 600; font-size: .86rem; padding: 0 6px; }
.input-row { display: flex; gap: 8px; }
.inline-form { margin-bottom: 18px; }
form.inline { display: inline; }
.danger-zone { margin-top: 4px; }
pre.code { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .82rem; white-space: pre-wrap; word-break: break-all; margin: 10px 0; }
.req-list { list-style: none; padding: 0; margin: 0 0 6px; font-size: .9rem; }
.req-list .ok { color: var(--ok); }
.req-list .bad { color: var(--danger); font-weight: 600; }
.steps li { margin-bottom: 6px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.stat:hover { border-color: #c3ced8; }
.stat-num { font: 700 1.7rem/1.1 var(--font-head); }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.stat-danger .stat-num { color: var(--danger); }
.stat-warn .stat-num { color: var(--warn); }
.stat-accent .stat-num { color: var(--primary); }
.stat-ok .stat-num { color: var(--ok); }

/* Quick add */
.quick-add-form { display: grid; grid-template-columns: 1fr; gap: 0 12px; align-items: end; }
.quick-add-form label { margin-top: 8px; }
.field-btn { margin-top: 12px; }
.field-btn .btn { width: 100%; }

/* Tabs and filters */
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 9px 13px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.is-active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters input[type=search] { grid-column: 1 / -1; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: .93rem; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfd; }
.col-check { width: 44px; padding-right: 0 !important; }
.col-actions { text-align: right; white-space: nowrap; width: 90px; }
.check { background: none; border: 0; padding: 4px; cursor: pointer; color: #94a3b8; border-radius: 50%; display: inline-flex; }
.check .icon { width: 24px; height: 24px; }
.check:hover { color: var(--ok); }
.check.is-checked { color: var(--ok); }
.task-title { font-weight: 600; color: var(--text); text-decoration: none; }
.task-title:hover { color: var(--primary); text-decoration: underline; }
.task-meta { color: var(--muted); font-size: .8rem; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
tr.is-done .task-title { text-decoration: line-through; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 34px 16px; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty .icon { width: 34px; height: 34px; color: #b6c2ce; }
.list-foot { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .88rem; gap: 12px; flex-wrap: wrap; }
.pager { display: inline-flex; align-items: center; gap: 10px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: #eef2f6; color: #475569; }
.prio-urgent { background: var(--danger-soft); color: var(--danger); }
.prio-high { background: var(--warn-soft); color: var(--warn); }
.prio-medium { background: var(--primary-soft); color: var(--primary-dark); }
.prio-low { background: #eef2f6; color: #475569; }
.status-pending { background: #eef2f6; color: #475569; }
.status-in_progress { background: #e5efff; color: #1d4ed8; }
.status-done { background: var(--ok-soft); color: var(--ok); }
.badge-new { background: var(--primary); color: #fff; margin-left: 6px; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 0 16px; align-items: start; }

/* Small screens: task rows become cards */
@media (max-width: 767px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: .78rem; font-weight: 600; }
  .table td[data-label="Task"]::before, .table td[data-label="Name"]::before { content: none; }
  .tasks-table tr { padding-left: 52px; }
  .tasks-table .col-check { position: absolute; left: 10px; top: 10px; width: auto; }
  .col-actions { text-align: left; width: auto; }
  .table td .task-meta { display: inline-flex; margin-left: 6px; }
  .table td[data-label="Task"] .task-meta, .table td[data-label="Name"] .task-meta { display: flex; margin-left: 0; }
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .nav { display: flex; flex-direction: row; width: auto; padding: 0; gap: 2px; align-items: center; }
  .nav a, .nav-logout button { width: auto; padding: 8px 12px; }
  .stats { grid-template-columns: repeat(5, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .quick-add-form { grid-template-columns: minmax(220px, 3fr) 1.4fr 1.1fr 1fr 1.3fr auto; }
  .quick-add-form label { margin-top: 0; }
  .field-btn { margin-top: 0; }
  .filters { display: flex; flex-wrap: wrap; align-items: center; }
  .filters input[type=search] { width: 240px; }
  .filters select { width: auto; min-width: 150px; }
  .two-col { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .two-col-even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .stat, .nav a { transition: background-color .12s, border-color .12s, color .12s; }
}
