:root {
  color-scheme: light;
  --bg: #f7f9fb;
  --panel: #ffffff;
  --panel-soft: #f0f5f8;
  --text: #18212b;
  --muted: #667789;
  --line: #dce5ea;
  --accent: #167c80;
  --accent-strong: #0c6368;
  --paid: #15803d;
  --warn: #a15c00;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(24, 33, 43, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(22, 124, 128, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
}

.boot {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--muted);
  font-size: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 4vw, 48px);
  background: rgba(247, 249, 251, 0.9);
  border-bottom: 1px solid rgba(220, 229, 234, 0.8);
  backdrop-filter: blur(14px);
}

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

.mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 22px;
  width: min(1240px, calc(100% - 32px));
  margin: 26px auto 48px;
}

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

.panel-header {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

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

.panel-header p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form {
  display: grid;
  gap: 16px;
  padding: 20px 22px 22px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.small-label {
  color: #354456;
  font-size: 13px;
  font-weight: 650;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid #cad7df;
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

.textarea {
  min-height: 84px;
  resize: vertical;
}

.input:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 124, 128, 0.14);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 122px;
  padding: 18px;
  border: 1px dashed #9eb3bf;
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: center;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-main {
  display: block;
  color: #1f3443;
  font-weight: 750;
}

.upload-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.file-preview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.preview-tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.preview-tile span {
  display: block;
  padding: 7px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recognition-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.recognition-card > img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.recognition-fields {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 8px;
  line-height: 1;
  white-space: nowrap;
}

.primary {
  background: var(--accent);
  color: white;
  font-weight: 750;
}

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

.secondary {
  background: #e5f1f1;
  color: var(--accent-strong);
  font-weight: 700;
}

.ghost {
  background: transparent;
  color: #314253;
  border: 1px solid var(--line);
}

.danger {
  background: #fef3f2;
  color: var(--danger);
  border: 1px solid #fecdca;
}

.bill-list {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.bill-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.bill-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bill-card h3 {
  margin: 0;
  font-size: 17px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.amount {
  font-size: 24px;
  font-weight: 850;
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.status.pending {
  background: #fff4df;
  color: var(--warn);
}

.status.paid {
  background: #dcfce7;
  color: var(--paid);
}

.status.partial {
  background: #e0f2fe;
  color: #075985;
}

.status.draft {
  background: #eef2f6;
  color: #475467;
}

.note-status-list {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-soft);
}

.note-status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  color: #354456;
  font-size: 13px;
}

.note-status-row span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty {
  padding: 34px 18px;
  color: var(--muted);
  text-align: center;
}

.customer-wrap {
  width: min(980px, calc(100% - 32px));
  margin: 26px auto 56px;
}

.bill-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bill-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.15;
}

.pay-box {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.pay-amount {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 900;
}

.content-band {
  margin-top: 18px;
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.pay-selection {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.pay-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pay-option input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.pay-option strong,
.pay-option small {
  display: block;
  overflow-wrap: anywhere;
}

.pay-option small {
  margin-top: 3px;
  color: var(--muted);
}

.partial-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #e5f1f1;
  color: var(--accent-strong);
}

.partial-summary strong {
  font-size: 22px;
}

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

.items-table th {
  color: var(--muted);
  font-size: 13px;
}

.items-table td:last-child,
.items-table th:last-child {
  text-align: right;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.note-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.note-card button {
  display: block;
  width: 100%;
  padding: 0;
  background: #f5f7f8;
}

.note-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.note-card-body {
  padding: 11px;
}

.note-card-body strong {
  display: block;
  overflow-wrap: anywhere;
}

.note-card-body span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 24, 35, 0.74);
}

.modal.open {
  display: flex;
}

.modal-inner {
  width: min(1020px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: white;
  border-radius: 8px;
}

.modal-bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.modal-img {
  display: block;
  width: 100%;
  height: auto;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: none;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #10212c;
  color: white;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

.notice {
  padding: 12px 14px;
  border: 1px solid #f6d7a7;
  border-radius: 8px;
  background: #fff8eb;
  color: #765313;
  line-height: 1.55;
}

@media (max-width: 880px) {
  .layout,
  .bill-hero {
    grid-template-columns: 1fr;
  }

  .pay-box {
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions,
  .card-actions {
    width: 100%;
  }

  .primary,
  .secondary,
  .ghost,
  .danger {
    flex: 1 1 auto;
  }

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

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

  .amount {
    text-align: left;
  }

  .bill-card-top {
    flex-direction: column;
  }

  .note-status-row,
  .pay-option {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .note-status-row strong,
  .note-status-row .status,
  .pay-option b {
    grid-column: 2;
  }
}
