:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef4fb;
  --text: #162033;
  --muted: #667085;
  --line: #d8e1ed;
  --blue: #1976d2;
  --green: #22a06b;
  --yellow: #f5b700;
  --red: #ec5b56;
  --shadow: 0 18px 50px rgba(22, 32, 51, .12);
  --radius: 8px;
  --control: #ffffff;
  --control-hover: #f4f8fd;
  --active-bg: #e9f3ff;
  --active-border: #9bc8ff;
  --timer-bg: linear-gradient(135deg, rgba(25, 118, 210, .12), rgba(34, 160, 107, .06));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 12% 8%, rgba(25, 118, 210, .11), transparent 34%), linear-gradient(180deg, var(--bg), var(--panel-2));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  --bg: #101725;
  --panel: #172235;
  --panel-2: #1f2b40;
  --text: #eef4ff;
  --muted: #a8b4c7;
  --line: #2d3c55;
  --blue: #63a8ff;
  --green: #35c98f;
  --yellow: #ffd166;
  --red: #ff7a74;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
  --control: #1c2940;
  --control-hover: #23324c;
  --active-bg: rgba(99, 168, 255, .15);
  --active-border: rgba(99, 168, 255, .46);
  --timer-bg: linear-gradient(135deg, rgba(99, 168, 255, .14), rgba(53, 201, 143, .08));
}

button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.brand, .top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.top-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.logo {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), #2abf88);
  color: white;
  font-weight: 900;
  box-shadow: var(--shadow);
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
.brand h1 { font-size: clamp(1.45rem, 4vw, 2.05rem); line-height: 1.05; }
.brand p, .muted { color: var(--muted); }
.brand p { margin: 4px 0 0; font-size: .95rem; }

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

body.dark .panel {
  background: rgba(23, 34, 53, .92);
}

body.dark .login-page {
  background:
    radial-gradient(circle at 18% 14%, rgba(99, 168, 255, .12), transparent 30%),
    radial-gradient(circle at 86% 82%, rgba(53, 201, 143, .10), transparent 28%),
    linear-gradient(180deg, #101725, #172235);
}

body.dark .login-card {
  background: rgba(23, 34, 53, .94);
  border-color: var(--line);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control);
  color: var(--muted);
  padding: 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-toggle {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover,
.secondary:hover,
.filter:hover,
.report-tab:hover {
  background: var(--control-hover);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 14%, rgba(25, 118, 210, .14), transparent 30%),
    radial-gradient(circle at 86% 82%, rgba(34, 160, 107, .12), transparent 28%),
    linear-gradient(180deg, #f7faff, #edf3fb);
}

.login-card {
  width: min(460px, 100%);
  padding: 34px;
  border-color: rgba(155, 172, 196, .42);
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 24px 70px rgba(22, 32, 51, .14);
}

.login-brand {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 26px;
}

.login-card .logo {
  width: 52px;
  height: 52px;
  margin: 0;
  border-radius: 12px;
  font-size: 1.1rem;
}

.login-card h1 {
  font-size: 1.7rem;
  line-height: 1.1;
}

.login-card p {
  margin: 7px 0 0;
  line-height: 1.5;
}

.login-form {
  gap: 16px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.login-form .field {
  width: 100%;
  height: 50px;
  border-color: #ccd8e8;
  border-radius: 10px;
  font-size: 1rem;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.login-form .field:focus {
  border-color: rgba(25, 118, 210, .72);
  box-shadow: 0 0 0 4px rgba(25, 118, 210, .12);
}

body.dark .login-form .field {
  border-color: var(--line);
}

body.dark .login-form .field:focus {
  border-color: var(--active-border);
  box-shadow: 0 0 0 4px rgba(99, 168, 255, .12);
}

::placeholder {
  color: var(--muted);
  opacity: .72;
}

.login-submit {
  width: 100%;
  min-height: 50px;
  margin-top: 4px;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(25, 118, 210, .22);
}

.form-grid {
  display: grid;
  gap: 10px;
}

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
  width: 100%;
  min-width: 0;
}

.toolbar .field {
  flex: 1 1 220px;
}

.toolbar .select {
  flex: 0 1 142px;
}

.field, .select {
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.toolbar .primary {
  flex: 0 0 104px;
  width: 104px;
  min-height: 46px;
  padding: 0 12px;
}

.field:focus, .select:focus {
  border-color: var(--active-border);
  box-shadow: 0 0 0 4px rgba(25, 118, 210, .10);
}

.button, .primary, .secondary, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 10px;
  padding: 0 15px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.button:active, .primary:active, .secondary:active, .danger:active, .filter:active, .report-tab:active {
  transform: translateY(1px);
}

.primary {
  border: 0;
  background: #2278d8;
  color: white;
  box-shadow: 0 10px 22px rgba(25, 118, 210, .18);
}

.primary:hover {
  background: #1c6fc9;
}

.secondary { border: 1px solid var(--line); background: var(--control); color: var(--text); }
.danger { border: 1px solid rgba(236, 91, 86, .35); background: rgba(236, 91, 86, .1); color: var(--red); }
.export { border: 0; background: #22a06b; color: white; }
.export:hover { background: #1d8e5f; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.workspace, .focus-panel, .analytics { padding: 18px; }

.filters, .report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filters {
  margin-bottom: 16px;
  margin-top: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(238, 244, 251, .62);
  width: fit-content;
  max-width: 100%;
}

body.dark .filters {
  background: rgba(31, 43, 64, .72);
}

.filter, .report-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--control);
  color: var(--muted);
  min-height: 34px;
  min-width: 92px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.filter.active, .report-tab.active {
  background: var(--active-bg);
  color: var(--blue);
  border-color: var(--active-border);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(25, 118, 210, .08);
}

.filter-todo {
  background: rgba(236, 91, 86, .12);
  border-color: rgba(236, 91, 86, .32);
  color: #b63c38;
}

.filter-progress {
  background: rgba(245, 151, 48, .14);
  border-color: rgba(245, 151, 48, .36);
  color: #a65f05;
}

.filter-done {
  background: rgba(34, 160, 107, .14);
  border-color: rgba(34, 160, 107, .36);
  color: #16784f;
}

.filter-todo.active {
  background: #ec5b56;
  border-color: #ec5b56;
  color: white;
}

.filter-progress.active {
  background: #f59e30;
  border-color: #f59e30;
  color: #1f2937;
}

.filter-done.active {
  background: #22a06b;
  border-color: #22a06b;
  color: white;
}

body.dark .filter-todo {
  background: rgba(255, 122, 116, .15);
  border-color: rgba(255, 122, 116, .36);
  color: #ffb0ac;
}

body.dark .filter-progress {
  background: rgba(255, 209, 102, .15);
  border-color: rgba(255, 209, 102, .34);
  color: #ffd98a;
}

body.dark .filter-done {
  background: rgba(53, 201, 143, .15);
  border-color: rgba(53, 201, 143, .34);
  color: #88e6bf;
}

body.dark .filter-todo.active,
body.dark .filter-progress.active,
body.dark .filter-done.active {
  color: #101725;
}

.task-list {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.task {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.task:hover {
  border-color: var(--active-border);
  box-shadow: 0 12px 28px rgba(22, 32, 51, .08);
}

.check {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}

.task.done .check { border-color: var(--green); background: var(--green); color: white; }
.task.done h3 { color: var(--muted); text-decoration: line-through; }
.task h3 {
  margin-bottom: 5px;
  font-size: .98rem;
  line-height: 1.25;
}

.task-actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
}

.task-actions .secondary,
.task-actions .danger {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: .8rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--panel-2);
  color: var(--muted);
}

.priority-high { color: var(--red); background: rgba(236, 91, 86, .12); }
.priority-medium { color: #a36b00; background: rgba(245, 183, 0, .18); }
.priority-low { color: var(--green); background: rgba(34, 160, 107, .13); }

.focus-panel {
  display: grid;
  align-content: space-between;
  gap: 16px;
}

.focus-task {
  border-left: 4px solid var(--blue);
  padding: 12px 14px;
  background: var(--control);
  border-radius: 10px;
}

.focus-task strong { display: block; margin-bottom: 4px; color: var(--text); }

.timer {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / .62;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--timer-bg), var(--control);
  text-align: center;
}

.timer strong { display: block; font-size: clamp(2.7rem, 9vw, 5rem); line-height: 1; }
.timer span { display: block; margin-top: 8px; color: var(--muted); font-weight: 700; }

.pomodoro-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pomodoro-actions .primary,
.pomodoro-actions .secondary {
  width: 100%;
}

.analytics { margin-top: 18px; }
.analytics-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0 18px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
}

.stat strong { display: block; font-size: 1.55rem; }
.stat span { color: var(--muted); font-size: .9rem; }

.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr);
  gap: 14px;
}

.report-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--control);
  padding: 14px;
}

