:root {
  color-scheme: light;
  --navy: #14273e;
  --navy-2: #203a57;
  --blue: #147bc1;
  --blue-dark: #0d5e96;
  --aqua: #3fc2cf;
  --paper: #f4f7f9;
  --white: #ffffff;
  --ink: #182638;
  --muted: #667587;
  --line: #dbe3e9;
  --line-dark: #c7d1da;
  --green: #24865a;
  --green-soft: #eaf7f0;
  --amber: #a36500;
  --amber-soft: #fff6dc;
  --red: #b42318;
  --red-soft: #fff0ef;
  --purple: #7050b0;
  --purple-soft: #f1ecfb;
  --focus: #9bd9ff;
  --shadow: 0 18px 50px rgba(20, 39, 62, 0.14);
  font-family:
    "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% 8%, rgba(63, 194, 207, 0.07), transparent 28%),
    linear-gradient(135deg, rgba(20, 123, 193, 0.035), transparent 45%),
    var(--paper);
  color: var(--ink);
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  background: var(--navy);
  color: var(--white);
  transition: opacity 200ms ease;
}

.loading-screen.ready {
  opacity: 0;
  pointer-events: none;
}

.loading-screen.error {
  background: #381c22;
}

.loading-mark {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 19px;
  background: linear-gradient(145deg, var(--aqua), var(--blue));
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.loading-screen p {
  margin: 0;
  font-size: 14px;
}

.app-header {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 15px clamp(20px, 4vw, 64px);
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 6px 22px rgba(20, 39, 62, 0.17);
}

.brand {
  display: flex;
  min-width: max-content;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 13px;
  background: linear-gradient(145deg, var(--aqua), var(--blue));
  font-size: 14px;
  font-weight: 900;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(17px, 2vw, 21px);
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.eyebrow.light {
  color: #82dce4;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 5px;
  color: #bfccd8;
  font-size: 11px;
  font-weight: 700;
}

.local-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #51d29d;
  box-shadow: 0 0 0 4px rgba(81, 210, 157, 0.13);
}

.page-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 56px;
}

.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 23px;
}

.page-intro h2 {
  margin: 5px 0 7px;
  color: var(--navy);
  font-size: clamp(27px, 3vw, 36px);
}

.page-intro p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.database-label {
  padding: 9px 13px;
  border: 1px solid #badfd4;
  border-radius: 999px;
  background: #effaf6;
  color: #286d57;
  font-size: 11px;
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}

.summary-card {
  position: relative;
  min-height: 124px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--white);
  box-shadow: 0 7px 24px rgba(20, 39, 62, 0.05);
}

.summary-card::after {
  position: absolute;
  top: -26px;
  right: -20px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(20, 123, 193, 0.055);
  content: "";
}

.summary-card span,
.summary-card small {
  display: block;
}

.summary-card span {
  color: #526477;
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin: 6px 0 2px;
  color: var(--navy);
  font-size: 29px;
  font-variant-numeric: tabular-nums;
}

.summary-card small {
  color: #8693a0;
  font-size: 10px;
}

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

.summary-card.accent strong {
  color: var(--blue);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) minmax(155px, 0.8fr) minmax(125px, 0.65fr);
  align-items: end;
  gap: 13px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 0 8px 30px rgba(20, 39, 62, 0.05);
}

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 7px;
}

.field-label {
  color: #405166;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.field-label em {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #e7f2fb;
  color: var(--blue-dark);
  font-size: 9px;
  font-style: normal;
  vertical-align: 1px;
}

.field small {
  color: #7c8997;
  font-size: 10px;
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--white);
  color: var(--ink);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

input,
select {
  min-height: 42px;
  padding: 8px 11px;
}

textarea {
  padding: 10px 11px;
  line-height: 1.6;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #9fadb9;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 800;
  transition:
    background 130ms ease,
    border-color 130ms ease,
    transform 100ms ease;
}

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

.button-primary {
  background: var(--blue);
  color: var(--white);
}

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

.button-dark {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.07);
  color: var(--white);
}

.button-dark:hover {
  background: rgba(255, 255, 255, 0.14);
}

.button-secondary {
  border-color: var(--line-dark);
  background: var(--white);
  color: var(--navy);
}

.button-secondary:hover,
.button-ghost:hover {
  border-color: #98a8b7;
  background: #f1f5f7;
}

.button-ghost {
  border-color: var(--line);
  background: transparent;
  color: #4b5c6f;
}

.button-danger {
  border-color: #efb7b2;
  background: var(--red-soft);
  color: var(--red);
}

