:root,
html[data-theme="light"] {
  color-scheme: light;
  --page: #f5f7fb;
  --page-soft: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --text: #172033;
  --heading: #0d2740;
  --muted: #667085;
  --border: #dce3eb;
  --border-strong: #c8d2de;
  --primary: #f36b21;
  --primary-hover: #d95712;
  --primary-soft: #fff0e7;
  --navy: #0f334d;
  --navy-soft: #e9f0f5;
  --danger: #c83f49;
  --danger-soft: #fff0f1;
  --success: #198754;
  --success-soft: #e9f8f0;
  --warning: #b76a00;
  --warning-soft: #fff5df;
  --shadow: 0 14px 34px rgba(27, 46, 74, 0.09);
  --shadow-soft: 0 7px 20px rgba(27, 46, 74, 0.07);
  --focus: 0 0 0 4px rgba(243, 107, 33, 0.18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d141d;
  --page-soft: #111b27;
  --surface: #172230;
  --surface-2: #1c2938;
  --surface-3: #223244;
  --text: #e9edf3;
  --heading: #ffffff;
  --muted: #aeb8c6;
  --border: #304254;
  --border-strong: #40566b;
  --primary: #ff7f32;
  --primary-hover: #ff9357;
  --primary-soft: #382217;
  --navy: #72b7e4;
  --navy-soft: #1a3447;
  --danger: #ff7c84;
  --danger-soft: #3a2026;
  --success: #57d89a;
  --success-soft: #17372a;
  --warning: #ffbd56;
  --warning-soft: #3b2f18;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.24);
  --focus: 0 0 0 4px rgba(255, 127, 50, 0.22);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --page: #0d141d;
    --page-soft: #111b27;
    --surface: #172230;
    --surface-2: #1c2938;
    --surface-3: #223244;
    --text: #e9edf3;
    --heading: #ffffff;
    --muted: #aeb8c6;
    --border: #304254;
    --border-strong: #40566b;
    --primary: #ff7f32;
    --primary-hover: #ff9357;
    --primary-soft: #382217;
    --navy: #72b7e4;
    --navy-soft: #1a3447;
    --danger: #ff7c84;
    --danger-soft: #3a2026;
    --success: #57d89a;
    --success-soft: #17372a;
    --warning: #ffbd56;
    --warning-soft: #3b2f18;
    --shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.24);
    --focus: 0 0 0 4px rgba(255, 127, 50, 0.22);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 4%, rgba(243, 107, 33, 0.08), transparent 24rem),
    radial-gradient(circle at 88% 0%, rgba(15, 51, 77, 0.08), transparent 28rem),
    var(--page);
  font-family: Tahoma, Arial, "Helvetica Neue", sans-serif;
  line-height: 1.55;
}

html[dir="ltr"] body {
  font-family: Inter, Arial, "Helvetica Neue", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--heading);
  line-height: 1.25;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3vw, 40px);
}

h2 {
  margin-bottom: 8px;
  font-size: 21px;
}

h3 {
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 15px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 13px;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
  outline: none;
  box-shadow: var(--focus);
}

textarea {
  resize: vertical;
}

input[type="color"] {
  width: 64px;
  height: 46px;
  padding: 5px;
  cursor: pointer;
}

button,
.primary,
.secondary,
.danger,
.ghost,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 15px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

button:hover,
.button-link:hover {
  transform: translateY(-1px);
}

button:active,
.button-link:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.secondary {
  background: var(--surface-2);
  color: var(--heading);
  border-color: var(--border);
}

.secondary:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 36%, var(--border));
}

.danger:hover {
  background: color-mix(in srgb, var(--danger-soft) 72%, var(--danger));
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.ghost:hover {
  color: var(--heading);
  background: var(--surface-2);
}

.compact {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 13px;
}

.wide {
  width: 100%;
}

.alert {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 14px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.alert.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 35%, var(--border));
}

.alert.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

/* Login and installation */
.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(100%, 460px);
}

