/* ─────────────────────────────────────────────────────────────────────────
   LINE Bot SaaS · 產品原型共用樣式
   設計語言：Mintlify（依專案 DESIGN.md）
   Inter（介面文字）＋ Geist Mono（數值／代碼）；薄荷綠僅用於選中／強調狀態。
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* surface */
  --canvas:        #ffffff;
  --surface:       #f7f7f7;
  --surface-soft:  #fafafa;
  --surface-code:  #1c1c1e;
  --hairline:      #e5e5e5;
  --hairline-soft: #ededed;
  --hairline-dark: #1f1f1f;

  /* text */
  --ink:      #0a0a0a;
  --charcoal: #1c1c1e;
  --slate:    #3a3a3c;
  --steel:    #5a5a5c;
  --stone:    #707072;  /* 品牌 #888888 之文字安全版 — 小字上維持 ≥4.5:1 */
  --muted:    #a8a8aa;
  --on-dark:  #ffffff;
  --on-dark-muted: #b3b3b3;

  /* brand & semantic */
  --green:      #00d4a4;
  --green-deep: #00b48a;
  --green-soft: #7cebcb;
  --tag:   #3772cf;
  --warn:  #c37d0d;
  --error: #d45656;
  --green-tint: color-mix(in oklch, var(--green) 14%, transparent);
  --tag-tint:   color-mix(in oklch, var(--tag) 14%, transparent);
  --warn-tint:  color-mix(in oklch, var(--warn) 16%, transparent);
  --error-tint: color-mix(in oklch, var(--error) 14%, transparent);
  --row-hover:  color-mix(in oklch, var(--ink) 3%, transparent);

  /* 文字安全深色版 — 品牌色作小字使用時的 600 級深化（≥4.5:1） */
  --green-ink: color-mix(in oklch, var(--green-deep) 62%, black);
  --warn-ink:  color-mix(in oklch, var(--warn) 70%, black);
  --error-ink: color-mix(in oklch, var(--error) 72%, black);

  /* type */
  --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 9999px;

  /* spacing (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  --sidebar-w: 248px;
  --topbar-h:  56px;

  /* motion — 依 DESIGN.md 動畫 token */
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* 鍵盤焦點 — 全站可見（滑鼠點擊不觸發） */
:focus-visible {
  outline: 2px solid var(--green-ink);
  outline-offset: 2px;
}

/* ─── app shell ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-4);
}
.brand-mark {
  width: 30px; height: 30px; border-radius: var(--r-md);
  background: var(--ink); color: var(--on-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub  { font-size: 11px; color: var(--stone); font-family: var(--font-mono); }

.sidebar-tenant {
  margin: 0 var(--s-4) var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  display: flex; align-items: center; gap: var(--s-3);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.sidebar-tenant:hover { border-color: var(--stone); }
.tenant-badge {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--green-tint); color: var(--green-deep);
}
.tenant-name { font-size: 13px; font-weight: 500; }
.tenant-plan { font-size: 11px; color: var(--stone); font-family: var(--font-mono); }
.chev { color: var(--muted); margin-left: auto; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-4) var(--s-3); }
.nav-section { margin-top: var(--s-5); }
.nav-section:first-child { margin-top: 0; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--steel); padding: 0 var(--s-3) var(--s-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--steel);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); font-weight: 500; }
.nav-item.active::before {
  content: ''; position: absolute; left: -3px; top: 8px; bottom: 8px; width: 2px;
  border-radius: 2px; background: var(--green);
}
.nav-item .nav-tail { margin-left: auto; }
.nav-pill {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.02em;
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--warn-tint); color: var(--warn);
}
.sidebar-foot {
  border-top: 1px solid var(--hairline);
  padding: var(--s-3) var(--s-4);
  display: flex; align-items: center; gap: var(--s-3);
}
.avatar {
  width: 28px; height: 28px; border-radius: var(--r-full); flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--ink); color: var(--on-dark);
}

/* main column */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: color-mix(in oklch, var(--canvas) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-8);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: 13px; color: var(--steel); }
.crumbs .sep { color: var(--muted); }
.crumbs .here { color: var(--ink); font-weight: 500; }
.topbar-spacer { flex: 1; }
.search-pill {
  display: flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-3);
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--r-md); color: var(--stone); font-size: 13px; min-width: 220px;
}
.search-pill kbd {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--canvas); border: 1px solid var(--hairline);
  border-radius: var(--r-xs); padding: 0 5px; color: var(--steel);
}
.content { padding: var(--s-8); max-width: 1180px; width: 100%; }
.content-wide { max-width: 1320px; }

