/* ============================================
   ivey dashboard — 套用 ivey design system（藍）
   ============================================ */

:root {
  /* ── 品牌色（ivey 藍）── */
  --accent: #0A84FF;
  --accent-tint: rgba(74, 130, 228, 0.15);
  --accent-border: rgba(74, 130, 228, 0.45);

  /* ── 背景分層（永遠不用純白純黑）── */
  --bg-base: #0D0D0F;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-strong: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.10);
  --bg-modal: #111A2E;
  --bg-pressed: rgba(255, 255, 255, 0.04);

  /* ── 邊線 ── */
  --border-card: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.10);
  --separator: rgba(84, 84, 88, 0.65);

  /* ── 文字（只用兩種顏色）── */
  --text-primary: #FFFFFF;
  --text-secondary: rgba(235, 235, 245, 0.6);

  /* ── 狀態色 ── */
  --amber: #FFB020;
  --red:   #FF453A;
  --green: #30D158;
  --purple: #BF5AF2;

  /* ── 圓角階梯（限定 5 個）── */
  --radius-chip: 9px;
  --radius-input: 10px;
  --radius-card: 12px;
  --radius-button: 12px;
  --radius-pill: 20px;

  /* ── 間距 ── */
  --space-screen-x: 16px;
  --space-card-padding: 16px;
  --space-card-gap: 12px;
  --space-section: 24px;

  /* ── 文字尺寸（限定 7 個）── */
  --t-large-title: 34px;
  --t-title-2: 22px;
  --t-headline: 17px;
  --t-body: 17px;
  --t-subhead: 15px;
  --t-footnote: 13px;
  --t-caption: 12px;

  /* ── 字體 ── */
  --font-base: "Roboto", "Noto Sans TC", -apple-system, system-ui, sans-serif;
  --font-mono: "Roboto Mono", "SF Mono", monospace;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 30px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* ── reset ─────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-base);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: var(--t-subhead);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  padding: 10px 12px;
  color: var(--text-primary);
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-border);
  background: rgba(255, 255, 255, 0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-secondary); }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--t-footnote);
  font-weight: 500;
  color: var(--text-secondary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: var(--radius-chip);
  color: var(--text-primary);
}

/* ── LOGIN ─────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-screen-x);
  background:
    radial-gradient(circle at 20% 0%, rgba(10, 132, 255, 0.10), transparent 50%),
    var(--bg-base);
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-card-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
}
.login-card h1, .app-header h1 {
  font-weight: 700;
  font-size: var(--t-title-2);
  letter-spacing: -0.01em;
}
.login-tagline {
  color: var(--text-secondary);
  font-size: var(--t-footnote);
  margin: 6px 0 24px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form button[type="submit"], .modal-actions button[type="submit"] {
  background: var(--accent);
  color: #FFFFFF;
  border-radius: var(--radius-button);
  padding: 12px 16px;
  font-size: var(--t-headline);
  font-weight: 600;
  margin-top: 4px;
  transition: opacity 0.12s;
}
.login-form button[type="submit"]:active,
.modal-actions button[type="submit"]:active { opacity: 0.7; }
.login-error { color: var(--red); font-size: var(--t-footnote); }

/* ── APP SHELL ─────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 12px var(--space-screen-x);
  border-bottom: 1px solid var(--border-card);
  background: rgba(13, 13, 15, 0.80);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-footnote);
}
.who { color: var(--text-secondary); margin-left: 8px; font-weight: 500; }

/* Idle/Active 按鈕基底 */
.ghost-btn {
  padding: 8px 14px;
  border-radius: var(--radius-button);
  border: 1px solid transparent;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--t-footnote);
  font-weight: 500;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.ghost-btn:active { opacity: 0.7; }
.ghost-btn:hover {
  background: var(--bg-card-strong);
  color: var(--text-primary);
}

