/* 業配名單系統：淺色主題。每個元件都自訂樣式，不使用瀏覽器預設外觀。 */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f0f2f7;
  --border: #e5e8ef;
  --border-strong: #d4d9e3;
  --text: #1a1f2e;
  --text-2: #464e63;
  --muted: #7c8497;
  --primary: #5048e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --primary-soft-2: #e0e3ff;
  --ring: rgba(80, 72, 229, .2);
  --ok: #138a4f;
  --ok-soft: #e7f6ee;
  --warn: #a35a00;
  --warn-soft: #fff4e0;
  --err: #d0302f;
  --err-soft: #fdeceb;
  --info: #2160d8;
  --info-soft: #e9f1ff;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-md: 0 6px 16px rgba(17, 24, 39, .08);
  --shadow-lg: 0 18px 48px rgba(17, 24, 39, .16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
::selection { background: var(--primary-soft-2); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 24px; line-height: 1.3; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; line-height: 1.4; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 650; margin: 0 0 8px; color: var(--text); }
p { margin: 0 0 10px; }
ul, ol { margin: 0; padding-left: 20px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); color: var(--text-2); padding: 1px 6px; border-radius: 6px; }
pre { margin: 0; }
img, svg { vertical-align: middle; }
.icon { flex: none; }
[hidden] { display: none !important; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: #c9cfdb transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd4de; border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b4bbc9; border: 3px solid transparent; background-clip: content-box; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 14px 14px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 18px; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6d5efc 0%, #4f46e5 55%, #3b82f6 100%); box-shadow: 0 4px 12px rgba(80, 72, 229, .35);
}
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.brand small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .04em; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text-2);
  font-weight: 500; position: relative;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav a.active .icon { color: var(--primary); }
