:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef2f6;
  --text: #151923;
  --muted: #636b78;
  --line: #dce2ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --shadow: 0 16px 42px rgba(30, 41, 59, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
}

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

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-size: 0.84rem;
  font-weight: 850;
}

.country-chip {
  display: inline-grid;
  gap: 1px;
  min-height: 38px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.country-chip span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.country-chip strong {
  font-size: 0.92rem;
  line-height: 1.1;
}

.login-popover {
  position: relative;
}

.login-popover summary {
  list-style: none;
}

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

.login-form {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 10;
  display: grid;
  width: min(280px, calc(100vw - 32px));
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #2f3643;
  font-size: 0.9rem;
  font-weight: 750;
}

.login-form input {
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid #c9d2de;
  border-radius: var(--radius);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.nav-link {
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 650;
}

.nav-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.main {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 48px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.page-copy {
  max-width: 640px;
  margin: 10px 0 0;
  color: var(--muted);
}

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

.report-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.4fr) minmax(0, 0.6fr);
  gap: 14px;
  margin-bottom: 24px;
}

.summary-card,
.task-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-card {
  padding: 14px;
}

.progress-panel {
  display: grid;
  align-content: space-between;
  gap: 20px;
}

.summary-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.summary-value {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 850;
}

.console-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.console-sidebar {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 12px;
}

.workspace-panel,
.sidebar-section,
.task-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace-panel,
.sidebar-section {
  padding: 16px;
}

.workspace-panel h1 {
  font-size: 1.65rem;
}

.workspace-panel p:not(.eyebrow) {
  margin: 8px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.workspace-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.workspace-actions .button {
  flex: 1;
}

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

.console-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.console-header h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.task-panel {
  padding: 14px;
}

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

.list-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.list-toolbar h2 {
  margin: 0;
  font-size: 1.25rem;
}

.list-count {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.page-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 750;
}

.page-size-control select {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid #c9d2de;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 750;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title-row h2 {
  margin: 0;
  font-size: 1rem;
}

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

.module-row {
  display: grid;
  width: 100%;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.module-row:hover,
.module-row.is-active {
  border-color: var(--primary);
  background: #f5f8ff;
}

.module-row.is-active {
  box-shadow: inset 4px 0 0 var(--primary);
}

.module-row-head,
.module-status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.module-row-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.module-status-strip {
  justify-content: flex-start;
}

.mini-count,
.module-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.mini-not-done,
.module-tag {
  background: #eef2f7;
  color: #334155;
}

.mini-in-progress {
  background: #fff7da;
  color: #92400e;
}

.mini-completed {
  background: #e5f9ed;
  color: #166534;
}

.progress-track {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebf2;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.progress-track-small {
  height: 8px;
}

.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: 14px;
  box-shadow: none;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.task-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.86rem;
  font-weight: 850;
}

.task-card:hover {
  border-color: #b9c7dc;
  box-shadow: 0 12px 32px rgba(30, 41, 59, 0.09);
  transform: translateY(-1px);
}

.task-title {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.25;
}

.task-description {
  display: -webkit-box;
  max-width: 720px;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.task-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 850;
  white-space: nowrap;
}

.priority-icon {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.priority-low {
  background: #eef2ff;
  color: #3730a3;
}

.priority-low .priority-icon {
  background: #818cf8;
}

.priority-medium {
  background: #ecfeff;
  color: #155e75;
}

.priority-medium .priority-icon {
  background: #06b6d4;
}

.priority-high {
  background: #fff7ed;
  color: #9a3412;
}

.priority-high .priority-icon {
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 9px solid #f97316;
  border-left: 5px solid transparent;
  border-radius: 0;
  background: transparent;
}

.priority-critical {
  background: #fef2f2;
  color: #991b1b;
}

.priority-critical .priority-icon {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #dc2626;
  transform: rotate(45deg);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-not-done {
  background: #f1f5f9;
  color: #334155;
}

.badge-in-progress {
  background: #fef3c7;
  color: #92400e;
}

.badge-completed {
  background: #dcfce7;
  color: #166534;
}

.empty-state {
  padding: 34px;
  border: 1px dashed #bdc7d5;
  border-radius: var(--radius);
  background: #fff;
  text-align: center;
}

.empty-state p {
  margin: 8px auto 18px;
  max-width: 460px;
  color: var(--muted);
}

.country-gate {
  display: grid;
  gap: 22px;
  width: min(620px, 100%);
  margin: clamp(38px, 8vh, 92px) auto 0;
  padding: clamp(24px, 5vw, 34px);
}

.country-gate-head {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.country-gate-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
}

.country-gate h1 {
  font-size: clamp(2rem, 6vw, 2.8rem);
}

.country-gate .page-copy {
  max-width: 430px;
  margin-top: 2px;
  font-size: 1rem;
}

.country-form {
  display: grid;
  gap: 16px;
}

.country-form .button {
  width: 100%;
  min-height: 48px;
  margin-top: 2px;
}

.panel {
  padding: clamp(18px, 4vw, 28px);
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: clamp(18px, 3vw, 26px);
  border-left: 4px solid var(--primary);
}

.detail-hero-main {
  display: grid;
  gap: 10px;
}

.detail-hero-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.detail-hero h1 {
  max-width: 920px;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
}

.detail-hero p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-hero-actions {
  flex: 0 0 auto;
}

.task-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.42fr);
  gap: 16px;
  align-items: start;
}

.detail-stack {
  display: grid;
  gap: 14px;
}

.detail-description-card,
.detail-meta-card,
.comments-card,
.edit-panel {
  box-shadow: var(--shadow);
}

.detail-description-card .section-title-row {
  margin-bottom: 8px;
}

.detail-description-card h2,
.edit-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-metric {
  display: grid;
  gap: 6px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.detail-metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.detail-metric strong {
  align-self: end;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 750;
  overflow-wrap: anywhere;
}

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

.comment-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.comment-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 850;
}

.comment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.comment-head strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.comment-item p {
  margin: 6px 0 0;
  color: #2d3440;
}

.comment-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.comment-form textarea {
  min-height: 96px;
  padding: 12px;
  border: 1px solid #c9d2de;
  border-radius: var(--radius);
  resize: vertical;
}

.detail-row {
  display: grid;
  gap: 4px;
}

.detail-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-value {
  margin: 0;
  overflow-wrap: anywhere;
}

.form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: #2f3643;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #c9d2de;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

.field input,
.field select {
  min-height: 46px;
  padding: 0 12px;
}

.field textarea {
  min-height: 140px;
  padding: 12px;
  resize: vertical;
}

.field select:disabled {
  background: #edf1f5;
  color: #7b8492;
  cursor: not-allowed;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
  outline: none;
}

.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.editor-shell {
  overflow: hidden;
  border: 1px solid #c9d2de;
  border-radius: var(--radius);
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid #c9d2de;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
}

.tool-button:hover {
  border-color: #aebacd;
  background: var(--surface-muted);
}

.rich-editor {
  min-height: 168px;
  padding: 14px;
  outline: none;
  overflow-wrap: anywhere;
}

.rich-editor:focus {
  box-shadow: inset 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.rich-editor.is-invalid {
  box-shadow: inset 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.rich-editor:empty::before {
  content: "Write the task description...";
  color: #8a94a3;
}

.rich-output {
  display: grid;
  gap: 12px;
  max-width: 860px;
  overflow-wrap: anywhere;
  color: #242a35;
  font-size: 1rem;
}

.rich-output p,
.rich-output ul,
.rich-output ol,
.rich-editor p,
.rich-editor ul,
.rich-editor ol {
  margin-top: 0;
  margin-bottom: 10px;
}

.rich-output ul,
.rich-output ol {
  padding-left: 22px;
}

.rich-output li {
  margin-bottom: 6px;
}

.rich-output img,
.rich-editor img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

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

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

.button-small {
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.9rem;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.button-secondary:hover {
  border-color: #b8c3d1;
  background: var(--surface-muted);
}

.button-danger {
  background: var(--danger);
  color: #fff;
}

.button-danger:hover {
  background: var(--danger-dark);
}

.not-found {
  display: grid;
  gap: 14px;
  justify-items: start;
}

@media (max-width: 820px) {
  .summary-grid,
  .report-grid,
  .task-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-grid,
  .task-detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-hero {
    display: grid;
  }

  .console-shell {
    grid-template-columns: 1fr;
  }

  .console-sidebar {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar,
  .page-head,
  .task-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

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

  .admin-controls {
    width: 100%;
  }

  .admin-controls .button,
  .login-popover,
  .country-chip {
    width: 100%;
  }

  .login-form {
    position: static;
    width: 100%;
    margin-top: 10px;
  }

  .nav-link,
  .nav-actions .button {
    flex: 1;
  }

  .page-head {
    display: grid;
  }

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

  .country-form {
    grid-template-columns: 1fr;
  }

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

  .task-card .badge {
    width: max-content;
  }

  .console-header {
    display: grid;
  }

  .workspace-actions {
    flex-direction: column;
  }

  .task-side {
    justify-items: start;
    grid-column: 1 / -1;
  }

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

  .button-row,
  .button-row .button {
    width: 100%;
  }

  .list-toolbar,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .page-size-control {
    justify-content: space-between;
  }
}
