:root {
  --bg: #f7f9fb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #0b4f93;
  --blue-strong: #064784;
  --blue-soft: #eaf4ff;
  --green: #059669;
  --green-soft: #e8fbf2;
  --orange: #c05621;
  --orange-soft: #fff4e8;
  --purple: #7c3aed;
  --purple-soft: #f4edff;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 30px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

button:hover { background: var(--blue-strong); }
button:disabled { opacity: .5; cursor: not-allowed; }

.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ghost:hover { background: #f9fafb; }
.danger { color: var(--danger); }
.danger:hover { background: #fff1f2; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8fb 100%);
}

.login-wrap {
  width: min(100%, 640px);
  text-align: center;
}

.login-title h1 {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 800;
}

.login-title p {
  margin: 0;
  color: var(--muted);
}

.login-subtitle {
  font-size: clamp(1.18rem, 3vw, 1.25rem);
  line-height: 1.18;
  font-weight: 400;
  white-space: nowrap;
}

.login-agency {
  font-size: .83rem;
  line-height: 1.4;
  font-weight: 400;
  margin-top: 6px !important;
  margin-bottom: 26px !important;
}

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

.login-card {
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
  padding: 28px 26px 24px;
  text-align: left;
}

.login-card h2 {
  text-align: center;
  margin: 0 0 8px;
  font-size: 1.45rem;
}

.login-card .lead {
  text-align: center;
  margin: 0 0 24px;
  color: var(--muted);
}

.login-foot {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
}

.copyright {
  margin-top: 22px;
  color: var(--muted);
  font-size: .9rem;
}

.app-topbar {
  min-height: 58px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .16);
}

.app-brand strong {
  display: block;
  font-size: .98rem;
  line-height: 1.2;
}

.app-brand span {
  display: block;
  font-size: .86rem;
  opacity: .9;
}

.logout-icon {
  width: 38px;
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: none;
}

.logout-icon:hover { background: rgba(255, 255, 255, .12); }

.page {
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 26px 28px 58px;
}

.page.narrow { width: min(100%, 760px); }

.page-heading {
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0 0 6px;
  font-size: 1.55rem;
  line-height: 1.25;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card {
  min-height: 92px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card.wide { grid-column: 1 / -1; }

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.stat-icon.blue { background: var(--blue-soft); color: var(--blue); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.orange { background: var(--orange-soft); color: var(--orange); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }

.stat-number {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: .95rem;
}

.cta-card {
  padding: 24px;
  margin-bottom: 24px;
}

.cta-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.cta-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.wide-button {
  width: 100%;
}

.history-card, .filters-card, .form-card {
  padding: 0;
  overflow: hidden;
}

.card-title {
  padding: 22px 24px 14px;
  font-weight: 800;
}

.history-list, .submission-list {
  display: grid;
}

.history-item, .submission-item {
  display: grid;
  gap: 7px;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
}

.history-top, .submission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-title, .submission-title {
  font-weight: 700;
}

.history-meta, .submission-meta {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill.family { background: var(--blue-soft); color: var(--blue); }
.pill.business { background: var(--orange-soft); color: var(--orange); }

.time {
  color: var(--muted);
  font-size: .88rem;
  white-space: nowrap;
}

.empty {
  padding: 24px;
  color: var(--muted);
}

.form-progress {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bg);
  padding: 12px 28px 8px;
  margin: -26px -28px 24px;
  border-bottom: 1px solid var(--line);
}

.step-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.step {
  border-radius: 999px;
  min-height: 34px;
  padding: 7px 14px;
  color: var(--muted);
  background: #f3f4f6;
  border: 1px solid var(--line);
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
}

.step.active {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b8ecd4;
}

.step.done {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #cfe7ff;
}

.bar {
  height: 5px;
  border-radius: 999px;
  background: #edf1f5;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--progress);
  background: var(--blue);
}

.form-card h2 {
  margin: 0;
  padding: 22px 24px 4px;
  font-size: 1.2rem;
}

.form-card .form-desc {
  margin: 0;
  padding: 0 24px 20px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.form-body {
  padding: 24px;
}

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

.full { grid-column: 1 / -1; }

label, .field-label {
  display: grid;
  gap: 8px;
  font-weight: 650;
  color: #233044;
}

.required-star {
  color: var(--danger);
  margin-left: 3px;
  white-space: nowrap;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

input[disabled], select[disabled] {
  background: #f8fafc;
  color: #6b7280;
}

textarea {
  min-height: 128px;
  resize: vertical;
}

.hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 400;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.radio-row {
  display: grid;
  gap: 12px;
}

.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  font-weight: 700;
}

.choice input { width: 18px; min-height: 18px; }
.choice span { display: block; }
.choice small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.notice, .success {
  border-radius: 8px;
  padding: 13px 14px;
  margin-bottom: 16px;
}

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
}

.success {
  background: var(--green-soft);
  border: 1px solid #b8ecd4;
  color: #065f46;
}

.subblock {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 22px;
}

.subblock:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.subblock h3 {
  margin: 0 0 16px;
  font-size: 1.05rem;
}

.usaha-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.usaha-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfdff;
}

.usaha-card.collapsed {
  background: #fff;
}

.usaha-card.collapsed .grid,
.usaha-card.collapsed .business-actions {
  display: none;
}

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

.row-title h4 { margin: 0; }

.business-title {
  display: grid;
  gap: 3px;
}

.business-name {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 500;
}

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

.icon-button {
  width: 42px;
  min-height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}

.business-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.admin-tools {
  padding: 20px;
  margin-bottom: 24px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.table-wrap {
  overflow: auto;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #334155;
  font-size: .86rem;
}

.admin-add {
  margin-top: 24px;
  padding: 22px;
}

.small {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.45;
}

.hidden { display: none !important; }

@media (max-width: 780px) {
  .app-topbar { padding: 10px 16px; }
  .page { padding: 24px 16px 50px; }
  .form-progress { margin: -24px -16px 22px; padding: 12px 16px 8px; }
  .stats-grid, .stats-grid.admin, .grid, .filters { grid-template-columns: 1fr; }
  .history-top, .submission-top { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .login-title h1 { font-size: 2.25rem; }
  .login-subtitle { font-size: 1.12rem; }
  .login-agency { font-size: .75rem; }
}
