:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1d2533;
  --muted: #657083;
  --line: #dfe5ee;
  --brand: #1677ff;
  --brand-dark: #0f5dcc;
  --soft: #eaf3ff;
  --green: #20a162;
  --orange: #d46b08;
  --red: #cf1322;
  --shadow: 0 16px 40px rgba(30, 48, 80, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #edf4ff 0%, var(--bg) 320px);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  transition: 0.18s ease;
}

button:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

button.secondary,
button.ghost {
  color: var(--brand);
  background: var(--soft);
}

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

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px min(5vw, 72px) 24px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 46px);
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-required .app-header,
.auth-required .tabs,
.auth-required main {
  display: none;
}

.auth-gate {
  padding: 40px min(5vw, 72px) 24px;
}

.auth-card {
  max-width: 720px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 10px;
}

.auth-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 8px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  padding: 12px 18px;
  border-radius: 12px;
  color: #fff;
  background: var(--brand);
  text-decoration: none;
  transition: 0.18s ease;
}

.button-link:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.secondary-link {
  color: var(--brand);
  background: var(--soft);
}

.secondary-link:hover {
  background: #dbeaff;
}

.auth-help {
  color: var(--muted);
  font-size: 15px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 min(5vw, 72px) 18px;
  overflow-x: auto;
}

.tab {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

main {
  padding: 0 min(5vw, 72px) 48px;
}

.panel {
  display: none;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  color: #315479;
  background: var(--soft);
  font-size: 14px;
}

.green-badge {
  color: var(--green);
  background: #f0fff7;
}

.orange-badge {
  color: var(--orange);
  background: #fff7e6;
}

.red-badge {
  color: var(--red);
  background: #fff1f0;
}

.is-user .admin-only {
  display: none !important;
}

.hidden {
  display: none !important;
}

small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-weight: 400;
}

code {
  word-break: break-all;
}

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

label,
fieldset,
.filters {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: 3px solid rgba(22, 119, 255, 0.16);
  border-color: var(--brand);
}

.wide,
.service-fieldset {
  grid-column: 1 / -1;
}

fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

legend {
  padding: 0 8px;
  color: var(--ink);
}

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

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 8px;
  color: var(--ink);
  background: #f8fafc;
  font-weight: 500;
}

.checkbox-grid input {
  width: auto;
  margin: 0;
}

.estimate-card {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  border: 1px solid #b7d7ff;
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #f6fbff, #ecf5ff);
}

.estimate-card h3 {
  margin-bottom: 6px;
  color: var(--brand);
  font-size: 34px;
}

.breakdown {
  display: grid;
  gap: 8px;
}

.breakdown-item,
.request-card,
.detail,
.metrics article,
.dashboard-grid article,
.notice {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.request-card h3 {
  margin-bottom: 8px;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  color: #315479;
  background: #f1f5f9;
  font-size: 13px;
}

.pill.red {
  color: var(--red);
  background: #fff1f0;
}

.pill.green {
  color: var(--green);
  background: #f0fff7;
}

.inline-filter {
  display: block;
  max-width: 360px;
  margin-bottom: 18px;
}

.filters {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: #4c596b;
  background: #f8fafc;
  font-size: 14px;
}

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

.detail {
  margin-top: 18px;
}

.detail.empty {
  color: var(--muted);
  background: #f8fafc;
}

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

.detail-grid div {
  border-radius: 12px;
  padding: 10px;
  background: #f8fafc;
}

.audit-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
}

.audit-list li {
  border-left: 3px solid var(--brand);
  padding: 8px 10px;
  background: #f8fbff;
}

.admin-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-controls .wide-control {
  grid-column: span 2;
}

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

.metrics article strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

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

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 42px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

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

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
}

.notice-list {
  display: grid;
  gap: 10px;
}

.notice strong {
  display: block;
  margin-bottom: 4px;
}

.formula {
  margin-bottom: 16px;
  border-radius: 16px;
  padding: 16px;
  background: #f8fafc;
}