.login-card {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
  padding: 30px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.login-card .logo {
  display: block;
  width: 150px;
  max-width: 54%;
  height: auto;
  margin: 8px auto 18px;
  border-radius: 16px;
}

.login-card h1 {
  font-size: 26px;
}

.login-card > .muted {
  margin-bottom: 23px;
}

.login-card form {
  text-align: start;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-inline-end: 86px;
}

.icon-button {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 6px 10px;
  transform: translateY(-50%);
  font-size: 12px;
}

.icon-button:hover {
  background: var(--primary-soft);
  transform: translateY(-50%);
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  padding: 4px;
}

.login-card > .language-switcher {
  margin-bottom: 8px;
}

.language-link {
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.language-link.active {
  background: var(--navy);
  color: var(--surface);
}

/* App shell */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 78px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: 0 5px 22px rgba(18, 35, 57, 0.05);
  padding: 9px clamp(18px, 4vw, 50px);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand img {
  width: 58px;
  height: 48px;
  border-radius: 11px;
  object-fit: cover;
  flex: 0 0 auto;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  color: var(--heading);
  font-size: 15px;
  white-space: nowrap;
}

.brand-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-navigation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.nav-link {
  position: relative;
  border-radius: 10px;
  color: var(--muted);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--heading);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-link.active::after {
  position: absolute;
  inset-inline: 16px;
  bottom: 3px;
  height: 2px;
  border-radius: 999px;
  background: var(--primary);
  content: "";
}

.logout-form {
  margin: 0;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 10px;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--heading);
}

.container {
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}

.app-main {
  padding-block: 34px 60px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-heading p:last-child {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--muted);
}

.add-button {
  min-width: 150px;
  box-shadow: 0 9px 20px rgba(243, 107, 33, 0.24);
}

.panel,
.stats article {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel {
  padding: 22px;
}

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

.panel-head.simple {
  align-items: flex-start;
}

.panel-head h2,
.panel-head p {
  margin-bottom: 0;
}

.panel-head p {
  margin-top: 5px;
}

.grid {
  display: grid;
  gap: 20px;
}

.stats {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.stats-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats article {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 6px;
  min-height: 105px;
  padding: 18px;
}

.stats article::before {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--primary);
  content: "";
}

.stats article:nth-child(2)::before {
  background: var(--warning);
}

.stats article:nth-child(3)::before {
  background: var(--success);
}

.stats article:nth-child(4)::before {
  background: var(--danger);
}

.stats span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stats strong {
  color: var(--heading);
  font-size: 30px;
  line-height: 1.15;
}

.compact-stats {
  max-width: 540px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

/* Tasks */
.tasks-panel {
  margin-top: 2px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.filter {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 12px;
}

.filter.active {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--surface);
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--border);
  border-inline-start: 5px solid var(--primary);
  border-radius: 15px;
  background: var(--surface-2);
  padding: 16px;
  transition: border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.task-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.task-card.late {
  border-inline-start-color: var(--danger);
}

.task-card.done {
  border-inline-start-color: var(--success);
  opacity: 0.72;
}

.task-card.done h3 {
  text-decoration: line-through;
}

.task-main {
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.task-title-row h3 {
  overflow-wrap: anywhere;
  margin-bottom: 0;
}

.task-main p {
  margin: 8px 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.task-main time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-main time.overdue,
.text-danger {
  color: var(--danger);
  font-weight: 800;
}

.badge {
  --badge-color: var(--primary);
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--badge-color);
  border-radius: 999px;
  background: color-mix(in srgb, var(--badge-color) 10%, var(--surface));
  color: var(--badge-color);
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.neutral {
  --badge-color: var(--muted);
}

.task-actions,
.category-actions,
.dialog-actions,
.filter-actions,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-actions {
  flex: 0 0 auto;
}

.task-actions form,
.category-actions form {
  margin: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 180px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

/* Dialog */
.app-dialog {
  width: min(620px, calc(100% - 24px));
  max-height: calc(100vh - 30px);
  border: 0;
  border-radius: 20px;
  background: transparent;
  padding: 0;
  color: var(--text);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(7, 17, 29, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-card {
  overflow: auto;
  max-height: calc(100vh - 30px);
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.dialog-head h2,
.dialog-head p {
  margin-bottom: 0;
}

.dialog-close {
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0;
  font-size: 24px;
  font-weight: 500;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

/* Categories */
.category-layout {
  grid-template-columns: minmax(280px, 0.78fr) minmax(0, 1.45fr);
  align-items: start;
}

.sticky-panel {
  position: sticky;
  top: 98px;
}

.color-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 6px 10px;
}

.color-field input {
  border: 0;
  background: transparent;
  padding: 2px;
}

.color-field span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.category-admin-list {
  display: grid;
  gap: 11px;
}

.category-admin-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 13px;
}

.category-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.category-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.category-identity > span:last-child {
  display: grid;
  min-width: 0;
}

.category-identity strong {
  overflow-wrap: anywhere;
  color: var(--heading);
}

.category-identity small {
  color: var(--muted);
}

.category-color-block {
  width: 42px;
  height: 42px;
  border: 4px solid color-mix(in srgb, var(--surface) 85%, transparent);
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--border);
  flex: 0 0 auto;
}

.category-edit-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px auto auto;
  align-items: center;
  gap: 8px;
}

.category-edit-form input[type="color"] {
  height: 43px;
}

/* Reports */
.report-filter-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 13px;
}

.report-filter-form .field-wide {
  grid-column: span 2;
}

.filter-actions {
  justify-content: flex-end;
}

.report-stats {
  margin-top: 20px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.report-table th,
.report-table td {
  border-bottom: 1px solid var(--border);
  padding: 13px 14px;
  text-align: start;
  vertical-align: middle;
}

.report-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.report-table td {
  background: var(--surface);
  font-size: 13px;
}

.report-table tr:last-child td {
  border-bottom: 0;
}

.report-table td:first-child {
  min-width: 220px;
}

.report-table td:first-child strong,
.report-table td:first-child small {
  display: block;
}

.report-table td:first-child small {
  margin-top: 4px;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.completed {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-pill.overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Settings */
.settings-grid {
  display: grid;
  gap: 20px;
}

.settings-panel {
  display: grid;
  gap: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.choice-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 94px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface-2);
  padding: 15px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.choice-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.choice-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-mark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  flex: 0 0 auto;
}

.choice-card:has(input:checked) .choice-mark {
  border: 6px solid var(--primary);
}

.choice-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.choice-copy strong {
  color: var(--heading);
}

.choice-copy small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.theme-choice {
  align-items: flex-start;
  min-height: 128px;
}

.theme-swatch {
  width: 42px;
  height: 42px;
  border: 1px solid #bfc7d1;
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
}

.theme-swatch.light {
  background: #ffffff;
  box-shadow: inset 0 -12px 0 #edf1f5;
}

.theme-swatch.dark {
  border-color: #44556a;
  background: #172230;
  box-shadow: inset 0 -12px 0 #26384b;
}

.theme-swatch.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.theme-swatch.split i:first-child {
  background: #ffffff;
}

.theme-swatch.split i:last-child {
  background: #172230;
}

.settings-actions {
  justify-content: flex-end;
}

.settings-actions .primary {
  min-width: 170px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
  }

  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
  }

  .top-navigation {
    position: absolute;
    inset-inline: 18px;
    top: calc(100% + 8px);
    display: none;
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .top-navigation.open {
    display: flex;
  }

  .nav-link {
    text-align: start;
  }

  .nav-link.active::after {
    inset-block: 10px;
    inset-inline-start: 4px;
    inset-inline-end: auto;
    width: 3px;
    height: auto;
  }

  .category-layout {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
  }

  .report-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-filter-form .field-wide {
    grid-column: span 2;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 68px;
    gap: 9px;
    padding-inline: 12px;
  }

  .brand img {
    width: 48px;
    height: 40px;
  }

  .brand-copy small {
    display: none;
  }

  .logout-form .secondary {
    padding-inline: 9px;
  }

  .container {
    width: min(100% - 22px, 1180px);
  }

  .app-main {
    padding-block: 24px 44px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }

  .add-button {
    align-self: flex-start;
  }

  .stats-four,
  .stats-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel {
    padding: 17px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .task-card {
    align-items: stretch;
    flex-direction: column;
  }

  .task-actions {
    width: 100%;
  }

  .task-actions form,
  .task-actions button {
    flex: 1;
    width: 100%;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .theme-choice {
    min-height: 100px;
  }

  .category-display {
    align-items: stretch;
    flex-direction: column;
  }

  .category-actions {
    width: 100%;
  }

  .category-actions form,
  .category-actions button {
    flex: 1;
    width: 100%;
  }

  .category-edit-form {
    grid-template-columns: minmax(0, 1fr) 60px;
  }

  .category-edit-form button {
    width: 100%;
  }

  .report-table,
  .report-table tbody,
  .report-table tr,
  .report-table td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .report-table thead {
    display: none;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
  }

  .report-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    padding: 6px 12px;
  }

  .report-table td {
    display: grid;
    grid-template-columns: minmax(100px, 36%) 1fr;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 10px 0;
    text-align: end;
  }

  .report-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-align: start;
  }

  .report-table td:last-child {
    border-bottom: 0;
  }

  .report-table td:first-child {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .login-body {
    padding: 12px;
  }

  .login-card {
    border-radius: 20px;
    padding: 24px 17px;
  }

  .language-switcher {
    width: 100%;
  }

  .language-link {
    flex: 1;
    text-align: center;
  }

  .brand-copy strong {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .logout-form .secondary {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .stats article {
    min-height: 92px;
    padding: 14px;
  }

  .stats strong {
    font-size: 25px;
  }

  .form-row,
  .report-filter-form {
    grid-template-columns: 1fr;
  }

  .report-filter-form .field-wide {
    grid-column: auto;
  }

  .filter-actions,
  .dialog-actions,
  .settings-actions {
    width: 100%;
  }

  .filter-actions > *,
  .dialog-actions > *,
  .settings-actions > * {
    flex: 1;
  }

  .dialog-card {
    padding: 18px;
  }
}

@media print {
  :root,
  html[data-theme] {
    color-scheme: light;
    --page: #ffffff;
    --surface: #ffffff;
    --surface-2: #ffffff;
    --text: #111111;
    --heading: #111111;
    --muted: #555555;
    --border: #cccccc;
    --border-strong: #aaaaaa;
    --shadow: none;
    --shadow-soft: none;
  }

  body {
    background: #ffffff;
  }

  .topbar,
  .no-print,
  .report-filter-panel,
  .alert {
    display: none !important;
  }

  .container {
    width: 100%;
  }

  .app-main {
    padding: 0;
  }

  .stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .panel,
  .stats article {
    box-shadow: none;
  }

  .report-table {
    min-width: 0;
  }
}

/* Task progress, subtasks, overdue alerts, and footer */
.task-card {
  align-items: flex-start;
}

.task-card.late {
  border-color: color-mix(in srgb, var(--danger) 46%, var(--border));
  background: color-mix(in srgb, var(--danger-soft) 72%, var(--surface));
  box-shadow: 0 8px 22px color-mix(in srgb, var(--danger) 12%, transparent);
}

.task-content {
  display: grid;
  flex: 1 1 auto;
  gap: 15px;
  min-width: 0;
}

.task-time-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.delay-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--border));
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 900;
}

.overdue-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: 16px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 15px 17px;
  box-shadow: var(--shadow-soft);
}

.overdue-notice strong {
  color: inherit;
  font-size: 16px;
}

.overdue-notice p {
  margin: 3px 0 0;
}

.task-progress {
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  padding: 11px 13px;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 12px;
}

.progress-copy strong {
  color: var(--heading);
  font-size: 13px;
}

.progress-copy span,
.progress-copy small {
  color: var(--muted);
  font-size: 12px;
}

.progress-track,
.report-progress {
  overflow: hidden;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: var(--surface-3);
}

.progress-track span,
.report-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.3s ease;
}

.subtask-manager {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}

.subtask-manager summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--heading);
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
}

.subtask-manager summary::-webkit-details-marker {
  display: none;
}

.subtask-manager summary::before {
  color: var(--primary);
  content: "＋";
  font-size: 16px;
}

.subtask-manager[open] summary::before {
  content: "−";
}

.summary-count {
  margin-inline-start: auto;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 2px 8px;
  font-size: 11px;
}

.subtask-body {
  border-top: 1px solid var(--border);
  padding: 12px;
}

.no-subtasks-message {
  margin-bottom: 10px;
  font-size: 13px;
}

.subtask-list {
  display: grid;
  gap: 8px;
}

.subtask-row {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  padding: 9px;
}

.subtask-row.done {
  opacity: 0.72;
}

.subtask-row.done .subtask-check span {
  text-decoration: line-through;
}

.subtask-display,
.subtask-edit-form,
.add-subtask-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtask-toggle-form {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.subtask-check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-weight: 700;
}

.subtask-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--success);
}