.nav .nav-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 3px #fff3d6; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.mailbox-pill {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 10px; font-size: 12.5px;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); min-width: 0;
}
.mailbox-pill:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.mailbox-pill .status-dot { flex: none; }
.mailbox-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mailbox-pill b { display: block; font-weight: 600; color: var(--text); }
.mailbox-pill.warn { background: var(--warn-soft); border-color: #f6dcae; color: var(--warn); }
.mailbox-pill.warn b { color: var(--warn); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.status-dot.ok { background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }
.status-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px #fef3c7; }
.status-dot.err { background: #ef4444; box-shadow: 0 0 0 3px #fee2e2; }
.status-dot.run { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); animation: pulse 1.4s ease-in-out infinite; }
.logout-btn { width: 100%; justify-content: flex-start; color: var(--muted); }

.main { flex: 1; min-width: 0; }
.container { max-width: 1280px; margin: 0 auto; padding: 28px 32px 80px; }
.mobile-bar { display: none; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.page-head .eyebrow a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 18px 22px 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: 9px; }
.card-head .hint { font-weight: 400; }
.card-title-icon {
  width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
  background: var(--primary-soft); color: var(--primary);
}
.card-title-icon.ok { background: var(--ok-soft); color: var(--ok); }
.card-title-icon.warn { background: var(--warn-soft); color: var(--warn); }
.card-sub { color: var(--muted); font-size: 13px; margin: -8px 0 16px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--text-2); margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; margin: 4px 0 18px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- buttons */
.btn {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: #c3cad6; color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(80, 72, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); box-shadow: none; }
.btn.soft:hover { background: var(--primary-soft-2); color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: var(--err-soft); border-color: #f3c3c1; color: var(--err); }
.btn.danger.solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger.solid:hover { background: #b42524; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.small { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn.small .icon { width: 14px; height: 14px; }
.btn.large { height: 46px; padding: 0 22px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 38px; padding: 0; }
.btn.small.icon-only { width: 32px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.btn.is-loading { pointer-events: none; opacity: .85; }
.btn.is-loading::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
.btn.is-loading .icon { display: none; }
.link-btn { -webkit-appearance: none; appearance: none; background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
form.inline { display: inline-flex; margin: 0; }

/* ---------------------------------------------------------------- form controls */
.field { margin-bottom: 16px; min-width: 0; }
.field > label, .label { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 7px; }
.field .req { color: var(--err); }
.hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.field > .hint { margin-top: 6px; display: block; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-top: 6px; }

input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], input[type=search], select, textarea {
  -webkit-appearance: none; appearance: none; width: 100%; height: 40px; padding: 0 12px; margin: 0;
  border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text);
  font: 14px/1.4 var(--font); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.65; resize: vertical; }
textarea.tall { min-height: 280px; }
textarea.short { min-height: 70px; }
input::placeholder, textarea::placeholder { color: #a3aab8; opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: #bfc6d3; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); outline: none; }
input[readonly], textarea[readonly] { background: var(--surface-2); color: var(--text-2); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; box-shadow: none; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--err); box-shadow: 0 0 0 3px rgba(208, 48, 47, .12); }
.field-error { display: flex; align-items: center; gap: 5px; color: var(--err); font-size: 12.5px; margin-top: 6px; }
.field-error .icon { width: 14px; height: 14px; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 1000px #fff inset; transition: background-color 9999s;
}
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=search]::-webkit-search-decoration, input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* select: custom arrow; Chromium also gets a custom drop-down list */
select {
  padding-right: 38px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237c8497' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
@supports (appearance: base-select) {
  select { appearance: base-select; display: flex; align-items: center; }
  select::picker-icon { display: none; }
  ::picker(select) {
    appearance: base-select; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
    box-shadow: var(--shadow-lg); padding: 6px; margin-top: 6px; max-height: 320px;
  }
  select option { padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--text); gap: 8px; }
  select option:hover, select option:focus-visible { background: var(--surface-3); outline: none; }
  select option:checked { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  select option::checkmark { order: 1; margin-left: auto; content: "✓"; color: var(--primary); }
}

/* checkbox & radio */
input[type=checkbox], input[type=radio] {
  -webkit-appearance: none; appearance: none; flex: none; width: 18px; height: 18px; margin: 0; cursor: pointer;
  border: 1.5px solid #b8c0cf; background: var(--surface) center / 12px no-repeat; vertical-align: middle;
  transition: background-color .12s, border-color .12s, box-shadow .12s;
}
input[type=checkbox] { border-radius: 5px; }
input[type=radio] { border-radius: 50%; }
input[type=checkbox]:hover, input[type=radio]:hover { border-color: var(--primary); }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-color: var(--primary); }
input[type=checkbox]:checked {
  background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
input[type=checkbox]:indeterminate {
  background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}
input[type=radio]:checked { border-color: var(--primary); border-width: 5.5px; }
input[type=checkbox]:disabled, input[type=radio]:disabled { background-color: var(--surface-3); border-color: var(--border-strong); cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; color: var(--text); user-select: none; }
.check.top { align-items: flex-start; }
.check.top input { margin-top: 2px; }
.check small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 1px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.checks.col { flex-direction: column; gap: 12px; }

/* switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; user-select: none; }
.field > label.switch { flex-wrap: nowrap; align-items: flex-start; gap: 12px; font-weight: 400; margin-bottom: 0; }
.field > label.check { display: inline-flex; flex-wrap: nowrap; align-items: center; gap: 9px; font-weight: 500; margin-bottom: 0; }
.switch input[type=checkbox] {
  width: 38px; height: 22px; border-radius: 99px; border: 0; background: #cdd3de; position: relative; margin-top: 1px;
  background-image: none !important; transition: background-color .18s;
}
.switch input[type=checkbox]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(17, 24, 39, .25); transition: transform .18s;
}
.switch input[type=checkbox]:checked { background-color: var(--primary); }
.switch input[type=checkbox]:checked::after { transform: translateX(16px); }
.switch input[type=checkbox]:disabled { background-color: var(--surface-3); }
.switch input[type=checkbox]:disabled::after { box-shadow: none; background: #e9ecf2; }
.switch .switch-text b { display: block; font-weight: 600; color: var(--text); }
.switch .switch-text small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.switch-list { display: flex; flex-direction: column; gap: 14px; }
.switch-list .switch { padding-bottom: 14px; border-bottom: 1px dashed var(--border); }
.switch-list .switch:last-child { border-bottom: 0; padding-bottom: 0; }

/* pill toggles: <label class="pill"><input type="checkbox"><span>…</span></label> */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { position: relative; display: inline-flex; cursor: pointer; }
.pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pill span {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 13px; transition: all .12s; user-select: none;
}
.pill span::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #b8c0cf; background: #fff center / 10px no-repeat;
  transition: all .12s; flex: none;
}
.pill:hover span { border-color: #b4bccb; color: var(--text); }
.pill input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.pill input:checked + span::before {
  background-color: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.pill input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }
.pill input:disabled + span { opacity: .5; cursor: not-allowed; }

/* radio cards: <label class="choice"><input type="radio"><span class="choice-body">…</span></label> */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice-body {
  display: flex; flex-direction: column; gap: 3px; height: 100%; padding: 13px 14px 13px 42px; border: 1.5px solid var(--border);
  border-radius: 12px; background: var(--surface); transition: all .12s; position: relative;
}
.choice-body::before {
  content: ""; position: absolute; left: 14px; top: 15px; width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid #b8c0cf; background: #fff; transition: all .12s;
}
.choice-body b { font-weight: 650; color: var(--text); }
.choice-body small { color: var(--muted); font-size: 12.5px; }
.choice:hover .choice-body { border-color: #bfc6d3; }
.choice input:checked + .choice-body { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--ring); }
.choice input:checked + .choice-body::before { border: 5.5px solid var(--primary); }
.choice input:focus-visible + .choice-body { box-shadow: 0 0 0 3px var(--ring); }

/* file picker */
.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  padding: 26px 18px; border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2);
  cursor: pointer; transition: all .15s; position: relative; color: var(--text-2);
}
.file-drop:hover, .file-drop.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.file-drop:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.file-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop .file-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--primary); box-shadow: var(--shadow); }
.file-drop b { color: var(--text); }
.file-drop .file-name { font-size: 12.5px; color: var(--muted); }
.file-drop.has-file .file-name { color: var(--ok); font-weight: 600; }

/* disclosure */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }
.disclosure { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); margin-bottom: 16px; }
.disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 11px 14px; font-weight: 600; font-size: 13px; color: var(--text-2); user-select: none; }
.disclosure > summary .icon { transition: transform .15s; color: var(--muted); }
.disclosure[open] > summary .icon.chev { transform: rotate(90deg); }
.disclosure > summary:hover { color: var(--text); }
.disclosure > summary small { font-weight: 400; color: var(--muted); }
.disclosure > .disclosure-body { padding: 4px 14px 14px; }
.disclosure.plain { background: transparent; border: 0; margin: 0; }
.disclosure.plain > summary { padding: 6px 0; }
.disclosure.plain > .disclosure-body { padding: 8px 0 0; }