.brand-text {
  font-weight: 700;
  font-size: var(--t-headline);
  letter-spacing: -0.01em;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ── PRODUCT TABS（最上層 pill）─────────────── */
.product-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  padding: 4px;
  border-radius: var(--radius-pill);
  justify-self: center;
}
.product-tab {
  padding: 7px 18px;
  border-radius: 16px;
  font-size: var(--t-footnote);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.product-tab:active { opacity: 0.7; }
.product-tab:hover:not(.active) { color: var(--text-primary); }
.product-tab.active {
  background: var(--accent);
  color: #FFFFFF;
}

/* ── VIEW TABS（次層 underline）───────────── */
.view-tabs {
  display: flex;
  gap: 2px;
  padding: 8px var(--space-screen-x) 0;
  border-bottom: 1px solid var(--border-card);
  background: var(--bg-base);
}
.view-tab {
  padding: 10px 16px;
  font-size: var(--t-footnote);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s, opacity 0.12s;
}
.view-tab:active { opacity: 0.7; }
.view-tab:hover:not(.active) { color: var(--text-primary); }
.view-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ── STUB / LOADING ────────────────────────── */
.stub-view {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.stub-card {
  width: min(520px, 100%);
  margin: 60px auto;
  background: var(--bg-card-strong);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.stub-status {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber);
}
.stub-card h2 {
  font-size: var(--t-title-2);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stub-desc {
  color: var(--text-secondary);
  font-size: var(--t-subhead);
  line-height: 1.55;
}
.stub-hint {
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-input);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}
.stub-refresh {
  align-self: flex-start;
  margin-top: 4px;
  padding: 10px 16px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-button);
  color: var(--accent);
  font-size: var(--t-footnote);
  font-weight: 600;
}
.stub-refresh:disabled { opacity: 0.4; pointer-events: none; }
.stub-refresh:active { opacity: 0.7; }

/* ── POSTHOG VIEW ──────────────────────────── */
.ph-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-card-gap);
  padding: 18px var(--space-screen-x) 40px;
  align-content: start;
}
.ph-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: var(--space-card-padding);
  box-shadow: var(--shadow-card);
}
.ph-card h3 {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.ph-summary { grid-column: 1 / -1; }
.ph-summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 12px;
}
.ph-stat-label {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.ph-stat-value {
  font-family: var(--font-mono);
  font-size: var(--t-large-title);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.ph-meta {
  font-size: var(--t-caption);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ph-refresh {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: var(--t-caption);
  cursor: pointer;
  padding: 0;
}
.ph-refresh:hover { opacity: 0.7; }

.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px;
  gap: 10px;
  align-items: center;
  font-size: var(--t-caption);
}
.bar-label { color: var(--text-secondary); font-family: var(--font-mono); }
.bar-track {
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease-out;
}
.bar-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

.ph-events { display: flex; flex-direction: column; gap: 4px; }
.ph-event-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-input);
  font-size: var(--t-footnote);
}
.ph-event-name { color: var(--text-secondary); font-family: var(--font-mono); }
.ph-event-count {
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ── ASC VIEW ──────────────────────────────── */
.asc-wrap {
  padding: 18px var(--space-screen-x) 40px;
  display: flex;
  flex-direction: column;
  gap: var(--space-card-gap);
}
.asc-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.asc-header h2 {
  font-size: var(--t-title-2);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.asc-refresh {
  padding: 9px 14px;
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-button);
  color: var(--accent);
  font-size: var(--t-footnote);
  font-weight: 600;
}
.asc-refresh:active { opacity: 0.7; }
.asc-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-section);
}
.asc-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.asc-group-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.asc-group-name {
  font-size: var(--t-headline);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.asc-group-bundle {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text-secondary);
}

.asc-list { display: flex; flex-direction: column; gap: 6px; }
.asc-row {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.asc-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.asc-version-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.asc-version-marketing {
  font-family: var(--font-mono);
  font-size: var(--t-headline);
  font-weight: 600;
  color: var(--text-primary);
}
.asc-version-build {
  font-family: var(--font-mono);
  font-size: var(--t-caption);
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-chip);
}
.asc-audience {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--accent-tint);
  color: var(--accent);
  letter-spacing: 0.04em;
}
.asc-audience-internal {
  background: var(--bg-card);
  color: var(--text-secondary);
}
.asc-state {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.asc-state-valid      { background: rgba(48, 209, 88, 0.15);  color: var(--green); }
.asc-state-processing { background: rgba(255, 176, 32, 0.15); color: var(--amber); }
.asc-state-failed     { background: rgba(255, 69, 58, 0.15);  color: var(--red); }
.asc-state-other      { background: var(--bg-card);           color: var(--text-secondary); }

.asc-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: var(--t-caption);
  color: var(--text-secondary);
}
.asc-bundle {
  font-family: var(--font-mono);
  margin-left: auto;
}