.subtask-check span {
  overflow-wrap: anywhere;
}

.subtask-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.subtask-actions form {
  margin: 0;
}

.subtask-edit-form input,
.add-subtask-form input {
  flex: 1 1 auto;
}

.add-subtask-form {
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed var(--border-strong);
}

.new-subtasks-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  padding: 13px;
}

.section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-label-row strong {
  color: var(--heading);
  font-size: 14px;
}

.new-subtask-fields {
  display: grid;
  gap: 8px;
}

.new-subtask-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.report-progress {
  min-width: 100px;
  margin-bottom: 5px;
  height: 7px;
}

.report-table td small {
  color: var(--muted);
}

.site-footer {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  border-top: 1px solid var(--border);
  color: var(--muted);
  padding: 18px 0 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.login-body {
  grid-template-rows: 1fr auto;
  gap: 18px;
}

.login-footer {
  align-self: end;
}

@media (max-width: 820px) {
  .task-card {
    display: grid;
  }

  .task-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .task-actions > *,
  .task-actions form,
  .task-actions button {
    flex: 1 1 130px;
  }

  .overdue-notice {
    align-items: stretch;
    flex-direction: column;
  }

  .overdue-notice button {
    align-self: flex-start;
  }
}

@media (max-width: 620px) {
  .subtask-display,
  .subtask-edit-form,
  .add-subtask-form,
  .section-label-row {
    align-items: stretch;
    flex-direction: column;
  }

  .subtask-actions {
    width: 100%;
  }

  .subtask-actions > *,
  .subtask-actions form,
  .subtask-actions button,
  .subtask-edit-form button,
  .add-subtask-form button {
    flex: 1;
  }

  .new-subtask-field {
    grid-template-columns: 1fr;
  }

  .progress-copy {
    align-items: flex-start;
    flex-direction: column;
  }
}

.app-body {
  display: flex;
  flex-direction: column;
}

.app-body .app-main {
  flex: 1 0 auto;
}

/* Automatic filters, collapsible task rows, and branded reports */
.task-filter-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  align-items: end;
  gap: 10px;
  min-width: min(100%, 410px);
}

