:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --border: #d7e2ee;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #0b3a67;
  --primary-soft: rgba(11, 58, 103, 0.12);
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.1), 0 6px 16px rgba(15, 23, 42, 0.06);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", "Noto Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 900px at 85% -15%, rgba(11, 58, 103, 0.14), transparent 55%),
    radial-gradient(900px 500px at 10% 0%, rgba(30, 64, 175, 0.08), transparent 58%),
    linear-gradient(180deg, #edf2f7 0%, #f7f8fb 100%);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 160px;
  display: block;
  margin-bottom: 10px;
}

.auth-card h1 {
  margin: 0;
  font-size: 28px;
  color: #0f172a;
}

.auth-card p {
  margin: 8px 0 16px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label,
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form span,
.form-grid span {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

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

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  color: #0f172a;
}

textarea {
  resize: vertical;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #0b3a67 0%, #124c89 55%, #1c63b0 100%);
}

.btn-ghost {
  color: #0f172a;
  background: #f8fafc;
  border-color: var(--border);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

.btn-sidebar {
  width: 100%;
  height: 38px;
}

.hint {
  font-size: 12px;
  margin: 2px 0 0;
}

.error-text {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
  font-weight: 600;
}

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

.sidebar {
  width: 260px;
  padding: 22px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.26);
  background: linear-gradient(180deg, #edf2f7 0%, #7998bb 58%, #1b4f7a 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-logo {
  width: 160px;
  max-width: 100%;
}

.sidebar-user {
  margin-top: 10px;
  display: grid;
  gap: 2px;
}

.sidebar-user strong {
  color: #f8fafc;
  font-size: 14px;
}

.sidebar-user span {
  color: rgba(248, 250, 252, 0.82);
  font-size: 12px;
}

.sidebar-menu {
  display: grid;
  gap: 8px;
}

.menu-item {
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  color: #e2ebf6;
  background: rgba(15, 23, 42, 0.22);
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
}

.menu-item.is-active {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.module-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.module-view[hidden] {
  display: none !important;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
}

.flow-step-group {
  display: grid;
  gap: 14px;
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.flow-step-pill {
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.flow-step-pill.is-active {
  border-color: #1c63b0;
  background: #e9f3ff;
  color: #0b3a67;
}

.flow-step-pill.is-done {
  border-color: #86efac;
  background: #ecfdf3;
  color: #14532d;
}

.flow-step-pill.is-locked {
  opacity: 0.6;
}

.flow-step-pill.is-optional {
  border-style: dashed;
}

.step-actions-card .muted-text {
  margin-top: 0;
}

.step-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(24px, 2.8vw, 32px);
  color: #0f172a;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.metric-card {
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(160deg, #f8fbff 0%, #eef5ff 100%);
}

.metric-card span {
  display: block;
  font-size: 12px;
  color: #475569;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

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

.card-title-row h2 {
  margin: 0;
  font-size: 18px;
  color: #0f172a;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.col-span-2 {
  grid-column: span 2;
}

.form-actions-row {
  display: flex;
  align-items: end;
  gap: 8px;
}

.geo-grid {
  margin-bottom: 10px;
}

.map-box {
  width: 100%;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #e2e8f0;
}

.muted-text {
  color: var(--muted);
  margin: 8px 0 0;
}

.muted-text[data-kind="warning"] {
  color: #9a3412;
  font-weight: 600;
}

.muted-text[data-kind="error"] {
  color: var(--danger);
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 13px;
  white-space: normal;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

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

.badge-finalized {
  color: #065f46;
  background: #dcfce7;
}

.checklist-container {
  display: grid;
  gap: 10px;
}

.checklist-block {
  border: 1px solid #dbe4ef;
  border-radius: 14px;
  overflow: hidden;
}

.checklist-block h3 {
  margin: 0;
  padding: 10px 12px;
  font-size: 15px;
  color: #0f172a;
  background: #eef4fb;
}

.checklist-progress-note {
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  color: #475569;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.checklist-item {
  padding: 12px;
  border-top: 1px solid #e2e8f0;
  display: grid;
  gap: 9px;
}

.checklist-item:first-of-type {
  border-top: none;
}

.checklist-item-single {
  border-top: none;
}

.question-title {
  font-weight: 700;
  color: #0f172a;
  line-height: 1.4;
}

.question-meta {
  color: #64748b;
  font-size: 12px;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #dbe4ef;
  border-radius: 999px;
  min-height: 38px;
  min-width: 74px;
  padding: 6px 12px;
  background: #f8fafc;
  font-weight: 600;
}

.status-pill input {
  width: 16px;
  height: 16px;
}

.question-nav {
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.question-nav .btn {
  min-width: 108px;
  height: 38px;
}

.question-nav-progress {
  text-align: center;
  font-size: 12px;
  color: #334155;
  font-weight: 700;
}

.photo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.photo-card {
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.photo-card img {
  display: block;
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.photo-card small {
  display: block;
  padding: 6px;
  color: #475569;
  font-size: 11px;
}

.score-preview {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 10px;
}

.score-pill {
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  background: #f8fafc;
}

.score-pill span {
  display: block;
  font-size: 12px;
  color: #475569;
}

.score-pill strong {
  display: block;
  font-size: 16px;
  margin-top: 4px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
  font-weight: 600;
}

.simple-table {
  overflow-x: auto;
  margin-top: 10px;
}

.simple-table table {
  min-width: 620px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-actions .btn {
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.status-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.status-draft {
  background: #ffedd5;
  color: #9a3412;
}

.status-finalized {
  background: #dcfce7;
  color: #065f46;
}

.warning-text {
  color: #b45309;
  font-weight: 700;
  font-size: 12px;
}

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

  .score-preview {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 980px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 14px 12px;
    gap: 10px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  }

  .sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .sidebar-logo {
    width: 128px;
  }

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

  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .col-span-2 {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 12px;
  }

  .card {
    padding: 12px;
  }

  .page-header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions .btn {
    flex: 1;
    min-width: 120px;
    height: 38px;
  }

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

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

  .map-box {
    height: 250px;
  }

  .menu-item {
    text-align: center;
    min-height: 34px;
    padding: 7px 8px;
  }

  .btn-sidebar {
    height: 34px;
  }

  .status-group {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-pill {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
  }

  .photo-row {
    grid-template-columns: 1fr;
  }

  .photo-row .answer-photo-input {
    width: 100%;
  }

  .question-nav {
    flex-wrap: wrap;
  }

  .question-nav .btn {
    flex: 1 1 calc(50% - 4px);
  }

  .question-nav-progress {
    width: 100%;
    order: 3;
  }

  .flow-steps {
    grid-template-columns: 1fr;
  }

  .step-actions .btn {
    flex: 1 1 100%;
  }
}