/* page header */
.page-head { margin-bottom: var(--s-6); }
.page-title { font-size: 26px; letter-spacing: -0.02em; }
.page-desc  { color: var(--steel); margin-top: var(--s-2); font-size: 14px; max-width: 68ch; }

/* ─── buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 34px; padding: 0 14px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-secondary:disabled:hover { border-color: var(--hairline); }
.btn-primary { background: var(--ink); color: var(--on-dark); }
.btn-primary:hover { background: var(--charcoal); }
.btn-accent { background: var(--green); color: var(--ink); }
.btn-accent:hover { background: var(--green-deep); }
.btn-secondary { background: var(--canvas); color: var(--ink); border: 1px solid var(--hairline); }
.btn-secondary:hover { border-color: var(--steel); }
.btn-ghost { background: transparent; color: var(--steel); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); }
.btn-danger { background: transparent; color: var(--error); border: 1px solid var(--error-tint); }
.btn-danger:hover { background: var(--error-tint); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--r-full); border: 1px solid var(--hairline); background: var(--canvas); color: var(--steel); }
.btn-icon:hover { color: var(--ink); border-color: var(--steel); }

/* ─── cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--canvas); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: var(--s-6);
}
.card-pad-sm { padding: var(--s-5); }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--steel); margin-top: 2px; }

/* stat tile */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.stat {
  background: var(--canvas); border: 1px solid var(--hairline);
  border-radius: var(--r-lg); padding: var(--s-5);
}
.stat-label { font-size: 12px; color: var(--steel); display: flex; align-items: center; gap: 6px; }
.stat-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin-top: var(--s-3); line-height: 1; }
.stat-value .unit { font-size: 15px; color: var(--stone); margin-left: 3px; }
.stat-delta { font-size: 12px; margin-top: var(--s-3); font-family: var(--font-mono); }
.delta-up { color: var(--green-ink); }
.delta-flat { color: var(--stone); }

/* ─── tabs ──────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: var(--s-5); border-bottom: 1px solid var(--hairline); margin-bottom: var(--s-5); }
.tab {
  padding: var(--s-3) 2px; font-size: 13.5px; color: var(--steel); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
  display: flex; align-items: center; gap: var(--s-2);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .count {
  font-family: var(--font-mono); font-size: 11px; color: var(--steel);
  background: var(--surface); border-radius: var(--r-full); padding: 0 6px;
}
.tab.active .count { background: var(--green-tint); color: var(--green-ink); }

/* ─── toolbar (filters + actions) ───────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); flex-wrap: wrap; }
.input {
  height: 34px; padding: 0 var(--s-3); border: 1px solid var(--hairline);
  border-radius: var(--r-md); background: var(--canvas); color: var(--ink); font-size: 13px;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.input-search { display: flex; align-items: center; gap: var(--s-2); padding-left: var(--s-3); }
.input-search svg { width: 15px; height: 15px; color: var(--muted); }
.input-search input { border: 0; outline: none; background: none; height: 32px; font-size: 13px; width: 180px; }
.select {
  height: 34px; padding: 0 30px 0 var(--s-3); border: 1px solid var(--hairline);
  border-radius: var(--r-md); background: var(--canvas); color: var(--slate); font-size: 13px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--steel); font-weight: 500; }
.field .input, .field textarea { width: 100%; }
textarea.input { height: auto; padding: var(--s-3); min-height: 84px; line-height: 1.5; resize: vertical; }
.field-hint { font-size: 11.5px; color: var(--stone); }

/* ─── table ─────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--steel); padding: var(--s-3) var(--s-5); background: var(--surface-soft);
  border-bottom: 1px solid var(--hairline);
}
table.data td { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--hairline-soft); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--dur-fast) var(--ease-out); cursor: pointer; }
table.data tbody tr:hover { background: var(--row-hover); }
table.data tbody tr.selected { background: var(--green-tint); }
.cell-strong { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 12px; color: var(--stone); margin-top: 1px; }
.cell-code { font-family: var(--font-mono); font-size: 12.5px; color: var(--slate); }
.num-col { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.row-avatar {
  width: 30px; height: 30px; border-radius: var(--r-full); flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--slate); border: 1px solid var(--hairline);
}
.cell-flex { display: flex; align-items: center; gap: var(--s-3); }

/* ─── badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; padding: 2px 9px; border-radius: var(--r-full);
  font-family: var(--font-ui);
}
.badge .dot { width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.badge-green { background: var(--green-tint); color: var(--green-ink); }
.badge-blue  { background: var(--tag-tint);  color: var(--tag); }
.badge-warn  { background: var(--warn-tint);  color: var(--warn-ink); }
.badge-error { background: var(--error-tint); color: var(--error-ink); }
.badge-neutral { background: var(--surface); color: var(--steel); border: 1px solid var(--hairline); }
.badge-mono { font-family: var(--font-mono); font-size: 11px; }

/* code chip */
.chip-code {
  font-family: var(--font-mono); font-size: 12px; color: var(--charcoal);
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-xs);
  padding: 1px 6px;
}

