:root {
  --navy: #0b1f4b;
  --navy-2: #13306e;
  --blue: #1d4ed8;
  --blue-2: #2563eb;
  --blue-soft: #e8efff;
  --bg: #f4f7fd;
  --white: #ffffff;
  --text: #0f1b3d;
  --muted: #5b6785;
  --border: #dbe3f3;
  --red: #dc2626;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fff4e0;
  --green: #15803d;
  --green-soft: #e7f7ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11, 31, 75, .06), 0 6px 20px rgba(11, 31, 75, .06);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 20px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }

/* Header */
.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 100%);
  color: var(--white);
  padding: 22px 0 64px;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; background: var(--white); color: var(--blue);
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
}
.brand h1 { font-size: 1.35rem; font-weight: 750; letter-spacing: -.01em; }
.tagline { margin: 2px 0 0; color: #c7d5f7; font-size: .9rem; }
.notice {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
  padding: 7px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #7dd3fc; box-shadow: 0 0 0 3px rgba(125, 211, 252, .3); }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: -42px; }
.stat {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; flex-direction: column; border-top: 3px solid var(--blue);
}
.stat-warn { border-top-color: var(--red); }
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--navy); }
.stat-warn .stat-num { color: var(--red); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Cards & forms */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-top: 20px; }
.card h2 { font-size: 1.05rem; color: var(--navy); margin-bottom: 12px; }
.task-form { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: start; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: .82rem; font-weight: 650; color: var(--navy); }
.field-btn { padding-top: 23px; }
input[type="text"], input[type="search"], input[type="date"], select {
  font: inherit; color: var(--text); background: var(--white);
  border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
  min-height: 44px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--blue-2); box-shadow: 0 0 0 3px rgba(37, 99, 235, .18); }
.invalid { border-color: var(--red) !important; }
.error { color: var(--red); font-size: .78rem; min-height: 1em; }

/* Buttons */
.btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  min-height: 44px; transition: background .15s, transform .05s, color .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .filter:focus-visible, .icon-btn:focus-visible { outline: 3px solid rgba(37, 99, 235, .4); outline-offset: 2px; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: var(--blue-soft); color: var(--blue); }
.btn-ghost:hover { background: #d8e4ff; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-link { background: none; color: var(--blue); padding: 6px 8px; min-height: 0; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--red); }

/* Toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 24px 0 12px; flex-wrap: wrap; }
.filters { display: inline-flex; background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.filter {
  font: inherit; font-weight: 650; font-size: .9rem; border: 0; background: none; color: var(--muted);
  padding: 8px 16px; border-radius: 9px; cursor: pointer; min-height: 38px;
}
.filter.active { background: var(--navy); color: var(--white); }
.search { flex: 1; max-width: 320px; }

/* Task list */
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; align-items: center; gap: 14px; border-left: 4px solid var(--blue);
}
.task.p-high { border-left-color: var(--red); }
.task.p-medium { border-left-color: #f59e0b; }
.task.p-low { border-left-color: var(--green); }
.task-check { width: 22px; height: 22px; accent-color: var(--blue); cursor: pointer; flex-shrink: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 650; word-wrap: break-word; overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.done { opacity: .78; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: .78rem; }
.badge { padding: 2px 9px; border-radius: 999px; font-weight: 650; }
.b-high { background: var(--red-soft); color: var(--red); }
.b-medium { background: var(--amber-soft); color: var(--amber); }
.b-low { background: var(--green-soft); color: var(--green); }
.b-date { background: var(--blue-soft); color: var(--navy-2); }
.b-overdue { background: var(--red); color: var(--white); }
.b-done { background: var(--green-soft); color: var(--green); }
.task-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--border); background: var(--white);
  color: var(--navy); border-radius: 9px; padding: 7px 12px; cursor: pointer; min-height: 38px;
}
.icon-btn:hover { background: var(--blue-soft); border-color: #c4d4f7; }
.icon-btn.del:hover { background: var(--red-soft); color: var(--red); border-color: #f5c2c2; }

/* Empty state */
.empty { text-align: center; background: var(--white); border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px 20px; }
.empty-icon { font-size: 2.2rem; }
.empty h3 { color: var(--navy); margin: 8px 0 4px; }
.empty p { color: var(--muted); margin: 0 0 12px; }

.footer-actions { display: flex; justify-content: center; gap: 16px; margin: 20px 0 8px; font-size: .9rem; }
.site-footer { color: var(--muted); font-size: .82rem; text-align: center; padding: 20px 0 28px; }
.muted { color: var(--muted); }

/* Modal */
.modal { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px rgba(11, 31, 75, .3); color: var(--text); }
.modal::backdrop { background: rgba(11, 31, 75, .55); }
.modal-form { display: flex; flex-direction: column; gap: 12px; padding: 22px; }
.modal-form h2 { color: var(--navy); font-size: 1.15rem; }
.modal-form p { margin: 0; overflow-wrap: anywhere; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--navy); color: var(--white); padding: 10px 18px; border-radius: 10px;
  box-shadow: var(--shadow); font-size: .9rem; font-weight: 600; z-index: 50; max-width: calc(100% - 32px);
}

/* Responsive */
@media (max-width: 760px) {
  .task-form { grid-template-columns: 1fr 1fr; }
  .field-title { grid-column: 1 / -1; }
  .field-btn { grid-column: 1 / -1; padding-top: 0; }
  .field-btn .btn { width: 100%; }
}
@media (max-width: 560px) {
  .wrap { padding: 0 14px; }
  .topbar { padding-bottom: 58px; }
  .notice { width: 100%; justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .filters { display: flex; }
  .filter { flex: 1; }
  .search { max-width: none; }
  .task { flex-wrap: wrap; align-items: flex-start; }
  .task-body { flex: 1 1 0; }
  .task-check { margin: 2px 0 0; }
  .task-actions { width: 100%; justify-content: flex-end; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 10px; }
  .task-actions .icon-btn { flex: 1; }
}