/* ── ASC Overview Dashboard ────────────────── */
.asc-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-card-gap);
}
.asc-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: var(--space-card-padding);
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
}
.asc-stat .ph-stat-label { margin-bottom: 0; }
.asc-stat .ph-stat-value { font-size: 32px; line-height: 1.1; }
.ph-stat-value-sub {
  font-family: var(--font-mono);
  font-size: var(--t-headline);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.asc-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.asc-section h3 {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.asc-app {
  font-size: var(--t-headline);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.asc-reviews {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asc-review {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asc-review-unreplied {
  border-color: rgba(255, 176, 32, 0.35);
  background: rgba(255, 176, 32, 0.05);
}
.asc-review-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: var(--t-caption);
}
.asc-review-app {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--t-footnote);
}
.asc-review-territory {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 1px 6px;
  border-radius: var(--radius-chip);
  font-size: 10px;
  letter-spacing: 0.04em;
}
.asc-review-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(48, 209, 88, 0.15);
  color: var(--green);
}
.asc-review-tag-warn {
  background: rgba(255, 176, 32, 0.15);
  color: var(--amber);
}
.asc-review-date {
  margin-left: auto;
  color: var(--text-secondary);
}
.asc-review-title {
  font-size: var(--t-subhead);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}
.asc-review-body {
  font-size: var(--t-footnote);
  color: var(--text-primary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.asc-review-meta {
  font-size: var(--t-caption);
  color: var(--text-secondary);
}

.asc-stars {
  font-family: var(--font-mono);
  font-size: var(--t-footnote);
  letter-spacing: 0.04em;
  color: var(--amber);
}
.asc-stars-dim { color: rgba(255, 176, 32, 0.25); }
.asc-stars-1, .asc-stars-2 { color: var(--red); }
.asc-stars-1 .asc-stars-dim,
.asc-stars-2 .asc-stars-dim { color: rgba(255, 69, 58, 0.25); }

/* ── ASC Sales（下載量）─────────────────────── */
.asc-sales-loading {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 28px;
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--t-footnote);
}
.asc-sales-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 24px;
  align-items: end;
  box-shadow: var(--shadow-card);
}
.asc-sales-total-block .ph-stat-value { font-size: 32px; line-height: 1.1; }
.asc-spark {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}
.asc-spark-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.asc-spark-bar {
  width: 100%;
  max-width: 28px;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease-out;
}
.asc-spark-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
}

.asc-sales-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 4px;
  overflow-x: auto;
}
.asc-sales-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-caption);
  font-family: var(--font-mono);
}
.asc-sales-table th,
.asc-sales-table td {
  padding: 8px 10px;
  text-align: right;
  white-space: nowrap;
}
.asc-sales-table th {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
  border-bottom: 1px solid var(--separator);
}
.asc-sales-table th:first-child,
.asc-sales-table td:first-child { text-align: left; }
.asc-sales-table tbody tr + tr td {
  border-top: 1px solid var(--border-card);
}
.asc-sales-app {
  font-family: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
}
.asc-sales-total {
  color: var(--accent);
  font-weight: 700;
}
.asc-sales-cell { color: var(--text-secondary); }
.asc-sales-cell:not(:empty) { color: var(--text-primary); }
.asc-sales-note {
  font-size: var(--t-caption);
  color: var(--text-secondary);
  font-style: italic;
}

