:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4f7;
  --line: #d8e0e7;
  --text: #1c2733;
  --muted: #66788a;
  --primary: #0f6b73;
  --primary-strong: #0a5056;
  --accent: #7a5a00;
  --danger: #b3261e;
  --shadow: 0 16px 40px rgba(28, 39, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif;
  font-size: 15px;
}

body.modal-open {
  overflow: hidden;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

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

button:disabled:hover {
  border-color: var(--line);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

button.danger {
  color: var(--danger);
  border-color: #ecc8c3;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #17232f;
  color: #ffffff;
  padding: 28px 20px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d9f1ef;
  color: #0b5d65;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-color: transparent;
  background: transparent;
  color: #d7e0e7;
}

.nav-tab.active,
.nav-tab:hover {
  background: #223343;
  border-color: #32495c;
  color: #ffffff;
}

.content {
  padding: 30px;
  overflow: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 25px;
}

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

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

.search-panel,
.edit-panel,
.import-panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
.table-toolbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tooltip-icon {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #b8c8d4;
  border-radius: 50%;
  background: #f8fbfd;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.tooltip-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 12;
  width: max-content;
  max-width: 280px;
  transform: translateX(-50%);
  padding: 8px 10px;
  border-radius: 6px;
  background: #17232f;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
  box-shadow: 0 10px 26px rgba(23, 35, 47, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.tooltip-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #17232f;
}

.tooltip-icon:hover .tooltip-bubble,
.tooltip-icon:focus .tooltip-bubble {
  opacity: 1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(15, 107, 115, 0.18);
  border-color: var(--primary);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
}

.search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.search-footer .actions {
  margin-top: 0;
}

.checkbox-field {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.booking-notice {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid #c5dde2;
  border-radius: var(--radius);
  background: #eef8f8;
  color: #174d55;
  font-size: 14px;
  font-weight: 700;
}

.status-line {
  margin: 16px 0 12px;
  color: var(--muted);
}

.result-list {
  display: grid;
  gap: 12px;
}

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

.result-main {
  display: grid;
  grid-template-columns:
    minmax(300px, 1fr)
    minmax(84px, 110px)
    minmax(84px, 110px)
    minmax(190px, 220px)
    minmax(84px, 110px);
  gap: 14px;
  align-items: center;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.metric-value {
  font-size: 18px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.range-metric {
  display: grid;
  gap: 7px;
}

.booking-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.booking-chip,
.booking-caption {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.booking-chip {
  gap: 6px;
  padding: 5px 8px;
  background: #e3f3f1;
  color: #0a5056;
}

.booking-chip strong {
  color: #062f35;
}

.booking-metric {
  min-width: 190px;
  display: grid;
  align-content: center;
  padding: 10px 12px;
  border: 1px solid #b9dce0;
  border-radius: 8px;
  background: #f2fbfb;
}

.booking-metric .metric-label,
.booking-metric .metric-value {
  color: #0a5056;
}

.booking-metric .metric-value {
  white-space: nowrap;
  overflow-wrap: normal;
}

.booking-caption {
  margin-top: 6px;
  padding: 3px 7px;
  background: #d8efec;
  color: #0a5056;
}

.result-details {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-soft);
  color: #31505a;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chip.warn {
  background: #fff2c7;
  color: var(--accent);
}

.chip.danger {
  background: #fde7e4;
  color: var(--danger);
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  color: var(--muted);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(320px, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.page > .split-layout {
  display: none;
}

.edit-panel,
.import-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.edit-panel h3,
.import-panel h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 120px minmax(180px, 1fr);
  gap: 10px;
}

.table-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 8px 0 10px;
}

.table-toolbar label {
  width: 180px;
}

.toolbar-action {
  margin-left: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(23, 35, 47, 0.48);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(1180px, 100%);
  max-height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: 0 22px 70px rgba(23, 35, 47, 0.22);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.modal-head h3 {
  margin: 0;
  font-size: 19px;
}

.modal-close {
  min-width: 64px;
}

.modal-body {
  overflow: auto;
  padding: 18px;
}

.modal-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(320px, 1fr);
  gap: 16px;
  margin-bottom: 0;
}

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

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

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

th {
  background: #edf3f6;
  color: #3c4c5b;
  font-size: 13px;
}

td {
  background: #ffffff;
}

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

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

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #17232f;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1180px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-tab {
    text-align: center;
  }

  .content {
    padding: 18px;
  }

  .split-layout,
  .form-grid,
  .result-main,
  .result-details,
  .inline-fields,
  .modal-layout {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .search-footer .actions {
    justify-content: stretch;
  }

  .search-footer .actions button {
    flex: 1;
  }

  .table-toolbar label {
    width: 100%;
  }

  .toolbar-action {
    margin-left: 0;
    width: 100%;
  }

  .modal-backdrop {
    padding: 14px;
  }

  .modal-panel {
    max-height: calc(100vh - 28px);
  }
}
