:root {
  /* 豆沙色 / red bean theme - softened for long daily use */
  --comfort-bg: #f6f1ef;
  --soft-surface: #fffdfb;
  --soft-accent: #9b6470;
  --soft-accent-bg: #f3dce1;
  --bg: var(--comfort-bg);
  --panel: #fffaf8;
  --panel-strong: #ffffff;
  --ink: #2a1f22;
  --muted: #74646a;
  --line: #eadbdd;
  --brand: #8f4f5f;
  --brand-2: #c08a96;
  --sales: #8f4850;
  --sales-bg: #f8e5ea;
  --store: #4f715b;
  --store-bg: #e9f3ec;
  --system: #5f627b;
  --system-bg: #ebeef8;
  --payment: #9a5a35;
  --payment-bg: #f8eadf;
  --task: #775995;
  --task-bg: #f0e9f8;
  --qr: #2f7378;
  --qr-bg: #e4f3f4;
  --photo: #9a4f75;
  --photo-bg: #f7e5ef;
  --warning-bg: #fff3cd;
  --ok: #4f7a5a;
  --warn: #9f6508;
  --danger: #a33a30;
  --shadow: 0 18px 50px rgba(78, 37, 48, .10);
}

* { box-sizing: border-box; }
html, body, #app { max-width: 100%; overflow-x: hidden; }
img, video, canvas, table { max-width: 100%; }
body, .card, .task-card, .cs-card, .modal-card, .calendar-day-item { overflow-wrap: anywhere; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(192,138,150,.23), transparent 34%), var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
.open-helper { display: grid; place-items: center; min-height: 100vh; text-align: center; padding: 24px; }
.primary-link, .btn.primary { background: var(--brand); color: #fff; text-decoration: none; border-radius: 999px; padding: 12px 18px; display: inline-flex; align-items: center; gap: 8px; }
.btn { background: #efe3d5; color: var(--ink); border-radius: 12px; padding: 9px 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 7px; line-height: 1.15; min-width: 0; text-align: center; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: #ffe4df; color: var(--danger); }
.btn.small { padding: 7px 10px; font-size: 12px; }
.login-page { background: radial-gradient(circle at 12% 12%, rgba(192,138,150,.28), transparent 30%), radial-gradient(circle at 88% 18%, rgba(143,79,95,.18), transparent 34%), linear-gradient(135deg, #f7f1ef, #fffaf5 58%, #f0e1df); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(520px, 100%); background: rgba(255,250,244,.94); border: 1px solid var(--line); border-radius: 28px; padding: 26px; box-shadow: var(--shadow); }
.login-card-wide { width: min(980px, 100%); }
.login-polish .login-card { padding: 24px; backdrop-filter: blur(18px); box-shadow: 0 26px 80px rgba(78,37,48,.14); }
.login-brand-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.login-brand-row .logo { margin-bottom: 0; }
.login-brand-row h1 { letter-spacing: 0; }
.login-lang-toggle { min-width: 72px; white-space: nowrap; }
.login-intro { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(300px, .72fr); gap: 18px; align-items: stretch; }
.login-form-panel { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: 0 14px 36px rgba(78,37,48,.08); }
.login-panel-head h3 { font-size: 24px; margin-top: 8px; }
.login-panel-head p { margin: 6px 0 12px; }
.login-submit { width: 100%; min-height: 48px; margin-top: 8px; }
.login-choice-row { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 14px; background: #fff8f6; padding: 10px 12px; color: var(--muted); font-size: 12px; font-weight: 850; line-height: 1.35; }
.login-choice-row input { width: auto; min-width: 16px; }
.auth-debug-message { border: 1px solid #f3d19a; background: #fff7e8; color: #7a4c00; border-radius: 16px; padding: 10px 12px; font-size: 12px; font-weight: 850; line-height: 1.45; }
.login-role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.login-role-chip { border: 1px solid var(--line); border-radius: 16px; background: #fff8f6; padding: 10px; text-align: left; display: grid; gap: 2px; color: var(--ink); }
.login-role-chip b { font-size: 13px; }
.login-role-chip span { color: var(--muted); font-size: 11px; font-weight: 850; }
.login-role-chip.active { border-color: var(--brand); background: var(--soft-accent-bg); box-shadow: inset 0 0 0 1px rgba(143,79,95,.2); }
.login-trust-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.login-trust-row span { border: 1px solid rgba(255,255,255,.36); border-radius: 999px; padding: 8px 10px; background: rgba(255,255,255,.22); color: #fff7f7; font-size: 12px; font-weight: 900; }

.login-auth-note { display: grid; gap: 4px; margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 16px; background: #fff8ef; color: var(--muted); font-size: 12px; line-height: 1.45; }
.login-auth-note b { color: var(--brand); font-size: 12px; }
.compact-login-card { width: min(520px, 100%); }
.compact-login-form { display: grid; gap: 12px; }
.security-banner { border: 1px solid #f3d19a; background: #fff7e8; color: #7a4c00; border-radius: 14px; padding: 9px 11px; font-size: 12px; font-weight: 850; max-width: 360px; }
.app-version-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border: 1px solid #f3b8a8; background: #fff2ee; color: #823329; border-radius: 14px; padding: 8px 10px; font-size: 12px; font-weight: 850; max-width: min(640px, 100%); }
.app-version-banner span { color: #6f575b; }
.app-version-banner .btn { min-height: 30px; padding: 5px 9px; }
.admin-switcher { width: clamp(180px, 24vw, 240px); display: grid; gap: 5px; align-items: center; margin: 0; }
.admin-switcher span { color: var(--muted); font-size: 10px; font-weight: 950; text-transform: none; letter-spacing: 0; }
.admin-switcher select { min-height: 42px; padding: 8px 32px 8px 12px; font-size: 13px; font-weight: 850; border-radius: 16px; background: rgba(255,255,255,.92); box-shadow: 0 8px 22px rgba(42,31,34,.05); }
.topbar-actions .btn.danger { min-height: 58px; padding: 0 14px; border-radius: 14px; background: #ffe5df; }
.topbar-actions .lang-icon { min-height: 58px; border-radius: 14px; background: rgba(255,255,255,.82); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading p { max-width: 520px; margin: 4px 0 0; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.logo-mark { width: 46px; height: 46px; border-radius: 16px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 900; }
.kicker { text-transform: none; color: var(--brand); letter-spacing: 0; font-size: 12px; font-weight: 900; }
h1, h2, h3 { margin: 0; }
p { color: var(--muted); line-height: 1.55; }
.field { display: grid; gap: 7px; margin: 12px 0; }
.field span, .label { color: var(--muted); font-size: 13px; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 12px; color: var(--ink); }
textarea { min-height: 88px; resize: vertical; }
.field-hint { font-size: 11px; color: var(--brand); font-style: normal; }
.readonly-field, input:disabled, select:disabled, textarea:disabled { background: #f3f0f1; color: #6d5960; border-color: #d7c3c9; }
.locked-field { border: 1px dashed #d7c3c9; border-radius: 16px; padding: 8px; background: repeating-linear-gradient(135deg, #f8f1f3, #f8f1f3 8px, #f1e7ea 8px, #f1e7ea 16px); }
.payment-type-locked-field select[data-payment-type-locked="deposit-split"] { pointer-events: none; cursor: not-allowed; user-select: none; }
.payment-type-locked-field select[data-payment-type-locked="deposit-split"]:focus { outline: 0; box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { background: rgba(255,250,244,.88); border-right: 1px solid var(--line); padding: 18px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side-nav { display: grid; gap: 4px; margin-top: 10px; }
.nav-btn { text-align: left; border-radius: 12px; padding: 9px 10px; background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; display: flex; align-items: center; gap: 9px; }
.nav-icon { width: 22px; height: 22px; display: inline-grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.72); font-size: 14px; }
.nav-btn.active, .nav-btn:hover { background: #efe3d5; color: var(--ink); }
.main { padding: 18px; min-width: 0; }
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: start; margin-bottom: 18px; }
.topbar-title { display: grid; gap: 8px; align-content: start; min-width: 0; }
.topbar-title h1 { font-size: clamp(28px, 3vw, 42px); line-height: 1.02; letter-spacing: 0; margin: 0; }
.topbar-title .badge { width: auto; max-width: max-content; }
.topbar-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-start; min-width: 0; }
.env-badge { background: #eaf6f7; color: #2e6f78; border: 1px solid #cce7ea; }
.env-badge-local { background: #fff3d7; color: #7a4d12; border-color: #f2d7a0; }
.env-badge-staging { background: #e9efff; color: #355199; border-color: #cbd7ff; }
.backend-badge, .backend-badge-production { background: #fff0e8; color: #9a3f2e; border: 1px solid #f3cabb; max-width: 100%; }
.backend-badge-staging { background: #e9efff; color: #355199; border-color: #cbd7ff; } .backend-badge-local { background: #fff3d7; color: #7a4d12; border-color: #f2d7a0; }
.topbar-title .security-banner { max-width: min(560px, 100%); }
.topbar-title .app-version-banner { margin-top: 6px; }
.smoke-environment-notice { display: grid; gap: 3px; padding: 10px 12px; margin: 10px 0; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72); color: var(--ink); }
.smoke-environment-notice b { color: var(--brand); } .smoke-environment-notice :is(span, small) { color: var(--muted); line-height: 1.35; } .smoke-environment-notice.is-warning { background: #fff6ec; border-color: #f0c59e; }
.topbar-actions { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: 8px; justify-content: end; align-items: end; min-width: 0; }
.lang-icon { width: 44px; height: 42px; padding: 0; display: inline-grid; grid-template-rows: 22px 12px; place-items: center; line-height: 1; }
.lang-icon span { font-size: 17px; }
.lang-icon b { font-size: 10px; letter-spacing: 0; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px; background: var(--soft-accent-bg); color: var(--brand); font-weight: 900; font-size: 12px; }
.badge.badge-role-admin, .badge.badge-role-management, .badge.badge-role-manager, .badge.badge-role-sales, .badge.badge-role-supervisor, .badge.badge-role-store { background: var(--soft-accent-bg); color: var(--brand); }
.badge.module-sales, .badge.badge-sales { background: var(--sales-bg); color: var(--sales); }
.badge.module-store, .badge.badge-store { background: var(--store-bg); color: var(--store); }
.badge.module-system, .badge.badge-system { background: var(--system-bg); color: var(--system); }
.badge.module-payment { background: var(--payment-bg); color: var(--payment); }
.badge.module-task { background: var(--task-bg); color: var(--task); }
.badge.module-qr { background: var(--qr-bg); color: var(--qr); }
.badge.module-photo { background: var(--photo-bg); color: var(--photo); }
.badge.module-audit { background: #fff0e8; color: #b5532d; }
.card { background: rgba(255,250,244,.92); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 8px 28px rgba(54,39,25,.06); }
.card + .card { margin-top: 14px; }
.split-records { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.page-note { margin: 0 0 10px; font-size: 12px; font-weight: 800; color: var(--muted); }
.full-record { min-width: 260px; line-height: 1.55; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.stat b { display: block; font-size: 26px; margin-top: 4px; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.deleted-records-list .is-deleted-record { opacity: 0.76; background: repeating-linear-gradient(135deg, rgba(163,58,48,.055), rgba(163,58,48,.055) 8px, rgba(255,255,255,.78) 8px, rgba(255,255,255,.78) 16px); }
.deleted-records-list .details-row .detail-panel { opacity: 0.92; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 11px; border-bottom: 1px solid #f0e6dc; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; background: #fff8ef; }
.empty { padding: 22px; text-align: center; color: var(--muted); }
.confirm-box { border: 1px dashed var(--brand-2); background: #fff8ef; border-radius: 18px; padding: 14px; margin: 14px 0; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { min-height: 96px; border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 8px; }
.day.out { opacity: .45; }
.day-number { font-weight: 900; margin-bottom: 5px; }
.event { font-size: 12px; border-radius: 9px; padding: 4px 6px; margin: 4px 0; background: #efe3d5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event.company { background: var(--system-bg); }
.event.personal { background: var(--store-bg); }
.event.record { background: var(--payment-bg); }
.role-matrix { display: grid; gap: 12px; }
.permission-row { display: grid; grid-template-columns: 190px repeat(6, minmax(78px, 1fr)); gap: 8px; align-items: center; padding: 8px; border-radius: 13px; background: #fff; border: 1px solid var(--line); }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; background: #1f1a16; color: #fff; border-radius: 16px; padding: 13px 16px; box-shadow: var(--shadow); z-index: 20; }
.toast-danger { background: #8f2f3d; }
.toast-warning { background: #876021; }
.toast-success { background: #2f6f4a; }
.record-draft-toast { display: flex; align-items: center; gap: 12px; max-width: min(460px, calc(100vw - 24px)); }
.record-draft-toast button { border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(255,255,255,.12); color: #fff; min-height: 34px; padding: 6px 10px; font-weight: 850; cursor: pointer; white-space: nowrap; }
.photo-list { color: var(--muted); font-size: 12px; margin-top: 6px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 18px; background: rgba(42,31,34,.48); backdrop-filter: blur(8px); }
.modal-card { width: min(760px, 100%); max-width: calc(100vw - 24px); max-height: min(88vh, 820px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 18px; box-shadow: 0 30px 80px rgba(42,31,34,.28); }
.modal-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.modal-head p { margin: 6px 0 0; }
.modal-actions { justify-content: flex-end; }
.kk-confirm-card { width: min(440px, calc(100vw - 28px)); }
.kk-confirm-head p { margin: 6px 0 0; color: var(--ink); font-weight: 750; line-height: 1.45; }
.kk-confirm-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.kk-confirm-actions .btn { min-height: 48px; }
form.is-submitting { cursor: progress; }
form.is-submitting button[type="submit"] { opacity: .78; pointer-events: none; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; grid-auto-flow: row; grid-template-columns: minmax(0, 1fr) auto auto; justify-content: stretch; align-items: end; }
  .admin-switcher { width: 100%; }
  .stats, .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-intro, .split-records { grid-template-columns: 1fr; }
  .login-brand-row { align-items: flex-start; }
  .section-heading { align-items: start; flex-direction: column; }
  .permission-row { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 560px) {
  .main, .sidebar { padding: 12px; }
  .login-shell { padding: 12px; align-items: start; }
  .login-polish .login-card { padding: 16px; border-radius: 22px; }
  .login-card, .card { border-radius: 20px; padding: 15px; }
  .login-role-grid { grid-template-columns: 1fr; }
  .secure-login-note { min-height: auto; padding: 22px; }
  .grid-2, .grid-3, .grid-4, .stats, .side-nav { grid-template-columns: 1fr; }
  .calendar { gap: 4px; }
  .day { min-height: 78px; padding: 5px; border-radius: 10px; }
  .event { font-size: 10px; }
}