.report-card h3 { margin-bottom: 12px; font-size: .98rem; }

.report-bars {
  display: grid;
  grid-template-columns: repeat(var(--columns, 7), minmax(36px, 1fr));
  align-items: end;
  gap: 8px;
  min-height: 188px;
  overflow-x: auto;
}

.report-bar {
  display: grid;
  align-items: end;
  gap: 8px;
  height: 170px;
  min-width: 36px;
  color: var(--muted);
  font-size: .78rem;
  text-align: center;
}

.report-bar i {
  display: block;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--green), var(--blue));
}

.report-list { display: grid; gap: 10px; }
.report-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: .9rem;
}

.report-track { height: 9px; overflow: hidden; border-radius: 999px; background: var(--panel-2); }
.report-fill { display: block; width: var(--value, 0%); height: 100%; background: var(--blue); }

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(236, 91, 86, .1);
  color: var(--red);
  font-weight: 800;
}

@media (max-width: 900px) {
  .hero, .report-layout { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .analytics-head { align-items: flex-start; flex-direction: column; }
  .report-actions { width: 100%; }
}

@media (max-width: 560px) {
  .app { width: min(100% - 20px, 1180px); padding-top: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions, .report-actions, .report-tabs, .filters { width: 100%; }
  .filter, .report-tab, .top-actions .secondary, .theme-toggle { flex: 1; min-width: 0; }
  .toolbar {
    flex-wrap: wrap;
  }
  .toolbar .field,
  .toolbar .select,
  .toolbar .primary {
    flex: 1 1 100%;
    width: 100%;
  }
  .stats { grid-template-columns: 1fr; }
  .task {
    grid-template-columns: 28px 1fr;
    align-items: start;
  }
  .task-actions {
    grid-column: 2;
    justify-content: flex-start;
    margin-top: 4px;
  }
  .login-card { padding: 24px; }
  .login-brand { grid-template-columns: 1fr; }
}