.button-danger:hover {
  background: #fee1df;
}

.check-field {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  color: #506174;
  font-size: 12px;
  font-weight: 700;
}

.check-field input {
  width: 17px;
  min-height: auto;
  height: 17px;
  margin: 0;
}

.password-visibility-field {
  align-self: end;
  font-size: 0.85rem;
}

.deleted-filter {
  grid-column: 1 / 2;
}

.csv-button {
  grid-column: 4 / 5;
}

.list-section {
  margin-top: 22px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 0 3px 11px;
}

.section-heading h3 {
  margin: 0;
  color: var(--navy);
  font-size: 17px;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--white);
  box-shadow: 0 8px 30px rgba(20, 39, 62, 0.05);
}

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

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid #e7edf1;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #edf3f7;
  color: #465669;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

td {
  color: #2d3d50;
  font-size: 12px;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #f8fbfd;
}

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

tbody tr.deleted-row {
  background: #f5f5f5;
  opacity: 0.7;
}

.reservation-link {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.reservation-link:hover .organization-name {
  color: var(--cyan-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.reservation-number {
  display: block;
  margin-bottom: 3px;
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.organization-name {
  display: block;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.45;
}

.subtext {
  display: block;
  margin-top: 3px;
  color: #778595;
  font-size: 10px;
  line-height: 1.45;
}

.type-badge,
.status-badge,
.deadline-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.type-badge {
  padding: 5px 8px;
  background: #edf1f4;
  color: #526276;
}

.type-badge.multi {
  background: var(--purple-soft);
  color: var(--purple);
}

.status-badge {
  padding: 5px 9px;
  background: #edf1f4;
  color: #536477;
}

.status-badge.status-new,
.status-badge.status-check {
  background: #e9f3fc;
  color: #176ca8;
}

.status-badge.status-hold,
.status-badge.status-quote {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge.status-confirmed,
.status-badge.status-paid,
.status-badge.status-complete {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.status-cancel,
.status-badge.status-lost {
  background: var(--red-soft);
  color: var(--red);
}

.count-line {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.count-line b {
  color: var(--navy);
}

.deadline-cell {
  min-width: 135px;
}

.deadline-badge {
  padding: 5px 8px;
  background: #edf3f7;
  color: #536477;
}

.deadline-badge.soon {
  background: var(--amber-soft);
  color: var(--amber);
}

.deadline-badge.overdue {
  background: var(--red-soft);
  color: var(--red);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  white-space: nowrap;
}

.row-action {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: #42546a;
  font-size: 11px;
  font-weight: 800;
}

.row-action:hover {
  border-color: #99a8b6;
  background: #f3f6f8;
}

.row-action.delete {
  color: var(--red);
}

.row-action.restore {
  color: var(--green);
}

.empty-state {
  padding: 60px 20px 68px;
  text-align: center;
}

.empty-state > div {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  place-items: center;
  border-radius: 50%;
  background: #edf3f7;
  color: #768698;
  font-size: 24px;
}

.empty-state h4 {
  margin: 0 0 7px;
  color: var(--navy);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

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

dialog::backdrop {
  background: rgba(11, 25, 42, 0.6);
  backdrop-filter: blur(3px);
}

.reservation-dialog {
  width: min(1120px, calc(100% - 26px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

.reservation-dialog form {
  display: flex;
  max-height: calc(100vh - 24px);
  flex-direction: column;
}

.dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 23px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 4px 0 0;
  color: var(--navy);
  font-size: 21px;
}

.dialog-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #566579;
  font-size: 25px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--line);
  background: #f1f5f7;
}

.dialog-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 0 22px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.tab-button {
  min-width: max-content;
  padding: 13px 15px 11px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #69798a;
  font-size: 12px;
  font-weight: 800;
}

.tab-button:hover {
  color: var(--navy);
}

.tab-button.active {
  border-bottom-color: var(--blue);
  color: var(--blue-dark);
}

.form-messages {
  flex: 0 0 auto;
  margin: 12px 23px 0;
  padding: 11px 14px;
  border: 1px solid #efc1bd;
  border-radius: 9px;
  background: var(--red-soft);
  color: #8d2c24;
  font-size: 11px;
  line-height: 1.6;
}

.form-messages.warning {
  border-color: #ecd395;
  background: var(--amber-soft);
  color: #79510b;
}

.form-messages ul {
  margin: 5px 0 0;
  padding-left: 20px;
}

.dialog-body {
  flex: 1 1 auto;
  padding: 4px 23px 28px;
  overflow-y: auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

fieldset {
  margin: 0;
  padding: 23px 0 26px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

fieldset:last-child {
  border-bottom: 0;
}

legend {
  width: 100%;
  margin-bottom: 15px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 900;
}

legend small {
  margin-left: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.fieldset-help,
.schedule-stage-help {
  margin: -7px 0 15px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.entity-fieldset {
  padding-top: 20px;
}

.ai-assist-fieldset {
  padding: 20px;
  border: 1px solid #b7dfe5;
  border-radius: 14px;
  background: linear-gradient(135deg, #f3fcfd, #f8fbff);
}

.ai-assist-fieldset + .entity-fieldset {
  margin-top: 18px;
}

.ai-assist-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.ai-assist-status {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.ai-draft-preview {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid #b7dfe5;
}

.ai-draft-heading h3,
.ai-draft-schedules h4 {
  margin: 0;
  color: var(--navy);
  font-size: 14px;
}

.ai-draft-heading p {
  margin: 5px 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.ai-raw-email-option {
  margin: 14px 0 8px;
}

.ai-draft-schedules {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.ai-draft-schedule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
}

@media (max-width: 720px) {
  .ai-assist-actions {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

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

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

.dialog-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 15px 23px;
  border-top: 1px solid var(--line);
  background: #f8fafb;
}

.save-note {
  margin-right: auto;
  color: #6b7988;
  font-size: 10px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 21px 0 16px;
}

.panel-heading h3,
.history-layout h3,
.deadline-layout h3 {
  margin: 0;
  color: var(--navy);
  font-size: 15px;
}

.panel-heading p,
.panel-copy {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.schedule-list {
  display: grid;
  gap: 15px;
}

.schedule-card {
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 14px;
  background: #fbfcfd;
}

.schedule-stage-help {
  margin: 10px 0 0;
  padding: 9px 11px;
  border-radius: 8px;
  background: #eef6fb;
  color: #476477;
}

.schedule-change-history {
  margin-top: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
}

.schedule-change-history summary {
  cursor: pointer;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
}

.schedule-change-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.schedule-change-list > div {
  display: grid;
  grid-template-columns: 135px 110px 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding-top: 7px;
  border-top: 1px dashed var(--line);
  color: #536475;
  font-size: 10px;
}

.schedule-change-list time,
.schedule-change-list small {
  color: var(--muted);
}

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #edf3f7;
}

.schedule-header h4 {
  margin: 0;
  color: var(--navy);
  font-size: 13px;
}

.schedule-header .schedule-date-summary {
  margin-left: 7px;
  color: #758493;
  font-size: 10px;
  font-weight: 500;
}

.remove-schedule {
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid #ebc1bd;
  border-radius: 7px;
  background: var(--white);
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
}

.schedule-body {
  padding: 17px;
}

.schedule-main-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.schedule-details {
  margin-top: 16px;
}

.details-toggle {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f6f8;
  color: #46586c;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
}

.details-content {
  display: none;
  margin-top: 13px;
}

.schedule-details.open .details-content {
  display: block;
}

.headcount-section {
  margin-top: 19px;
}

.headcount-section h5 {
  margin: 0 0 9px;
  color: var(--navy);
  font-size: 12px;
}

.headcount-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
}

.headcount-table {
  min-width: 690px;
}

.headcount-table th,
.headcount-table td {
  padding: 8px 9px;
  font-size: 10px;
}

.headcount-table input,
.headcount-table select {
  min-height: 34px;
  padding: 5px 7px;
  font-size: 11px;
}

.headcount-table input {
  width: 86px;
}

.headcount-table select {
  width: 80px;
}

.headcount-category {
  min-width: 120px;
  color: #3c4f64;
  font-weight: 800;
}

.headcount-total-row {
  background: #f1f5f8;
}

.headcount-total-row td {
  color: var(--navy);
  font-weight: 900;
}

.declared-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 13px;
  padding: 13px;
  border: 1px dashed #bdcad5;
  border-radius: 10px;
  background: #f7f9fa;
}

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

.no-schedule {
  padding: 40px 20px;
  border: 1px dashed #b8c5d1;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.history-layout,
.deadline-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.1fr);
  gap: 28px;
  padding-top: 23px;
}

.history-entry {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f9fa;
}

.notice {
  padding: 10px 12px;
  border: 1px solid #c8deef;
  border-radius: 8px;
  background: #edf6fc;
  color: #3f6581;
  font-size: 11px;
  line-height: 1.6;
}

.history-save {
  width: 100%;
  margin-top: 12px;
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 13px;
}

.timeline-item {
  position: relative;
  padding: 0 0 19px 24px;
  border-left: 2px solid #d9e2e8;
}

.timeline-item::before {
  position: absolute;
  top: 3px;
  left: -7px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px #b7c9d6;
  content: "";
}

.timeline-item:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  color: #718091;
  font-size: 10px;
}

.method-badge {
  padding: 3px 6px;
  border-radius: 999px;
  background: #e9f3fb;
  color: var(--blue-dark);
  font-weight: 800;
}

.timeline-content {
  color: #2a3c50;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.timeline-next {
  margin-top: 7px;
  padding: 7px 9px;
  border-radius: 7px;
  background: var(--amber-soft);
  color: #76520c;
  font-size: 10px;
}

.timeline-empty {
  padding: 28px 14px;
  border: 1px dashed #c4ced7;
  border-radius: 10px;
  color: #7b8996;
  font-size: 11px;
  text-align: center;
}

.deadline-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.deadline-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f9fafb;
}

.deadline-item strong {
  display: block;
  color: #33485d;
  font-size: 11px;
}

.deadline-item small {
  display: block;
  margin-top: 3px;
  color: #7a8997;
  font-size: 9px;
}

.deadline-item time {
  color: var(--navy);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.deadline-item.overdue {
  border-color: #efbbb6;
  background: var(--red-soft);
}

.deadline-item.overdue time {
  color: var(--red);
}

.deadline-item.soon {
  border-color: #ecd394;
  background: var(--amber-soft);
}

.pricing-list,
.task-list,
.price-master-list,
.master-editor {
  display: grid;
  gap: 13px;
}

.pricing-card,
.task-card,
.price-master-card,
.task-rule-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfd;
}

.pricing-card-header,
.price-master-heading,
.task-rule-heading,
.master-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.pricing-card-header h4,
.task-card h4 {
  margin: 4px 0;
  color: var(--navy);
  font-size: 15px;
}

.pricing-card-header small,
.task-card small {
  color: var(--muted);
  font-size: 10px;
}

.pricing-total {
  color: var(--blue-dark);
  font-size: 24px;
  white-space: nowrap;
}

.pricing-controls {
  display: grid;
  grid-template-columns: 180px 180px 1fr;
  gap: 12px;
  margin-top: 15px;
}

.pricing-breakdown {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-dark);
}

.pricing-lines {
  display: grid;
  align-content: start;
  gap: 7px;
}

.pricing-lines div,
.pricing-breakdown dl div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  color: #536475;
  font-size: 11px;
}

.pricing-breakdown dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.pricing-breakdown dt,
.pricing-breakdown dd {
  margin: 0;
}

.payment-section {
  margin-top: 22px;
  padding-top: 3px;
  border-top: 1px solid var(--line);
}

.compact-heading {
  padding-bottom: 12px;
}

.payment-entry {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 11px;
}

.payment-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.payment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
}

.payment-item strong,
.payment-item span {
  display: block;
}

.payment-item span,
.payment-item small {
  color: var(--muted);
  font-size: 10px;
}

.task-card.overdue {
  border-color: #efbbb6;
  background: var(--red-soft);
}

.task-card.soon {
  border-color: #ecd394;
  background: var(--amber-soft);
}

.task-main {
  display: grid;
  grid-template-columns: minmax(190px, 0.65fr) 1.6fr;
  gap: 18px;
}

.task-controls {
  display: grid;
  grid-template-columns: 140px 1fr 1.4fr auto;
  align-items: end;
  gap: 10px;
}

.settings-dialog {
  width: min(1080px, calc(100% - 26px));
}

.settings-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.settings-section .section-heading {
  align-items: center;
}

.settings-section .section-heading p,
.master-actions p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.master-actions {
  padding: 10px 12px;
  border: 1px solid #badfd4;
  border-radius: 10px;
  background: #effaf6;
}

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

.master-period,
.price-fields,
.rule-fields {
  margin: 13px 0;
}

.price-master-heading .field {
  width: min(280px, 60%);
}

.task-rule-name {
  flex: 1;
}

.rule-notes {
  grid-column: span 2;
}

.settings-dialog {
  overflow: hidden;
}

.settings-dialog form {
  display: flex;
  max-height: calc(100vh - 30px);
  flex-direction: column;
}

.settings-body {
  padding: 20px 23px 26px;
  overflow-y: auto;
}

.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 9px;
  background: var(--white);
}

.input-suffix input {
  min-width: 0;
  border: 0;
  background: transparent;
}

.input-suffix span {
  flex: 0 0 auto;
  padding-right: 11px;
  color: #758291;
  font-size: 11px;
}

.confirm-dialog {
  width: min(430px, calc(100% - 30px));
}

.confirm-content {
  padding: 27px;
  text-align: center;
}

.confirm-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  place-items: center;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-size: 20px;
  font-weight: 900;
}

.confirm-content h2 {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 18px;
}

.confirm-content p {
  margin: 0;
  color: #677687;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-line;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 21px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: min(380px, calc(100% - 44px));
  padding: 12px 16px;
  border-radius: 9px;
  background: var(--navy);
  color: var(--white);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

footer {
  padding: 16px 20px 28px;
  color: #7c8995;
  font-size: 10px;
  text-align: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

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

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

  .type-filter {
    grid-column: auto;
  }

  .deleted-filter {
    grid-column: 1 / 2;
  }

  .csv-button {
    grid-column: 3 / 4;
  }

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

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

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

@media (max-width: 820px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .local-badge {
    margin-right: auto;
  }

  .page-shell {
    width: calc(100% - 26px);
    padding-top: 30px;
  }

  .page-intro {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .search-field {
    grid-column: 1 / -1;
  }

  .deleted-filter {
    grid-column: 1 / 2;
  }

  .csv-button {
    grid-column: 2 / 3;
  }

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

  .history-layout,
  .deadline-layout {
    grid-template-columns: 1fr;
  }

  .schedule-change-list > div {
    grid-template-columns: 1fr 1fr;
  }

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

  .pricing-breakdown {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 580px) {
  .app-header {
    padding: 13px 15px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .header-actions .button {
    flex: 1;
    padding-right: 11px;
    padding-left: 11px;
  }

  .local-badge {
    width: 100%;
    margin-bottom: 3px;
  }

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

  .summary-card {
    min-height: 104px;
  }

  .search-field,
  .deleted-filter,
  .csv-button {
    grid-column: auto;
  }

  .csv-button {
    width: 100%;
  }

  .dialog-header,
  .dialog-footer,
  .dialog-body,
  .settings-body {
    padding-right: 15px;
    padding-left: 15px;
  }

  .dialog-tabs {
    padding: 0 13px;
  }

  .form-grid,
  .form-grid.compact,
  .schedule-main-grid,
  .declared-totals,
  .wheelchair-grid,
  .pricing-controls,
  .payment-entry,
  .task-controls,
  .master-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2,
  .field-full {
    grid-column: auto;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-heading .button {
    width: 100%;
  }

  .pricing-card-header,
  .price-master-heading,
  .task-rule-heading,
  .master-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .price-master-heading .field {
    width: 100%;
  }

  .rule-notes {
    grid-column: auto;
  }

  .schedule-change-list > div {
    grid-template-columns: 1fr;
  }

  .dialog-footer {
    flex-wrap: wrap;
  }

  .save-note {
    width: 100%;
  }

  .dialog-footer .button {
    flex: 1;
  }
}

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

.server-badge span {
  background: var(--aqua);
  box-shadow: 0 0 0 4px rgba(63, 194, 207, 0.16);
}

.current-user {
  display: grid;
  min-width: 96px;
  color: var(--white);
  line-height: 1.25;
}

.current-user small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(63, 194, 207, 0.2), transparent 30%),
    linear-gradient(145deg, var(--navy), #1e4567);
}

.auth-shell {
  width: min(100%, 520px);
}

.auth-card {
  padding: clamp(26px, 6vw, 44px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 30px 80px rgba(5, 21, 36, 0.35);
}

.setup-card {
  width: min(100%, 620px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand h1 {
  margin: 2px 0 0;
  color: var(--navy);
  font-size: clamp(1.45rem, 4vw, 2rem);
}

.auth-description {
  margin: 22px 0;
  color: var(--muted);
  line-height: 1.75;
}

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

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-error {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #f3bbb6;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  line-height: 1.6;
}

.user-manager {
  display: grid;
  gap: 14px;
}

.user-card {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(140px, 0.7fr) auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfcfd;
}

.user-card .user-active-field {
  align-self: center;
}

.user-card .password-visibility-field {
  align-self: center;
}

.user-last-login {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

@media (max-width: 900px) {
  .current-user {
    order: -1;
  }

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

@media (max-width: 580px) {
  .current-user {
    width: 100%;
  }

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

  .user-last-login {
    grid-column: auto;
  }
}