/* ─── drawer ────────────────────────────────────────────────────────────── */
.drawer {
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  overflow: hidden; position: sticky; top: calc(var(--topbar-h) + var(--s-8));
}
.drawer-head { padding: var(--s-5); border-bottom: 1px solid var(--hairline); }
.drawer-body { padding: var(--s-5); }
.prop-row { display: grid; grid-template-columns: 96px 1fr; gap: var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--hairline-soft); align-items: baseline; }
.prop-row:last-child { border-bottom: 0; }
.prop-key { font-size: 12px; color: var(--steel); }
.prop-val { font-size: 13.5px; color: var(--ink); }

/* ─── toggle / switch ───────────────────────────────────────────────────── */
.switch { width: 40px; height: 24px; padding: 0; border: 0; border-radius: var(--r-full); background: var(--hairline); position: relative; transition: background var(--dur-base) var(--ease-out); flex-shrink: 0; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: var(--r-full); background: var(--canvas); box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform var(--dur-base) var(--ease-out); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(16px); }

.entitlement-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4) 0; border-bottom: 1px solid var(--hairline-soft); }
.entitlement-row:last-child { border-bottom: 0; }
.ent-name { font-size: 13.5px; font-weight: 500; }
.ent-desc { font-size: 12px; color: var(--stone); margin-top: 1px; }

/* ─── tree (區域樹) ─────────────────────────────────────────────────────── */
.tree { font-size: 13.5px; }
.tree-node { display: flex; align-items: center; gap: var(--s-2); padding: 7px var(--s-3); border-radius: var(--r-sm); cursor: pointer; }
.tree-node:hover { background: var(--surface); }
.tree-node.active { background: var(--green-tint); color: var(--green-ink); font-weight: 500; }
.tree-toggle { width: 14px; color: var(--muted); }
.tree-icon { width: 15px; height: 15px; color: var(--stone); }
.tree-node.active .tree-icon { color: var(--green-deep); }
.tree-count { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--stone); }
.tree-child { margin-left: var(--s-5); border-left: 1px solid var(--hairline); padding-left: var(--s-2); }

/* alert */
.alert { display: flex; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-md); font-size: 13px; align-items: flex-start; }
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-warn { background: var(--warn-tint); color: var(--warn); }
.alert-info { background: var(--tag-tint); color: var(--tag); }
.alert strong { display: block; margin-bottom: 2px; }
.alert p { color: inherit; opacity: 0.9; }

/* section spacing helper */
.stack-6 > * + * { margin-top: var(--s-6); }
.stack-4 > * + * { margin-top: var(--s-4); }
.stack-3 > * + * { margin-top: var(--s-3); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); }
.wrap { flex-wrap: wrap; }
.grid-2-1 { display: grid; grid-template-columns: 1fr 340px; gap: var(--s-6); align-items: start; }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1 { grid-template-columns: 1fr; }
  .drawer { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: var(--s-5); }
  .topbar { padding: 0 var(--s-5); }
}
