/* 張廣林形象设计工作室 · 工作台 */

:root {
  --bg: #f8f7f4;
  --bg-elevated: #ffffff;
  --ink: #1a1a1a;
  --text: #333333;
  --muted: #666666;
  --faint: #8a8680;
  --line: #e6e3db;
  --line-strong: #d4d0c8;
  --gold: #c9a86c;
  --gold-ink: #8d6d32;
  --gold-soft: #f3ead6;
  --gold-dim: rgba(201, 168, 108, 0.16);
  --success: #2f7d4a;
  --success-bg: #eaf6ef;
  --warning: #b56a10;
  --warning-bg: #fbf1e0;
  --danger: #b42318;
  --danger-bg: #fbeaea;
  --info: #215ea8;
  --info-bg: #e8f1fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.04), 0 10px 28px rgba(26, 26, 26, 0.05);
  --shadow-lg: 0 16px 48px rgba(26, 26, 26, 0.14);
  --header-h: 76px;
  --tab-h: 64px;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --font-num: "Outfit", "Helvetica Neue", system-ui, sans-serif;
  --focus: 0 0 0 3px rgba(201, 168, 108, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

img {
  max-width: 100%;
}

a {
  color: inherit;
}

.num,
.money,
.time,
.stat-value,
.balance-value {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* App shell */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  background: rgba(248, 247, 244, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  gap: 24px;
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 18%, var(--gold) 82%, transparent 100%);
  opacity: 0.7;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: none;
  background: var(--ink);
  color: #f8f4ea;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(201, 168, 108, 0.7);
  pointer-events: none;
}

.brand-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.08em;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--gold-ink);
  text-transform: none;
  margin-top: 2px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-nav button {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  position: relative;
  transition: color 0.15s ease, background 0.15s ease;
}

.top-nav button:hover {
  color: var(--ink);
  background: rgba(26, 26, 26, 0.04);
}

.top-nav button.is-active {
  color: var(--ink);
  font-weight: 600;
}

.top-nav button.is-active::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 2px;
  height: 1.5px;
  background: var(--gold);
}

.header-date {
  display: none;
  color: var(--faint);
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.view {
  display: none;
  animation: fadeUp 0.28s ease;
}

.view.is-active {
  display: block;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

.page-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold-ink);
  margin-bottom: 6px;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.page-desc {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  background: var(--ink);
  color: #f8f7f4;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  white-space: nowrap;
}

.btn:hover {
  background: #2a2a2a;
}

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

.btn:focus-visible,
.icon-btn:focus-visible,
.nav-link:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.search-field:focus-within {
  outline: none;
  box-shadow: var(--focus);
}

.btn-gold {
  background: var(--ink);
  color: #f8f4ea;
  box-shadow: inset 0 0 0 1px rgba(201, 168, 108, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}

.btn-ghost:hover {
  background: #fff;
  border-color: #c9c3b8;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #9b1c14;
}

.btn-text {
  background: none;
  border: 0;
  color: var(--gold-ink);
  padding: 8px 4px;
  min-height: auto;
  box-shadow: none;
}

.btn-text:hover {
  background: none;
  color: var(--ink);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
}

.icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}

.icon-btn:hover {
  color: var(--ink);
  border-color: #c9c3b8;
}

/* Cards & layout */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad {
  padding: 22px 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.stat-card {
  padding: 22px 24px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 2px;
  background: var(--gold);
  opacity: 0.85;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 10px;
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
}

.stat-foot {
  margin-top: 8px;
  font-size: 13px;
  color: var(--faint);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 28px 0 12px;
}

.section-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title h2::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--gold);
}

/* Lists */
.list {
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  color: inherit;
}

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

button.list-row {
  cursor: pointer;
}

button.list-row:hover,
.list-row.is-clickable:hover {
  background: #fcfbf8;
}

.list-row.is-today {
  background: linear-gradient(90deg, var(--gold-dim), transparent 180px);
}

.row-time {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}

.row-title {
  font-weight: 600;
  color: var(--ink);
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.row-side {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  white-space: nowrap;
}

.pill-pending,
.pill-待服务 {
  background: var(--info-bg);
  color: var(--info);
}

.pill-done,
.pill-已完成 {
  background: var(--success-bg);
  color: var(--success);
}

.pill-cancel,
.pill-已取消 {
  background: #f1f0ec;
  color: #6b6862;
}

.pill-noshow,
.pill-爽约 {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill-level,
.pill-demo {
  background: var(--gold-soft);
  color: var(--gold-ink);
}

.pill-demo {
  font-size: 11px;
}

.pill-warn {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Customer rows */
.customer-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

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

.customer-row:hover {
  background: #fcfbf8;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: #f4efe4;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 500;
  flex: none;
  position: relative;
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 108, 0.55);
}

.balance-value {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}

.balance-split {
  font-size: 12px;
  color: var(--faint);
  margin-top: 2px;
}

.low-balance .balance-value {
  color: var(--warning);
}

/* Search & filters */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 14px;
  min-height: 42px;
  min-width: 240px;
  flex: 1;
}

.search-field input {
  border: 0;
  background: none;
  outline: none;
  width: 100%;
  min-width: 0;
  box-shadow: none !important;
  padding: 8px 0;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  min-height: 34px;
}

.chip.is-active {
  background: var(--ink);
  color: #f8f7f4;
  border-color: var(--ink);
}

.date-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Empty */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
}