dialog {
  border: 0;
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

@media (max-width: 980px) {
  .app-header,
  .panel-heading {
    flex-direction: column;
  }

  .form-grid,
  .checkbox-grid,
  .estimate-card,
  .detail-grid,
  .admin-controls,
  .metrics,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .admin-controls .wide-control {
    grid-column: auto;
  }

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

@media (max-width: 720px) {
  .auth-gate {
    padding: 24px 16px;
  }

  .auth-card {
    padding: 20px;
  }

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

  .button-link {
    width: 100%;
  }
}


textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

textarea:focus {
  outline: 3px solid rgba(22, 119, 255, 0.16);
  border-color: var(--brand);
}

.pilot-banner {
  margin-bottom: 18px;
  border: 1px solid #ffe58f;
  border-radius: 16px;
  padding: 14px 16px;
  color: #8c5b00;
  background: #fffbe6;
}

.policy-notice {
  margin-bottom: 20px;
  color: #315479;
  background: #f6fbff;
}

.project-fieldset,
.study-fieldset {
  background: linear-gradient(135deg, #fbfdff, #f5faff);
}

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

.mode-choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

.mode-choice:has(input:checked) {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.mode-choice input {
  width: auto;
  margin: 3px 0 0;
}

.mode-choice strong,
.mode-choice small {
  display: block;
}

.mode-choice small,
.field-help {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.5;
}

.inner-grid {
  grid-column: auto;
  margin-top: 0;
}

.two-cols {
  grid-column: span 2;
}

.request-project {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
}

.scope-box {
  margin-top: 18px;
  border-left: 3px solid var(--brand);
  border-radius: 0 14px 14px 0;
  padding: 14px 16px;
  background: #f8fbff;
}

.scope-box h3 {
  margin-bottom: 8px;
}

.scope-box p:last-child {
  margin-bottom: 0;
}

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

  .two-cols {
    grid-column: auto;
  }
}

/* v1.2 demo UI: applicant-facing card layout */
.request-form { display: grid; gap: 18px; }
.form-section { border: 1px solid var(--line); border-radius: 20px; padding: 22px; background: linear-gradient(180deg, #fff 0%, #fbfdff 100%); }
.section-heading { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.section-heading h3 { margin: 0 0 4px; color: var(--ink); font-size: 22px; font-weight: 800; }
.section-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.section-number { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; background: var(--brand); font-size: 15px; font-weight: 800; }
.service-options { display: grid; gap: 14px; }
.recommended-services { border: 1px solid #b9dbff; border-radius: 16px; padding: 15px; background: #f6fbff; }
.recommended-services h4, .service-category h4 { margin: 0 0 5px; color: var(--ink); font-size: 15px; }
.recommended-services p { margin: 0 0 11px; color: var(--muted); font-size: 14px; }
.service-choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.service-choice { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; font-weight: 500; cursor: pointer; }
.service-choice.recommended { border-color: #96c8ff; background: #eef7ff; }
.service-choice input { width: auto; margin: 0; }
.service-choice small { display: inline; margin: 0 0 0 5px; color: var(--brand); font-size: 12px; }
.all-services { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; }
.all-services summary { cursor: pointer; color: var(--brand); font-weight: 700; }
.service-category-list { display: grid; gap: 13px; margin-top: 14px; }
.service-category { padding-top: 12px; border-top: 1px solid var(--line); }
.lead-time-notice { display: flex; align-items: center; grid-column: span 2; margin-top: 28px; border: 1px solid #b9dbff; border-radius: 12px; padding: 11px 13px; color: #315479; background: #f6fbff; font-size: 14px; line-height: 1.5; }
.lead-time-notice.warning { border-color: #ffd591; color: var(--orange); background: #fff7e6; }
.warning-notice { margin: 0 0 15px; color: #8a4b00; background: #fff7e6; border-color: #ffd591; }
.estimate-notice { margin-top: 14px; color: #315479; background: #f6fbff; border-color: #b9dbff; }
.form-section .form-actions { margin-top: 18px; }

@media (max-width: 820px) {
  .form-section { padding: 18px; }
  .service-choice-grid { grid-template-columns: 1fr; }
  .lead-time-notice { grid-column: 1 / -1; margin-top: 0; }
}

/* v1.2.2 UI refinement: presentation-scale typography */
input, select, textarea, button { font-size: 17px; }
.tab { font-size: 16px; }
.project-mode-grid .mode-choice strong { font-size: 17px; }
.project-mode-grid .mode-choice small, .field-help { font-size: 14px; }
.form-section { padding: 24px; }

/* v1.3.2 typography hierarchy: retain the larger 15px form labels while restoring the prior emphasis levels. */
legend { font-size: 15px; font-weight: 600; }
.project-mode-grid .mode-choice strong { font-weight: 700; }
input, select, textarea { font-weight: 400; }

/* v1.3 delivery and estimator refinement */
.delivery-upload-label {
  display: block;
  margin-top: 14px;
  border: 1px dashed #9bc9ff;
  border-radius: 14px;
  padding: 14px;
  color: var(--ink);
  background: #f8fbff;
}

.delivery-upload-label input {
  margin-top: 10px;
}

.delivery-upload-label input:disabled {
  color: var(--muted);
  background: #f3f5f7;
  cursor: not-allowed;
}

.delivery-notice {
  margin: 8px 0 12px;
  color: #315479;
  background: #f6fbff;
  border-color: #b9dbff;
}

.estimate-admin-note {
  margin-bottom: 12px;
  color: #315479;
  background: #f6fbff;
  border-color: #b9dbff;
}
