:root {
  color-scheme: light;
  --navy: #0f3047;
  --navy-2: #163e57;
  --teal: #0aaeb3;
  --teal-dark: #078d92;
  --green: #128d6b;
  --amber: #bd7314;
  --red: #c74250;
  --blue: #2476a5;
  --text: #172b3a;
  --muted: #667b88;
  --line: #dbe5e9;
  --surface: #ffffff;
  --background: #f4f7f9;
  --soft: #eef4f6;
  --shadow: 0 8px 24px rgba(15, 48, 71, 0.09);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(10, 174, 179, 0.22);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  background: #edf3f5;
}

.login-panel {
  width: min(100%, 430px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px 24px 22px;
}

.login-brand,
.header-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.login-brand {
  margin-bottom: 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 6px;
  font-size: 18px;
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.login-brand p,
.login-foot {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form,
.form-grid {
  display: grid;
  gap: 8px;
}

label,
.field-label {
  color: #405866;
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cddbe1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

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

.login-form input {
  margin-bottom: 10px;
}

.password-row {
  position: relative;
  margin-bottom: 2px;
}

.password-row input {
  padding-right: 50px;
  margin-bottom: 0;
}

.password-row .icon-button {
  position: absolute;
  top: 4px;
  right: 4px;
}

.form-error {
  min-height: 21px;
  margin: 0 0 5px;
  color: var(--red);
  font-size: 14px;
}

.login-foot {
  margin-top: 18px;
  text-align: center;
}

.app-view {
  min-height: 100vh;
  min-height: 100dvh;
}

.app-header {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto 0;
  min-height: 60px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 2px 10px rgba(15, 48, 71, 0.18);
}

.header-brand strong {
  display: block;
  font-size: 16px;
}

.header-brand span {
  display: block;
  color: #9fc3cf;
  font-size: 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.icon-button:hover {
  background: rgba(15, 48, 71, 0.07);
}

.header-action {
  color: #d8ebef;
}

.header-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  pointer-events: none;
}

.main-content {
  width: min(100%, 880px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(78px + env(safe-area-inset-top)) 14px calc(88px + env(safe-area-inset-bottom));
}

.main-content.contract-page-content {
  width: min(100%, 760px);
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.contract-page-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.contract-page-head h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1.25;
}

.contract-page-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.back-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.contract-page-form {
  gap: 12px;
}

.workflow-section {
  padding: 17px 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 3px 13px rgba(15, 48, 71, 0.045);
  overflow: hidden;
}

.step-heading {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  margin-bottom: 15px;
}

.step-heading > span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
}

.step-heading h2 {
  margin: 0;
  font-size: 19px;
}

.step-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workflow-section fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.document-rule {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 14px;
  padding: 13px;
  border-left: 4px solid var(--blue);
  background: #eef6fa;
  color: #284b61;
}

.document-rule .icon {
  width: 23px;
  height: 23px;
  margin-top: 1px;
  color: var(--blue);
}

.document-rule strong {
  display: block;
  font-size: 14px;
}

.document-rule p {
  margin: 3px 0 0;
  font-size: 13px;
}

.driver-evidence {
  min-width: 0;
  padding: 16px 0 10px;
  border-top: 1px solid var(--line);
}

.driver-evidence:first-child {
  padding-top: 0;
  border-top: 0;
}

.driver-evidence-heading {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.driver-evidence-heading h3 {
  min-width: 0;
  margin: 0;
  font-size: 16px;
}

.add-driver-button {
  width: 100%;
  margin-top: 4px;
}

#driver-count {
  margin: 8px 0 0;
  text-align: center;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin-bottom: 14px;
  padding: 3px;
  border: 1px solid #cddbe1;
  border-radius: 7px;
  background: #edf3f5;
}

.segmented-control label {
  min-width: 0;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
}

.segmented-control span {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 7px 8px;
  border-radius: 5px;
  color: #526b78;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.segmented-control input:checked + span {
  background: #fff;
  color: var(--teal-dark);
  box-shadow: 0 2px 7px rgba(15, 48, 71, 0.1);
}

.capture-grid {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.capture-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 9px;
  border: 1px dashed #9fb7c2;
  border-radius: 7px;
  background: #f8fbfc;
  cursor: pointer;
}

.capture-card.captured {
  border-style: solid;
  border-color: #87cbbb;
  background: #f0faf7;
}

.capture-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.capture-preview {
  width: 92px;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: #e7eff2;
  color: #6d8794;
}

.capture-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.capture-preview .icon {
  width: 27px;
  height: 27px;
}

.capture-copy {
  min-width: 0;
}

.capture-copy strong,
.capture-copy small,
.capture-copy em {
  display: block;
  overflow-wrap: anywhere;
}

.capture-copy strong {
  color: var(--text);
  font-size: 14px;
}

.capture-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.capture-copy em {
  margin-top: 7px;
  color: var(--teal-dark);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.evidence-consent {
  margin-top: 12px;
}

.document-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.document-status.complete {
  color: var(--green);
  font-weight: 700;
}

.locked-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #d7e1e5;
  border-radius: 6px;
  background: #f2f5f6;
  color: #687d88;
  font-size: 13px;
}

.locked-notice .icon {
  flex: 0 0 auto;
}

.contract-page-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  padding: 5px 0 calc(8px + env(safe-area-inset-bottom));
}

.contract-page-actions button {
  min-height: 50px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.page-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button,
.success-button,
.text-button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
}

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

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

.secondary-button {
  background: #e5edf0;
  color: var(--text);
}

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

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

.text-button {
  min-height: 38px;
  background: transparent;
  color: var(--blue);
  padding: 0 8px;
}

.full-button {
  width: 100%;
}

.compact-button {
  min-height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.metric-card {
  min-height: 104px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(15, 48, 71, 0.05);
}

.metric-card .metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.15;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-card.danger strong {
  color: var(--red);
}

.metric-card.warning strong {
  color: var(--amber);
}

.section-block {
  margin: 20px 0 12px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  padding: 13px 14px;
  border: 1px solid #eac98d;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: #fff7e8;
  color: #694a18;
  font-size: 14px;
  margin-bottom: 14px;
}

.return-alert {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
  padding: 13px 14px;
  border: 1px solid #edc987;
  border-left: 5px solid var(--amber);
  border-radius: 6px;
  background: #fff7e7;
  color: #684716;
}

.return-alert strong {
  font-size: 14px;
}

.return-alert span {
  font-size: 12px;
}

.contract-action-panel {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid #b9dadd;
  border-left: 5px solid var(--teal);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(15, 48, 71, 0.06);
}

.contract-action-panel h2 {
  margin: 0;
  font-size: 20px;
}

.contract-action-panel p {
  margin: 5px 0 15px;
  color: var(--muted);
  font-size: 14px;
}

.contract-action-panel .primary-button {
  min-height: 50px;
  font-size: 16px;
}

.contract-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.contract-action-buttons button {
  width: 100%;
  min-height: 50px;
}

.intake-hidden {
  display: none;
}

.contract-nav .icon {
  color: var(--teal-dark);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin-bottom: 12px;
}

.filter-bar.three {
  grid-template-columns: minmax(0, 1fr) 128px auto;
}

.prep-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.prep-toolbar label {
  min-width: 0;
}

.prep-toolbar input {
  margin-top: 4px;
}

.prep-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.prep-summary strong {
  color: var(--text);
}

.prep-summary a {
  margin-left: auto;
  color: var(--blue);
  font-weight: 700;
}

.prep-note {
  margin: 0;
  padding: 0 14px 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.vehicle-detail-grid {
  padding: 6px 0 12px;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-left: 40px;
}

.search-wrap .icon {
  position: absolute;
  left: 12px;
  top: 13px;
  color: var(--muted);
}

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

.record-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(15, 48, 71, 0.045);
}

.vehicle-rental-card.due-soon {
  border-left: 4px solid var(--amber);
}

.vehicle-rental-card.overdue {
  border-left: 4px solid var(--red);
}

.record-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 8px;
}

.record-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.record-card .record-id {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 4px 9px;
  background: #e8eef1;
  color: #536b78;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.active,
.status-pill.normal,
.status-pill.available {
  background: #dcf3eb;
  color: #08795b;
}

.status-pill.overdue,
.status-pill.legal-overdue {
  background: #fbe4e7;
  color: var(--red);
}

.status-pill.reserved,
.status-pill.due-soon,
.status-pill.six-overdue,
.status-pill.mileage-due {
  background: #fff0d3;
  color: #9a5a08;
}

.status-pill.completed,
.status-pill.inactive,
.status-pill.needs-setup {
  background: #e9eef1;
  color: #607480;
}

.record-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 12px;
  padding: 6px 14px 14px;
}

.detail-item {
  min-width: 0;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  display: block;
  margin-top: 1px;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e8eef1;
  background: #f8fafb;
}

.empty-state {
  padding: 42px 18px;
  border: 1px dashed #c8d7dd;
  border-radius: 8px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}

.empty-state .icon {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
}

.bottom-nav {
  position: fixed;
  z-index: 35;
  inset: auto 0 0 0;
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 5px max(6px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid #d4e0e5;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -5px 18px rgba(15, 48, 71, 0.08);
}

.bottom-nav button {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  color: #667c88;
  font-size: 11px;
}

.bottom-nav button.active {
  color: var(--teal-dark);
  background: #e7f5f5;
  font-weight: 700;
}

.bottom-nav .icon {
  width: 21px;
  height: 21px;
}

.fab {
  position: fixed;
  z-index: 24;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 22px rgba(10, 174, 179, 0.3);
}

.fab .icon {
  width: 24px;
  height: 24px;
}

.sheet-backdrop {
  position: fixed;
  z-index: 70;
  inset: 0;
  background: rgba(9, 31, 46, 0.45);
}

.sheet {
  position: fixed;
  z-index: 80;
  inset: auto 0 0 0;
  width: min(100%, 720px);
  max-height: min(92vh, 820px);
  max-height: min(92dvh, 820px);
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 -12px 38px rgba(9, 31, 46, 0.22);
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 9px auto 2px;
  border-radius: 2px;
  background: #c7d4da;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.sheet-header h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 16px 22px;
}

.form-grid {
  gap: 6px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  margin-bottom: 10px;
}

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

.form-actions {
  position: sticky;
  bottom: -22px;
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  margin: 10px -16px -22px;
  padding: 13px 16px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.inline-help {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.money-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 2px 0 12px;
  padding: 12px;
  border: 1px solid #c9e0e3;
  border-radius: 6px;
  background: #edf7f7;
}

.money-summary span {
  color: var(--muted);
  font-size: 12px;
}

.money-summary strong {
  display: block;
  margin-top: 2px;
}

.charge-panel {
  margin: 4px 0 14px;
  border: 1px solid #c9e0e3;
  border-radius: 8px;
  background: #f7fbfb;
  overflow: hidden;
}

.charge-panel h3 {
  margin: 0;
  padding: 12px 13px;
  border-bottom: 1px solid #dbe9eb;
  font-size: 16px;
}

.charge-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 13px;
  border-bottom: 1px solid #e6eff1;
  font-size: 14px;
}

.charge-line:last-child {
  border-bottom: 0;
}

.charge-line span:first-child {
  color: #405866;
}

.charge-line strong {
  white-space: nowrap;
}

.charge-line.total {
  padding-top: 12px;
  padding-bottom: 12px;
  background: #e9f6f6;
  font-size: 16px;
}

.confirm-check {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  margin: 6px 0 16px;
  padding: 12px;
  border: 1px solid #d2e0e4;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.confirm-check input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  margin: 1px 0 0;
}

.result-panel {
  padding: 16px;
  border: 1px solid #bcded5;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #eef9f5;
}

.result-panel h3 {
  margin: 0 0 6px;
  color: #087257;
  font-size: 19px;
}

.result-panel p {
  margin: 3px 0;
  overflow-wrap: anywhere;
}

.share-link {
  width: 100%;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #cbdde1;
  border-radius: 6px;
  background: #fff;
  color: #405866;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.button-stack {
  display: grid;
  gap: 9px;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.check-tile {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid #cddbe1;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
}

.check-tile input {
  width: 19px;
  height: 19px;
  min-height: 19px;
  margin: 0;
}

.sort-button {
  width: 46px;
  min-width: 46px;
  padding: 0;
}

.subtle-line {
  margin: 8px 0 14px;
  border: 0;
  border-top: 1px solid var(--line);
}

.readonly-field {
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid #d9e4e8;
  border-radius: 6px;
  background: #f5f8f9;
  color: #405866;
  margin-bottom: 10px;
}

.account-panel,
.settings-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.account-panel {
  padding: 17px;
  margin-bottom: 14px;
}

.account-panel strong {
  display: block;
  font-size: 17px;
}

.account-panel span {
  color: var(--muted);
  font-size: 13px;
}

.settings-row {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-bottom: 1px solid #e8eef1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 15px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.settings-row:last-child {
  border-bottom: 0;
}

.settings-row span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.loading {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(244, 247, 249, 0.82);
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #cfe1e6;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  z-index: 110;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 520px);
  transform: translateX(-50%);
  border-radius: 6px;
  padding: 12px 14px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 9px 28px rgba(15, 48, 71, 0.25);
  text-align: center;
  font-size: 14px;
}

.toast.error {
  background: #9f2f3b;
}

.sync-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (min-width: 720px) {
  .main-content {
    padding-left: 24px;
    padding-right: 24px;
  }

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

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

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

  .capture-card {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .capture-preview {
    width: 100%;
  }

  .sheet {
    bottom: 20px;
    border-bottom: 1px solid var(--line);
    border-radius: 8px;
  }
}

@media (max-width: 430px) {
  .filter-bar.three {
    grid-template-columns: minmax(0, 1fr) 122px;
  }

  .filter-bar.three .filter-submit {
    grid-column: 1 / -1;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

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

  .page-head h1 {
    font-size: 22px;
  }

  .workflow-section {
    padding: 15px 12px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