/* a whole card that folds open */
.card.fold { padding: 0; }
.card.fold > summary { display: flex; align-items: center; gap: 9px; padding: 16px 22px; font-weight: 650; font-size: 15px; color: var(--text); user-select: none; border-radius: var(--radius-lg); }
.card.fold > summary:hover { background: var(--surface-2); }
.card.fold > summary .chev { color: var(--muted); transition: transform .15s; }
.card.fold[open] > summary .chev { transform: rotate(90deg); }
.card.fold[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card.fold > .fold-body { padding: 18px 22px 20px; }

/* drop-down menu: <details class="menu"><summary class="btn">…</summary><div class="menu-list">…</div></details> */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 30; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px;
  display: flex; flex-direction: column; gap: 1px; animation: pop .12s ease-out;
}
.menu-list.up { top: auto; bottom: calc(100% + 6px); }
.menu-list form { display: block; margin: 0; }
.menu-item {
  -webkit-appearance: none; appearance: none; display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--text); font: 500 13.5px/1.3 var(--font); cursor: pointer; text-align: left;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-item:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.menu-item.danger, .menu-item.danger .icon { color: var(--err); }
.menu-item.danger:hover { background: var(--err-soft); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---------------------------------------------------------------- feedback */
.flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px;
  border: 1px solid; font-weight: 500; animation: drop .2s ease-out; box-shadow: var(--shadow-sm);
}
.flash .icon { margin-top: 1px; }
.flash .flash-text { flex: 1; }
.flash.ok { background: var(--ok-soft); border-color: #bfe6cf; color: #0d6b3d; }
.flash.toast {
  position: fixed; top: 14px; left: calc(50% + var(--sidebar-w) / 2); translate: -50% 0; z-index: 95;
  width: min(460px, calc(100vw - 36px)); margin: 0; box-shadow: var(--shadow-lg); animation: toast-in .22s ease-out;
}
.flash.toast.ok { background: #f2fbf5; }
.flash.toast.err { background: #fff5f4; }
.flash.err { background: var(--err-soft); border-color: #f5c6c4; color: #a42221; }
.flash-close { -webkit-appearance: none; appearance: none; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; padding: 2px; border-radius: 6px; display: grid; }
.flash-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: #8a4b00; margin-bottom: 16px; border: 1px solid #f5dfb5; }
.notice .icon { margin-top: 1px; flex: none; }
.notice.info { background: var(--info-soft); color: #1b4fb0; border-color: #cfe0ff; }
.notice.ok { background: var(--ok-soft); color: #0d6b3d; border-color: #bfe6cf; }
.notice.err { background: var(--err-soft); color: #a42221; border-color: #f5c6c4; }
.notice a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.notice > div { flex: 1; min-width: 0; }

/* tooltip: data-tip="…" */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 40;
  width: max-content; max-width: 260px; padding: 6px 10px; border-radius: 8px; background: #1f2433; color: #fff;
  font: 500 12px/1.45 var(--font); white-space: normal; text-align: left; pointer-events: none; box-shadow: var(--shadow-md);
}
.tip-wrap { display: inline-flex; }

/* badges & chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px;
  font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.accent { background: var(--primary-soft); color: var(--primary); }
.badge.info { background: var(--info-soft); color: var(--info); }
a.badge:hover { text-decoration: none; filter: brightness(.97); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 99px; background: var(--surface-3); border: 1px solid transparent; font: 500 12.5px/1.4 var(--font); color: var(--text-2);
}
.chip.ai { background: var(--primary-soft); color: var(--primary); }
.chip.ai .icon { width: 12px; height: 12px; }
button.chip { cursor: pointer; border-color: var(--border); background: var(--surface); }
button.chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.tag-region { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }

/* platforms */
.pf { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 12px; }
.pf::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: currentColor; }
.pf-instagram { color: #d6246e; }
.pf-tiktok { color: #111827; }
.pf-facebook { color: #1b6ff2; }
.pf-threads { color: #374151; }
.pf-youtube { color: #e11d2a; }

/* ---------------------------------------------------------------- data display */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 15px 16px; box-shadow: var(--shadow-sm); display: flex; gap: 12px; align-items: center; }
.stat-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-icon.err { background: var(--err-soft); color: var(--err); }
.stat .n { font-size: 21px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 12.5px; }
.stats.compact .stat { padding: 12px 14px; }
.stats.compact .stat .n { font-size: 19px; }

.table-wrap { overflow-x: auto; border-radius: inherit; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th {
  font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  white-space: nowrap; letter-spacing: .02em;
}
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: #fafbfe; }
.table tbody tr.is-selected td, .table tbody tr.is-selected:hover td { background: var(--primary-soft); }
.table td.top { vertical-align: top; }
.table .check-col { width: 44px; }
.table .actions { flex-wrap: nowrap; }
.card > .table-wrap { margin: 0 -24px -22px; border-top: 1px solid var(--border); }
.card.flush > .table-wrap { margin: 0; border-top: 1px solid var(--border); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.list-item .meta { font-size: 12.5px; color: var(--muted); }

.who { display: flex; align-items: center; gap: 11px; min-width: 170px; }
.who-text { min-width: 0; }
.who b { display: block; font-weight: 650; color: var(--text); line-height: 1.35; }
.who b a { color: var(--text); }
.who b a:hover { color: var(--primary); }
.who .handle { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.who .handle a { color: var(--muted); display: inline-grid; }
.who .handle a:hover { color: var(--primary); }
.avatar {
  --h: 240; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 14px;
  background: hsl(var(--h) 70% 94%); color: hsl(var(--h) 55% 38%);
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

.score {
  display: inline-grid; place-items: center; width: 44px; height: 30px; border-radius: 9px; font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.score.high { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.low { background: var(--surface-3); color: var(--muted); }

.reasons { list-style: none; margin: 0; padding: 0; }
.reasons li { padding-left: 18px; position: relative; font-size: 13px; line-height: 1.55; margin-bottom: 3px; color: var(--text-2); }
.reasons li::before { position: absolute; left: 0; top: 0; font-weight: 700; }
.reasons li.plus::before { content: "＋"; color: var(--ok); }
.reasons li.minus::before { content: "－"; color: var(--err); }
.reasons li.info::before { content: "・"; color: var(--muted); }
.reasons li.ai { color: var(--text); }
.reasons li.ai::before { content: "AI"; font-size: 9.5px; color: #fff; background: var(--primary); border-radius: 4px; padding: 0 3px; top: 3px; line-height: 14px; }
.reasons .extra { display: none; }
.reasons.open .extra { display: list-item; }
.toggle-reasons { -webkit-appearance: none; appearance: none; font: 600 12px var(--font); cursor: pointer; color: var(--primary); background: none; border: 0; padding: 2px 0; }

.kv { display: grid; grid-template-columns: 112px 1fr; gap: 9px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; color: var(--text); }
.bio { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); padding: 11px 13px; border-radius: 10px; font-size: 13px; color: var(--text-2); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--primary-soft); color: var(--primary); }
.empty h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }

.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > div {
  height: 100%; border-radius: 99px; background: linear-gradient(90deg, #6d5efc, var(--primary)); transition: width .4s;
  background-size: 28px 28px;
}
.progress.running > div { background-image: linear-gradient(45deg, rgba(255,255,255,.22) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.22) 50%, rgba(255,255,255,.22) 75%, transparent 75%), linear-gradient(90deg, #6d5efc, var(--primary)); animation: stripes 1s linear infinite; }
.progress.lg { height: 12px; }
.progress.ok > div { background: linear-gradient(90deg, #34c27a, var(--ok)); }
pre.log {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: 12px/1.6 var(--mono);
  color: var(--text-2); max-height: 220px; overflow: auto; white-space: pre-wrap; margin-top: 10px;
}
.preview-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); white-space: pre-wrap; font-size: 13.5px; line-height: 1.75; color: var(--text); word-break: break-word; }
.preview-subject { font-weight: 700; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.mail-frame { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fff; }
.mail-frame-head { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.mail-frame-head b { color: var(--text); font-weight: 600; }
.mail-frame-body { padding: 16px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.8; word-break: break-word; }
.dm-bubble { background: var(--surface-3); border-radius: 16px 16px 16px 4px; padding: 12px 14px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.7; word-break: break-word; }

/* steps (dashboard quick start, campaign flow) */
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.step { border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; position: relative; }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-3); color: var(--text-2); }
.step.done { border-color: #c6e9d5; background: linear-gradient(180deg, #f6fcf8, #fff); }
.step.done .step-num { background: var(--ok); color: #fff; }
.step.current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.step.current .step-num { background: var(--primary); color: #fff; }
.step b { font-size: 14.5px; }
.step p { color: var(--muted); font-size: 12.5px; margin: 0; flex: 1; }
.step .btn { align-self: flex-start; margin-top: 4px; }

.flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.flow-step { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); }
.flow-step i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; }
.flow-step.done { color: var(--ok); border-color: #c6e9d5; }
.flow-step.done i { background: var(--ok); color: #fff; }
.flow-step.current { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.flow-step.current i { background: var(--primary); color: #fff; }
.flow-sep { color: #c3c9d5; }

/* sticky selection bar */
.bulk-bar {
  position: sticky; bottom: 16px; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 16px 0 0; padding: 10px 12px 10px 18px; border-radius: 14px; background: #1f2433; color: #fff; box-shadow: var(--shadow-lg);
  animation: rise .18s ease-out;
}
.bulk-bar .count { font-weight: 600; }
.bulk-bar .count b { font-size: 16px; }
.bulk-bar .btn:not(.primary) { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: #fff; box-shadow: none; }
.bulk-bar .btn:not(.primary):hover { background: rgba(255,255,255,.16); }
.bulk-bar .menu-list { color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters .field > label { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
.filters select, .filters input[type=number], .filters input[type=text] { width: auto; min-width: 128px; height: 36px; font-size: 13px; }
.filters input[type=text] { min-width: 220px; }
.pagination { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 16px 0 2px; }

/* product cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.product-card {
  display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.product-card:hover { text-decoration: none; border-color: #c9cff9; box-shadow: var(--shadow-md); transform: translateY(-1px); color: var(--text); }
.product-card .pc-head { display: flex; gap: 12px; align-items: flex-start; }
.product-card .pc-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.product-card b { font-size: 15px; display: block; }
.product-card .pc-numbers { display: flex; gap: 18px; padding-top: 12px; border-top: 1px solid var(--border); }
.product-card .pc-numbers div { display: flex; flex-direction: column; }
.product-card .pc-numbers strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.product-card .pc-numbers span { color: var(--muted); font-size: 12px; }
.new-card { align-items: center; justify-content: center; text-align: center; border-style: dashed; background: var(--surface-2); color: var(--text-2); min-height: 160px; }

/* sending progress panel */
.send-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.send-panel .big { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.send-panel .big small { font-size: 15px; color: var(--muted); font-weight: 600; }
.send-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.send-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(17, 24, 39, .42); display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease-out; backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 24px;
  animation: pop .16s ease-out;
}
.modal-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); margin-bottom: 14px; }
.modal.danger .modal-icon { background: var(--err-soft); color: var(--err); }
.modal h3 { font-size: 17px; margin-bottom: 6px; }
.modal p { color: var(--text-2); margin-bottom: 20px; white-space: pre-line; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 9vh 16px 40px; background: radial-gradient(1200px 500px at 50% -10%, #e9e8ff, var(--bg)); }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .brand { justify-content: center; padding-bottom: 22px; }
.auth-box .card { padding: 26px; }

/* ---------------------------------------------------------------- motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes stripes { to { background-position: 28px 0, 0 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; margin-top: -8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-main { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .flash.toast { top: 64px; left: 50%; width: calc(100vw - 24px); }
  .app { flex-direction: column; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 16px;
  }
  .mobile-bar .brand { padding: 0; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; height: 100vh; transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 55; }
  .container { padding: 18px 16px 70px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 32px; height: 32px; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .card > .table-wrap { margin: 0 -16px -18px; }
  h1 { font-size: 21px; }
  .send-panel { grid-template-columns: 1fr; }
  .filters select, .filters input[type=text] { min-width: 0; flex: 1; }
}