.empty p {
  margin-bottom: 16px;
}

.empty-title {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 6px;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row.span-2 {
  grid-column: 1 / -1;
}

.form-row label {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.req::after {
  content: " *";
  color: var(--danger);
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--ink);
  min-height: 42px;
  appearance: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%23666' stroke-width='1.4' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.help {
  font-size: 12px;
  color: var(--faint);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-ok {
  background: var(--success-bg);
  color: var(--success);
}

.alert-warn {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Typeahead */
.typeahead {
  position: relative;
}

.typeahead-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow: auto;
  z-index: 20;
  display: none;
}

.typeahead-menu.is-open {
  display: block;
}

.typeahead-item {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: inherit;
}

.typeahead-item:hover,
.typeahead-item.is-active {
  background: var(--gold-soft);
}

.selected-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* Modal / drawer */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.42);
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px 20px;
  overflow: auto;
}

.overlay.is-open {
  display: flex;
}

.modal {
  width: min(560px, 100%);
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
  position: relative;
  margin: auto 0;
}

.modal-wide {
  width: min(720px, 100%);
}

.modal-head {
  padding: 22px 24px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.06em;
}

.modal-body {
  padding: 20px 24px 8px;
}

.modal-foot {
  padding: 16px 24px 22px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-close {
  appearance: none;
  border: 0;
  background: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(26, 26, 26, 0.06);
  color: var(--ink);
}

/* Detail */
.detail-hero {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding-bottom: 16px;
}

.detail-balances {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
  margin: 8px 0 16px;
}

.mini-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.mini-stat .lbl {
  font-size: 12px;
  color: var(--faint);
}

.mini-stat .val {
  font-family: var(--font-num);
  font-size: 20px;
  margin-top: 4px;
  color: var(--ink);
}

.mini-stat.primary .val {
  color: var(--gold-ink);
  font-size: 24px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.tabs button {
  appearance: none;
  background: none;
  border: 0;
  padding: 10px 14px;
  color: var(--muted);
  position: relative;
}

.tabs button.is-active {
  color: var(--ink);
  font-weight: 600;
}

.tabs button.is-active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  background: var(--gold);
}

.record {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record:last-child {
  border-bottom: 0;
}

/* Settings */
.settings-block + .settings-block {
  margin-top: 16px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

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

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.inline-form input {
  flex: 1;
  min-width: 120px;
}

.danger-zone {
  border-color: #ead9d6;
}

.note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

/* Toast */
#toast-root {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}

.toast {
  pointer-events: auto;
  background: var(--ink);
  color: #f8f7f4;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: fadeUp 0.2s ease;
}

.toast-ok {
  box-shadow: var(--shadow-lg), inset 0 0 0 1px rgba(201, 168, 108, 0.45);
}

.toast-danger {
  background: var(--danger);
}

.toast-warn {
  background: #8a5610;
}

/* Mobile tab bar */
.tab-bar {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 40;
}

.tab-bar button {
  appearance: none;
  border: 0;
  background: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 11px;
  letter-spacing: 0.04em;
  min-height: var(--tab-h);
  padding: 8px 0 6px;
}

.tab-bar button svg {
  width: 20px;
  height: 20px;
}

.tab-bar button.is-active {
  color: var(--ink);
}

.tab-bar button.is-active svg {
  stroke: var(--gold-ink);
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

.grow {
  flex: 1;
}

.stack-8 {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 900px) {
  .header-date {
    display: block;
    margin-left: auto;
    margin-right: 8px;
  }
}

@media (max-width: 860px) {
  :root {
    --header-h: 62px;
  }

  .app-header {
    padding: 0 16px;
  }

  .top-nav,
  .header-date {
    display: none;
  }

  .brand-name {
    font-size: 14px;
    letter-spacing: 0.04em;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }

  .app-main {
    padding: 20px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom, 0px));
  }

  .tab-bar {
    display: flex;
  }

  .page-title {
    font-size: 22px;
  }

  .grid-3,
  .grid-2,
  .form-grid,
  .detail-balances,
  .customer-row {
    grid-template-columns: 1fr;
  }

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

  .customer-row .row-level {
    display: none;
  }

  .stat-value {
    font-size: 26px;
  }

  .overlay {
    padding: 0;
    align-items: stretch;
  }

  .modal,
  .modal-wide {
    width: 100%;
    min-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .list-row {
    grid-template-columns: 64px 1fr;
    gap: 10px;
  }

  .list-row .row-side {
    grid-column: 2;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .view,
  .toast {
    animation: none;
  }
}


/* Statement preview */
.statement-preview {
  background: #efece6;
  margin: 0 -24px;
  padding: 20px 16px 8px;
  display: flex;
  justify-content: center;
}
.statement-preview img {
  width: min(100%, 520px);
  height: auto;
  display: block;
  box-shadow: var(--shadow-lg);
  border-radius: 4px;
  background: #f8f7f4;
}