/* ── KANBAN ────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: var(--space-card-gap);
  padding: 18px var(--space-screen-x) 40px;
  align-items: start;
  flex: 1;
  overflow-x: auto;
}
.column {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  min-height: 200px;
  max-height: calc(100vh - 130px);
}
.column-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--separator);
}
.column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--t-footnote);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.col-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
}
.col-backlog .col-dot { background: var(--text-secondary); }
.col-working .col-dot { background: var(--accent); }
.col-pending .col-dot { background: var(--amber); }
.col-shipped .col-dot { background: var(--green); }

.column-count {
  font-size: var(--t-caption);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
}
.add-card-btn {
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px 10px;
  border-radius: var(--radius-chip);
  font-weight: 500;
  transition: opacity 0.12s;
}
.add-card-btn:active { opacity: 0.7; }
.add-card-btn:hover { color: var(--accent); background: var(--accent-tint); }

.cards {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
}
.cards.dragover { background: var(--accent-tint); }

.card {
  background: var(--bg-card-strong);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, opacity 0.12s;
  position: relative;
}
.card:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.10);
}
.card:active { opacity: 0.85; }
.card.dragging { opacity: 0.4; }
.card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.priority-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-chip);
  letter-spacing: 0.04em;
}
.priority-P0 { background: rgba(255, 69, 58, 0.15);  color: var(--red); }
.priority-P1 { background: rgba(255, 176, 32, 0.15); color: var(--amber); }
.priority-P2 { background: var(--accent-tint);       color: var(--accent); }
.priority-P3 { background: var(--bg-card);           color: var(--text-secondary); }

.category-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-title {
  font-size: var(--t-subhead);
  font-weight: 500;
  line-height: 1.35;
  margin-bottom: 4px;
}
.card-summary {
  font-size: var(--t-footnote);
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: var(--t-caption);
  color: var(--text-secondary);
}
.card-meta .meta-item { display: flex; align-items: center; gap: 3px; }
.card-meta .meta-icon { opacity: 0.6; }
.card-meta .due-overdue { color: var(--red); }
.card-todos { font-size: var(--t-caption); color: var(--text-secondary); }
.card-branch {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--separator);
  font-size: var(--t-caption);
  color: var(--amber);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.card-branch .branch-name { font-weight: 600; }
.card-branch .branch-msg {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── DRAWER ────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100%);
  background: var(--bg-modal);
  border-left: 1px solid var(--border-card);
  z-index: 30;
  box-shadow: var(--shadow-modal);
  animation: slidein 0.18s ease-out;
}
.drawer-narrow { width: min(420px, 100%); }
.drawer-wide { width: min(640px, 100%); }
@keyframes slidein {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-inner {
  padding: 22px 24px 60px;
  height: 100%;
  overflow-y: auto;
}
.drawer-close {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 6px 10px;
  border-radius: var(--radius-chip);
  transition: opacity 0.12s;
}
.drawer-close:active { opacity: 0.7; }
.drawer-close:hover { background: var(--bg-card); color: var(--text-primary); }
.drawer h2 {
  font-size: var(--t-title-2);
  font-weight: 700;
  margin-bottom: 16px;
}

/* Card detail */
.detail-header {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--separator);
}
.detail-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.detail-pills > * {
  font-size: var(--t-caption);
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-chip);
  background: var(--bg-card);
  color: var(--text-secondary);
}
.detail-title {
  font-size: var(--t-large-title);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.detail-title-input {
  font-size: var(--t-large-title);
  font-weight: 700;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  padding: 4px 6px;
  margin: -4px -6px 6px;
}
.detail-title-input:hover { border-color: var(--border-strong); }
.detail-summary {
  color: var(--text-secondary);
  font-size: var(--t-footnote);
  line-height: 1.5;
}
.detail-summary-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-input);
  padding: 4px 6px;
  margin: -4px -6px;
  font-size: var(--t-footnote);
  color: var(--text-secondary);
}
.detail-summary-input:hover { border-color: var(--border-strong); }

.detail-section { margin-top: var(--space-section); }
.detail-section h3 {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.field-grid label { font-size: var(--t-caption); }

.todos-list { display: flex; flex-direction: column; gap: 4px; }
.todo {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-input);
  background: var(--bg-card);
  border: 1px solid transparent;
  transition: border-color 0.1s;
}
.todo:hover { border-color: var(--border-card); }
.todo input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.todo-body { flex: 1; min-width: 0; }
.todo-title { font-size: var(--t-footnote); cursor: text; }
.todo.done .todo-title {
  text-decoration: line-through;
  color: var(--text-secondary);
}
.todo-desc {
  font-size: var(--t-caption);
  color: var(--text-secondary);
  margin-top: 3px;
  white-space: pre-wrap;
}
.todo-delete {
  color: var(--text-secondary);
  font-size: var(--t-caption);
  padding: 2px 6px;
  opacity: 0;
  transition: opacity 0.1s;
}
.todo:hover .todo-delete { opacity: 1; }
.todo-delete:hover { color: var(--red); }