.task-filter-form label {
  margin: 0;
}

.task-card.task-accordion {
  display: block;
  overflow: hidden;
  padding: 0;
}

.task-card.task-accordion:hover {
  transform: none;
}

.task-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(110px, 170px) auto;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 15px 16px;
  list-style: none;
  user-select: none;
}

.task-summary::-webkit-details-marker {
  display: none;
}

.task-card[open] > .task-summary {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary-soft) 42%, var(--surface-2));
}

.task-sequence {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--heading);
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.task-card.late .task-sequence {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.task-card.done .task-sequence {
  border-color: color-mix(in srgb, var(--success) 55%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.task-summary-main {
  min-width: 0;
}

.task-summary .task-title-row h3 {
  font-size: 16px;
}

.task-summary .task-time-row {
  margin-top: 7px;
}

.task-summary-progress {
  display: grid;
  gap: 7px;
}

.task-summary-progress strong {
  color: var(--heading);
  font-size: 13px;
  text-align: center;
}

.task-summary-progress .progress-track {
  height: 7px;
}

.task-chevron {
  width: 11px;
  height: 11px;
  border-inline-end: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

html[dir="rtl"] .task-chevron {
  transform: rotate(45deg);
}

.task-card[open] > .task-summary .task-chevron {
  transform: rotate(225deg);
}

.task-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  padding: 17px;
}

.task-details .task-actions {
  align-self: end;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 330px;
}

.report-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.report-brand img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.report-brand div {
  display: grid;
  gap: 4px;
}

.report-brand strong {
  color: var(--heading);
  font-size: 20px;
}

.report-brand span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.report-filter-form .filter-actions {
  align-self: end;
}

@media (max-width: 900px) {
  .task-list-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .task-filter-form {
    width: 100%;
  }

  .task-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .task-summary-progress {
    grid-column: 2 / 3;
    width: min(220px, 100%);
  }

  .task-chevron {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .task-details {
    grid-template-columns: 1fr;
  }

  .task-details .task-actions {
    max-width: none;
  }
}

@media (max-width: 620px) {
  .task-filter-form {
    grid-template-columns: 1fr;
  }

  .task-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 13px;
  }

  .task-sequence {
    width: 34px;
    height: 34px;
  }

  .task-summary-progress {
    grid-column: 1 / -1;
    width: 100%;
  }

  .task-chevron {
    grid-row: 1;
  }

  .task-summary .status-pill,
  .task-summary .delay-pill {
    white-space: normal;
  }

  .task-details {
    padding: 13px;
  }

  .report-brand img {
    width: 56px;
    height: 56px;
  }
}

@media print {
  .report-brand {
    break-inside: avoid;
    margin-bottom: 16px;
  }

  .report-brand img {
    width: 62px;
    height: 62px;
  }

  .report-brand strong {
    font-size: 18px;
  }
}

/* Archived tasks and reusable task templates */
.stats-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stats-five article:nth-child(5)::before {
  background: var(--navy);
}

.page-heading-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.task-filter-form.task-filter-form-wide {
  grid-template-columns: minmax(230px, 1.5fr) repeat(3, minmax(145px, 1fr)) auto;
  min-width: min(100%, 900px);
}

.task-search-field {
  min-width: 0;
}

.filter-reset-link {
  align-self: end;
  justify-content: center;
  min-height: 43px;
}

.task-card.archived {
  border-inline-start-color: var(--navy);
  background: color-mix(in srgb, var(--navy-soft) 42%, var(--surface-2));
}

.task-card.archived .task-sequence {
  border-color: color-mix(in srgb, var(--navy) 45%, var(--border));
  background: var(--navy-soft);
  color: var(--navy);
}

.task-card.archived .task-title-row h3 {
  color: var(--muted);
}

.status-pill.archived {
  background: var(--navy-soft);
  color: var(--navy);
}

.template-picker-inline,
.selected-template-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 13px 14px;
}

.template-picker-inline p {
  margin: 3px 0 0;
  font-size: 13px;
}

.selected-template-notice {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: var(--success-soft);
}

.selected-template-notice[hidden] {
  display: none;
}

.previous-tasks-dialog .dialog-card {
  width: min(720px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
}

.previous-task-list {
  display: grid;
  gap: 9px;
  overflow: auto;
  max-height: 480px;
  margin-top: 14px;
  padding-inline-end: 3px;
}

.previous-task-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 13px;
  text-align: start;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.previous-task-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.previous-task-option[hidden] {
  display: none;
}

.previous-task-option-main,
.previous-task-option-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.previous-task-option-main {
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.previous-task-option-main strong {
  color: var(--heading);
}

.previous-task-option-main small {
  color: var(--muted);
}

.previous-task-option-meta {
  justify-content: flex-end;
}

.select-template-label {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.previous-task-no-results[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .task-filter-form.task-filter-form-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: min(100%, 650px);
  }

  .task-search-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .stats-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-heading-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .stats-five,
  .task-filter-form.task-filter-form-wide {
    grid-template-columns: 1fr;
  }

  .task-search-field {
    grid-column: auto;
  }

  .page-heading-actions,
  .page-heading-actions > *,
  .template-picker-inline,
  .selected-template-notice,
  .previous-task-option {
    width: 100%;
  }

  .page-heading-actions,
  .template-picker-inline,
  .selected-template-notice,
  .previous-task-option {
    align-items: stretch;
    flex-direction: column;
  }

  .previous-task-option-meta {
    justify-content: flex-start;
  }
}

/* Task date, planned completion date, and actual completion reporting */
.task-date-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 4px 9px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.task-date-value strong {
  color: var(--heading);
}

.task-date-value.overdue {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.task-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.task-meta-grid span {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.report-filter-form-dates {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.report-table-dates {
  min-width: 1280px;
}

.report-table-dates td:nth-child(3),
.report-table-dates td:nth-child(4),
.report-table-dates td:nth-child(5),
.report-table-dates td:nth-child(9) {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.report-late-row {
  background: var(--danger-soft);
}

@media (max-width: 1100px) {
  .report-filter-form-dates {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-meta-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .report-filter-form-dates {
    grid-template-columns: 1fr;
  }

  .task-date-value {
    border-radius: 10px;
  }

  .report-table-dates {
    min-width: 0;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 10mm;
  }

  .report-table-dates {
    min-width: 0;
    font-size: 9px;
  }

  .report-table-dates th,
  .report-table-dates td {
    padding: 6px 7px;
    font-size: 9px;
  }
}
