:root {
  color-scheme: light;
  --ink: #17324d;
  --muted: #5f7187;
  --line: rgba(117, 156, 191, 0.28);
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --blue: #3f8cff;
  --blue-strong: #236dd9;
  --cyan: #32bfd2;
  --mint: #2bbf8f;
  --rose: #d94a6a;
  --shadow: 0 22px 60px rgba(51, 98, 146, 0.18);
  --radius: 8px;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(247, 252, 255, 0.92), rgba(220, 241, 255, 0.84) 42%, rgba(255, 255, 255, 0.96)),
    repeating-linear-gradient(90deg, rgba(63, 140, 255, 0.06) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(50, 191, 210, 0.05) 0 1px, transparent 1px 72px);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.topbar-side {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-width: min(100%, 680px);
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(63, 140, 255, 0.24);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(221, 243, 255, 0.72));
  box-shadow: 0 12px 28px rgba(63, 140, 255, 0.16);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
  fill: rgba(63, 140, 255, 0.14);
  stroke: var(--blue-strong);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.45rem);
  line-height: 1.16;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.25;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  min-width: min(100%, 500px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.summary-strip div {
  padding: 14px 16px;
  border-left: 1px solid var(--line);
}

.summary-strip div:first-child {
  border-left: 0;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.08rem;
  line-height: 1.2;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  align-items: start;
  gap: 22px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.form-panel {
  position: sticky;
  top: 24px;
  padding: 20px;
}

.panel-heading,
.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  gap: 13px;
}

.field,
.search-field {
  display: grid;
  gap: 7px;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select,
.search-field input {
  width: 100%;
  height: 44px;
  min-width: 0;
  border: 1px solid rgba(91, 135, 177, 0.3);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input,
.field select {
  padding: 0 12px;
}

.field select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--blue-strong) 50%),
    linear-gradient(135deg, var(--blue-strong) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.field input:focus,
.field select:focus,
.search-field input:focus {
  border-color: rgba(63, 140, 255, 0.72);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(63, 140, 255, 0.14);
}

.hidden {
  display: none;
}

[hidden] {
  display: none !important;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  flex: 1;
  gap: 8px;
  padding: 0 18px;
  color: white;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  box-shadow: 0 14px 28px rgba(63, 140, 255, 0.24);
}

.secondary-button {
  padding: 0 15px;
  color: var(--blue-strong);
  font-weight: 800;
  background: rgba(63, 140, 255, 0.12);
  text-decoration: none;
}

.nav-button {
  gap: 8px;
  white-space: nowrap;
}

.nav-button svg,
.secondary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.icon-button {
  width: 38px;
  height: 38px;
  min-height: 38px;
  flex: 0 0 auto;
  border: 1px solid rgba(63, 140, 255, 0.2);
  color: var(--blue-strong);
  background: rgba(255, 255, 255, 0.78);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.ghost {
  background: rgba(63, 140, 255, 0.1);
}

.icon-button.danger {
  color: var(--rose);
  border-color: rgba(217, 74, 106, 0.18);
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.icon-button:active {
  transform: translateY(0);
}

.list-panel {
  min-width: 0;
  padding: 20px;
}

.management-workspace {
  display: grid;
  gap: 22px;
}

.service-manager-panel {
  padding: 20px;
}

.manager-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.inline-actions {
  align-self: end;
  margin-top: 0;
}

.list-toolbar {
  margin-bottom: 16px;
}

.search-field {
  position: relative;
  width: min(100%, 390px);
}

.search-field svg {
  position: absolute;
  left: 13px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.search-field input {
  padding: 0 12px 0 40px;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
}

tbody tr {
  background: rgba(255, 255, 255, 0.36);
  transition: background 160ms ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.72);
}

.amount-cell {
  color: var(--blue-strong);
  font-weight: 850;
  white-space: nowrap;
}

.category-pill,
.payment-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
  word-break: break-word;
}

.category-pill {
  color: #14508f;
  background: rgba(63, 140, 255, 0.13);
}

.payment-pill {
  color: #0f6a5a;
  background: rgba(43, 191, 143, 0.14);
}

.subtle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.service-name-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.service-name-cell strong {
  font-size: 0.94rem;
  word-break: break-word;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

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

.payment-type-card {
  display: grid;
  min-height: 132px;
  align-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.66);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.payment-type-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 14px 28px rgba(63, 140, 255, 0.14);
}

.payment-type-card strong {
  font-size: 1.18rem;
}

.payment-type-card span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.payment-type-card b {
  color: var(--blue-strong);
}

.service-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
}

.service-meta {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.service-meta strong {
  font-size: 1rem;
  word-break: break-word;
}

.service-meta span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 260px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 76px;
  height: 76px;
  fill: rgba(63, 140, 255, 0.08);
  stroke: rgba(63, 140, 255, 0.44);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state p {
  margin: 0;
  font-weight: 800;
}

@media (max-width: 1080px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-side {
    width: 100%;
    min-width: 0;
  }

  .summary-strip {
    width: 100%;
    min-width: 0;
  }

  .form-panel {
    position: static;
  }

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

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

  .form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

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

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

  .topbar-side,
  .manager-grid,
  .payment-type-grid {
    grid-template-columns: 1fr;
  }

  .nav-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-button {
    width: 100%;
  }

  .summary-strip div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .summary-strip div:first-child {
    border-top: 0;
  }

  .field-grid,
  .list-toolbar {
    grid-template-columns: 1fr;
  }

  .list-toolbar {
    display: grid;
    align-items: stretch;
  }

  .search-field {
    width: 100%;
  }

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

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    clip: rect(0 0 0 0);
    overflow: hidden;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.74);
  }

  td {
    display: grid;
    grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    gap: 12px;
    padding: 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
  }

  td.actions-cell {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
  }

  td.actions-cell::before {
    content: none;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 12px;
  }

  .form-panel,
  .service-manager-panel,
  .list-panel {
    padding: 16px;
  }

  .topbar {
    gap: 16px;
  }

  .brand {
    align-items: flex-start;
  }

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

  .brand-mark svg {
    width: 25px;
    height: 25px;
  }

  h1 {
    font-size: 1.42rem;
  }

  td {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