.add-todo-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.add-todo-form input { flex: 1; }
.add-todo-form button {
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-button);
  padding: 0 16px;
  color: var(--accent);
  font-size: var(--t-footnote);
  font-weight: 600;
  transition: opacity 0.12s;
}
.add-todo-form button:active { opacity: 0.7; }
.add-todo-form button:hover { background: var(--accent); color: #FFFFFF; }

.move-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Idle 按鈕 = accent tint + accent border */
.move-buttons button {
  padding: 8px 14px;
  border-radius: var(--radius-button);
  background: var(--accent-tint);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: var(--t-caption);
  font-weight: 600;
  transition: opacity 0.12s;
}
.move-buttons button:active { opacity: 0.7; }
/* Active 按鈕 = accent 實心 */
.move-buttons button.current {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.danger-btn {
  background: rgba(255, 69, 58, 0.10);
  border: 1px solid rgba(255, 69, 58, 0.45);
  color: var(--red);
  padding: 8px 14px;
  border-radius: var(--radius-button);
  font-size: var(--t-caption);
  font-weight: 600;
  transition: opacity 0.12s;
}
.danger-btn:active { opacity: 0.7; }
.danger-btn:hover { background: rgba(255, 69, 58, 0.20); }

/* ── ACTIVITY ──────────────────────────────── */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--t-footnote);
}
.activity-row {
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-input);
  border: 1px solid var(--border-card);
}
.activity-row .actor { color: var(--accent); font-weight: 600; }
.activity-row .verb { color: var(--text-primary); }
.activity-row .target { color: var(--text-secondary); }
.activity-row .arrow { color: var(--text-secondary); margin: 0 4px; }
.activity-row .delta { color: var(--amber); }
.activity-row .ts {
  color: var(--text-secondary);
  font-size: var(--t-caption);
  margin-top: 4px;
}

/* ── GITHUB ────────────────────────────────── */
.github-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-section);
}
.gh-section h3 {
  font-size: var(--t-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.gh-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--t-footnote);
}
.gh-item {
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-input);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gh-item .repo-tag {
  font-size: 10px;
  color: var(--text-secondary);
  margin-right: 6px;
  font-weight: 500;
}
.gh-item .gh-line-1 { display: flex; align-items: center; gap: 6px; }
.gh-item .gh-name { color: var(--text-primary); font-weight: 500; }
.gh-item .gh-meta { color: var(--text-secondary); font-size: var(--t-caption); }
.gh-pr-state {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  text-transform: uppercase;
}
.gh-pr-state.open   { background: var(--accent-tint);              color: var(--accent); }
.gh-pr-state.merged { background: rgba(191, 90, 242, 0.15);        color: var(--purple); }
.gh-pr-state.closed { background: rgba(255, 69, 58, 0.15);         color: var(--red); }

.gh-empty {
  color: var(--text-secondary);
  font-size: var(--t-footnote);
  padding: 12px 0;
}

/* ── MODAL ─────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
  animation: fadein 0.15s ease-out;
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-card {
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 28px;
  width: min(460px, 100%);
  box-shadow: var(--shadow-modal);
}
.modal-card h2 {
  font-size: var(--t-title-2);
  font-weight: 700;
  margin-bottom: 16px;
}
.new-card-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.modal-actions .ghost-btn { padding: 12px 16px; font-size: var(--t-headline); }

/* ── TOAST ─────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-modal);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-button);
  font-size: var(--t-footnote);
  font-weight: 500;
  z-index: 50;
  box-shadow: var(--shadow-modal);
  animation: toastin 0.2s ease-out;
}
@keyframes toastin {
  from { transform: translate(-50%, 8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 1100px) {
  .app-header {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .product-tabs { justify-self: start; flex-wrap: wrap; }
  .view-tabs { padding: 8px 12px 0; overflow-x: auto; }
  .header-left, .header-right { flex-wrap: wrap; }
}
@media (max-width: 800px) {
  .kanban { grid-template-columns: 1fr; }
  .column { max-height: none; }
  .ph-grid { grid-template-columns: 1fr; }
  .ph-summary-row { grid-template-columns: 1fr; }
  .asc-summary { grid-template-columns: repeat(2, 1fr); }
  .asc-review-date { margin-left: 0; }
  .asc-sales-summary { grid-template-columns: 1fr; gap: 16px; }
}
