/* ==========================================================================
   ETracking 後台樣式
   不需要任何建置工具，直接編輯此檔即可。
   ========================================================================== */

/* ---------- 設計變數 ---------- */

:root {
    color-scheme: light;

    --bg: #f7f7f5;
    --surface: #ffffff;
    --surface-2: #f9f9f7;
    --surface-3: #f0efec;
    --border: #e1e0d9;
    --border-strong: #c3c2b7;

    --text: #1a1a19;
    --text-2: #52514e;
    --text-3: #6c6a64;

    --accent: #256abf;
    --accent-hover: #1c5cab;
    --accent-bg: #256abf;
    --accent-bg-hover: #1c5cab;
    --accent-soft: #e8f1fd;
    --accent-text: #1c5cab;
    --on-accent: #ffffff;
    --focus: #2a78d6;

    /* 狀態色：固定含義，永遠搭配圖示與文字 */
    --good: #0ca30c;
    --good-text: #006300;
    --good-soft: #e6f5e6;
    --warning: #fab219;
    --warning-text: #7a5200;
    --warning-soft: #fef3d9;
    --serious: #ec835a;
    --serious-text: #a03f1a;
    --serious-soft: #fdebe4;
    --critical: #d03b3b;
    --critical-text: #b32a2a;
    --critical-soft: #fbe8e8;
    --neutral: #898781;
    --neutral-text: #52514e;
    --neutral-soft: #f0efec;

    /* 圖表 */
    --series-1: #2a78d6;
    --series-muted: #c3c2b7;
    --chart-grid: #e1e0d9;
    --chart-axis: #c3c2b7;
    --chart-label: #6c6a64;
    --heat-0: #f0efec;
    --heat-1: #cde2fb;
    --heat-2: #9ec5f4;
    --heat-3: #6da7ec;
    --heat-4: #3987e5;
    --heat-5: #256abf;
    --heat-6: #104281;

    /* 程式碼 */
    --code-bg: #fbfbfa;
    --code-highlight: #fdebe4;
    --code-highlight-border: #d03b3b;
    --tok-keyword: #a3329b;
    --tok-string: #2c6e1f;
    --tok-variable: #1c5cab;
    --tok-number: #a4521a;
    --tok-comment: #6c6a64;
    --tok-tag: #a03f1a;

    --shadow-sm: 0 1px 2px rgba(11, 11, 11, 0.05);
    --shadow-md: 0 4px 16px rgba(11, 11, 11, 0.10), 0 1px 3px rgba(11, 11, 11, 0.06);
    --radius: 8px;
    --radius-sm: 6px;
    --sidebar-width: 248px;

    --font: system-ui, -apple-system, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0d0d0d;
        --surface: #1a1a19;
        --surface-2: #20201f;
        --surface-3: #2c2c2a;
        --border: #2c2c2a;
        --border-strong: #42423e;

        --text: #f5f5f3;
        --text-2: #c3c2b7;
        --text-3: #95938b;

        --accent: #3987e5;
        --accent-hover: #5598e7;
        --accent-bg: #256abf;
        --accent-bg-hover: #1c5cab;
        --accent-soft: rgba(57, 135, 229, 0.16);
        --accent-text: #86b6ef;
        --on-accent: #ffffff;
        --focus: #6da7ec;

        --good-text: #5fd35f;
        --good-soft: rgba(12, 163, 12, 0.16);
        --warning-text: #fbc44d;
        --warning-soft: rgba(250, 178, 25, 0.14);
        --serious-text: #f2a283;
        --serious-soft: rgba(236, 131, 90, 0.16);
        --critical-text: #f08a8a;
        --critical-soft: rgba(208, 59, 59, 0.20);
        --neutral-text: #c3c2b7;
        --neutral-soft: #2c2c2a;

        --series-1: #3987e5;
        --series-muted: #4a4a46;
        --chart-grid: #2c2c2a;
        --chart-axis: #42423e;
        --chart-label: #95938b;
        --heat-0: #262625;
        --heat-1: #0d366b;
        --heat-2: #184f95;
        --heat-3: #256abf;
        --heat-4: #3987e5;
        --heat-5: #6da7ec;
        --heat-6: #b7d3f6;

        --code-bg: #161615;
        --code-highlight: rgba(208, 59, 59, 0.18);
        --code-highlight-border: #e66767;
        --tok-keyword: #d98bd3;
        --tok-string: #8fcf7f;
        --tok-variable: #86b6ef;
        --tok-number: #eea573;
        --tok-comment: #85837b;
        --tok-tag: #f2a283;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #20201f;
    --surface-3: #2c2c2a;
    --border: #2c2c2a;
    --border-strong: #42423e;

    --text: #f5f5f3;
    --text-2: #c3c2b7;
    --text-3: #95938b;

    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-bg: #256abf;
    --accent-bg-hover: #1c5cab;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --accent-text: #86b6ef;
    --on-accent: #ffffff;
    --focus: #6da7ec;

    --good-text: #5fd35f;
    --good-soft: rgba(12, 163, 12, 0.16);
    --warning-text: #fbc44d;
    --warning-soft: rgba(250, 178, 25, 0.14);
    --serious-text: #f2a283;
    --serious-soft: rgba(236, 131, 90, 0.16);
    --critical-text: #f08a8a;
    --critical-soft: rgba(208, 59, 59, 0.20);
    --neutral-text: #c3c2b7;
    --neutral-soft: #2c2c2a;

    --series-1: #3987e5;
    --series-muted: #4a4a46;
    --chart-grid: #2c2c2a;
    --chart-axis: #42423e;
    --chart-label: #95938b;
    --heat-0: #262625;
    --heat-1: #0d366b;
    --heat-2: #184f95;
    --heat-3: #256abf;
    --heat-4: #3987e5;
    --heat-5: #6da7ec;
    --heat-6: #b7d3f6;

    --code-bg: #161615;
    --code-highlight: rgba(208, 59, 59, 0.18);
    --code-highlight-border: #e66767;
    --tok-keyword: #d98bd3;
    --tok-string: #8fcf7f;
    --tok-variable: #86b6ef;
    --tok-number: #eea573;
    --tok-comment: #85837b;
    --tok-tag: #f2a283;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ---------- 基礎 ---------- */

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
}

p {
    margin: 0;
}

a {
    color: var(--accent-text);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code, kbd, pre, .mono {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

[hidden] {
    display: none !important;
}

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

.icon {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

.muted { color: var(--text-3); }
.secondary { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.text-right { text-align: right; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.strong { font-weight: 600; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 版面 ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 18px;
    color: var(--text);
    font-size: 16px;
    font-weight: 650;
    letter-spacing: 0.01em;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--accent-bg);
    color: var(--on-accent);
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 16px;
}

.nav-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 10px 6px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.nav-label a {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    color: var(--text-3);
}

.nav-label a:hover {
    background: var(--surface-3);
    color: var(--text);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-weight: 500;
}

.nav-item:hover {
    background: var(--surface-3);
    color: var(--text);
    text-decoration: none;
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.nav-item .count {
    margin-left: auto;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    line-height: 20px;
}

.nav-item.active .count {
    background: var(--surface);
}

.nav-project .dot {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    border-radius: 50%;
    background: var(--border-strong);
    flex: none;
}

.nav-project.is-paused {
    color: var(--text-3);
}

.sidebar-footer {
    padding: 10px;
    border-top: 1px solid var(--border);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.user-menu:hover { background: var(--surface-3); }

.avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 650;
    flex: none;
}

.main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 28px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--text-3);
    font-size: 13px;
}

.breadcrumbs a { color: var(--text-2); }
.breadcrumbs .current { color: var(--text); font-weight: 600; }
.breadcrumbs .sep { color: var(--border-strong); }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.content {
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px 28px 64px;
}

.content-narrow {
    max-width: 860px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 21px;
    letter-spacing: -0.005em;
}

.page-subtitle {
    margin-top: 4px;
    color: var(--text-2);
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.topbar .menu-toggle { display: none; }

.backdrop { display: none; }

/* 專案分頁列 */
.tabs {
    display: flex;
    gap: 2px;
    margin: -4px 0 22px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px 10px;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: none;
    color: var(--text-2);
    font: inherit;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.tab:hover {
    color: var(--text);
    text-decoration: none;
}

.tab.active {
    border-bottom-color: var(--accent);
    color: var(--accent-text);
}

.tab .count {
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 12px;
    line-height: 18px;
}

/* ---------- 格線 ---------- */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }

/* ---------- 卡片 ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
}

.card-subtitle {
    color: var(--text-3);
    font-size: 13px;
}

.card-header .actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.card-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13px;
}

/* ---------- 數據方塊 ---------- */

.stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    font-size: 27px;
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.stat-value small {
    margin-left: 3px;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
}

.stat-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 20px;
    color: var(--text-3);
    font-size: 12.5px;
}

a.stat:hover {
    border-color: var(--border-strong);
    text-decoration: none;
}

a.stat { color: inherit; }

.delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-weight: 600;
}

.delta.is-good { color: var(--good-text); }
.delta.is-bad { color: var(--critical-text); }
.delta.is-flat { color: var(--text-3); }

/* ---------- 按鈕 ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s;
}

.btn:hover {
    background: var(--surface-3);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    border-color: var(--accent-bg);
    background: var(--accent-bg);
    color: var(--on-accent);
}

.btn-primary:hover {
    border-color: var(--accent-bg-hover);
    background: var(--accent-bg-hover);
}

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

.btn-danger:hover {
    background: #b93232;
    border-color: #b93232;
}

.btn-danger-outline {
    color: var(--critical-text);
}

.btn-danger-outline:hover {
    background: var(--critical-soft);
    border-color: var(--critical);
}

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

.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text);
}

.btn-sm {
    height: 28px;
    padding: 0 9px;
    font-size: 13px;
}

.btn-icon {
    width: 34px;
    padding: 0;
}

.btn-icon.btn-sm { width: 28px; }

.btn-group {
    display: inline-flex;
    padding: 2px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
}

.btn-group a,
.btn-group button {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--text-2);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.btn-group a:hover,
.btn-group button:hover {
    color: var(--text);
    text-decoration: none;
}

.btn-group .active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

/* ---------- 標籤 ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--neutral-text);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge .icon { width: 12px; height: 12px; stroke-width: 2.25; }

.badge-good { background: var(--good-soft); color: var(--good-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-serious { background: var(--serious-soft); color: var(--serious-text); }
.badge-critical { background: var(--critical-soft); color: var(--critical-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }

.badge-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-2);
    font-weight: 500;
}

.tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 6px;
    border-radius: 4px;
    background: var(--surface-3);
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 11.5px;
    white-space: nowrap;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral);
    flex: none;
}

.status-dot.is-up { background: var(--good); }
.status-dot.is-down { background: var(--critical); }
.status-dot.is-pending { background: var(--border-strong); }
.status-dot.is-paused { background: var(--border-strong); }

/* ---------- 提示訊息 ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}

.alert .icon { margin-top: 3px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; }
.alert p + p { margin-top: 4px; }

.alert-success { border-left-color: var(--good); }
.alert-success > .icon { color: var(--good-text); }
.alert-error { border-left-color: var(--critical); }
.alert-error > .icon { color: var(--critical-text); }
.alert-warning { border-left-color: var(--warning); }
.alert-warning > .icon { color: var(--warning-text); }
.alert-info { border-left-color: var(--accent); }
.alert-info > .icon { color: var(--accent-text); }

.alert-close {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin: -2px -4px 0 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}

.alert-close:hover { background: var(--surface-3); color: var(--text); }

/* ---------- 表格 ---------- */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.table th:first-child,
.table td:first-child { padding-left: 18px; }

.table th:last-child,
.table td:last-child { padding-right: 18px; }

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover td { background: var(--surface-2); }

.table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table .check { width: 36px; padding-right: 0; }

.table-title {
    color: var(--text);
    font-weight: 600;
}

.table-title:hover { color: var(--accent-text); }

.cell-sub {
    margin-top: 2px;
    color: var(--text-3);
    font-size: 12.5px;
}

/* ---------- 表單 ---------- */

.form-group { margin-bottom: 18px; }
.form-group:last-child { margin-bottom: 0; }
[data-show-when] > .form-group:last-child { margin-bottom: 18px; }

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

.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13.5px;
}

.label .optional {
    margin-left: 4px;
    color: var(--text-3);
    font-weight: 400;
}

.input,
.select,
.textarea {
    display: block;
    width: 100%;
    height: 36px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    transition: border-color 0.12s, box-shadow 0.12s;
}

.textarea {
    height: auto;
    min-height: 84px;
    padding: 8px 11px;
    line-height: 1.5;
    resize: vertical;
}

.select {
    padding-right: 30px;
    appearance: none;
    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='%23898781' stroke-width='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 9px center;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

.input::placeholder,
.textarea::placeholder { color: var(--text-3); }

.input.mono,
.textarea.mono { font-family: var(--font-mono); font-size: 13px; }

.input-sm, .select-sm { height: 30px; font-size: 13px; }

.input-group {
    display: flex;
    gap: 8px;
}

.input-group .input { flex: 1; min-width: 0; }
.input-group .select { width: auto; flex: none; }

.help {
    margin-top: 6px;
    color: var(--text-3);
    font-size: 12.5px;
    line-height: 1.5;
}

.error {
    margin-top: 6px;
    color: var(--critical-text);
    font-size: 12.5px;
    font-weight: 500;
}

.has-error .input,
.has-error .select,
.has-error .textarea { border-color: var(--critical); }

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin: 3px 0 0;
    accent-color: var(--accent);
    flex: none;
}

.checkbox-label { font-weight: 500; }

.checkbox-help {
    display: block;
    color: var(--text-3);
    font-size: 12.5px;
    font-weight: 400;
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-section {
    padding: 20px 0;
    border-top: 1px solid var(--border);
}

.form-section:first-child { padding-top: 0; border-top: 0; }
.form-section:last-child { padding-bottom: 0; }

.form-section-title {
    margin-bottom: 4px;
    font-size: 14.5px;
    font-weight: 600;
}

.form-section-desc {
    margin-bottom: 16px;
    color: var(--text-2);
    font-size: 13px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.chip {
    height: 26px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.chip:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.chip.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

/* 類型選擇卡片 */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.choice {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}

.choice:hover {
    border-color: var(--border-strong);
    text-decoration: none;
}

.choice.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.choice-title { font-weight: 600; }
.choice-desc { color: var(--text-3); font-size: 12.5px; }

/* 篩選列 */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.filters .input,
.filters .select {
    width: auto;
    height: 32px;
    font-size: 13px;
}

.search {
    position: relative;
    flex: 1 1 240px;
    max-width: 380px;
}

.search .icon {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    color: var(--text-3);
    pointer-events: none;
}

.search .input {
    width: 100%;
    padding-left: 32px;
}

/* 批次操作列 */
.bulkbar {
    position: sticky;
    top: 56px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 18px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    /* 固定在畫面上方時會蓋住表格內容，必須是不透明的底色 */
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
    font-size: 13px;
    font-weight: 500;
}

/* ---------- 下拉選單 ---------- */

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 50;
    min-width: 200px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.dropdown-menu.is-left { right: auto; left: 0; }
.dropdown-menu.is-up { top: auto; bottom: calc(100% + 4px); }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    min-height: 32px;
    padding: 5px 10px;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--surface-3);
    text-decoration: none;
}

.dropdown-item.is-danger { color: var(--critical-text); }
.dropdown-item .icon { color: var(--text-3); }
.dropdown-item.is-danger .icon { color: inherit; }

.dropdown-divider {
    height: 1px;
    margin: 5px 0;
    background: var(--border);
}

.dropdown-label {
    padding: 6px 10px 2px;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 600;
}

/* ---------- 空狀態 ---------- */

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 44px 24px;
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-3);
}

.empty-title { font-weight: 600; font-size: 15px; }
.empty-text { max-width: 440px; color: var(--text-2); }
.empty .btn { margin-top: 10px; }

/* ---------- 分頁 ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13px;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-link {
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

a.page-link:hover {
    background: var(--surface-3);
    color: var(--text);
    text-decoration: none;
}

.page-link.active {
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 600;
}

.page-link.disabled { color: var(--border-strong); }

/* ---------- 圖表 ---------- */

.chart { margin: 0; }

.chart-plot {
    position: relative;
    width: 100%;
    border-radius: 4px;
}

.chart-plot:focus-visible { outline-offset: 4px; }

.chart-plot svg {
    display: block;
    width: 100%;
    overflow: visible;
}

.chart-plot text {
    fill: var(--chart-label);
    font-family: var(--font);
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.chart-grid { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart-axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-bar { fill: var(--series-1); transition: opacity 0.1s; }
.chart-plot.is-hovering .chart-bar { opacity: 0.45; }
.chart-plot.is-hovering .chart-bar.is-active { opacity: 1; }
.chart-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--series-1); opacity: 0.1; }
.chart-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-crosshair { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart-fail { fill: var(--critical); stroke: var(--surface); stroke-width: 2; }
.chart-hit { fill: transparent; }

.chart-empty {
    display: grid;
    place-items: center;
    min-height: 160px;
    color: var(--text-3);
    font-size: 13px;
}

.chart-tooltip {
    position: absolute;
    z-index: 60;
    top: 0;
    left: 0;
    min-width: 96px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    color: var(--text);
    font-size: 12.5px;
    line-height: 1.4;
    pointer-events: none;
    white-space: nowrap;
}

.chart-tooltip-title {
    margin-bottom: 2px;
    color: var(--text-3);
    font-size: 12px;
}

.chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.chart-tooltip-key {
    width: 10px;
    height: 2px;
    border-radius: 1px;
    background: var(--series-1);
    flex: none;
}

.chart-tooltip-key.is-critical { background: var(--critical); }

.chart-tooltip-value { font-weight: 650; font-size: 13.5px; }
.chart-tooltip-label { color: var(--text-2); }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-top: 10px;
    color: var(--text-2);
    font-size: 12.5px;
}

.chart-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: none;
}

.legend-line {
    width: 14px;
    height: 2px;
    border-radius: 1px;
    background: var(--series-1);
    flex: none;
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

.chart-table {
    max-height: 300px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* 迷你趨勢圖 */
.sparkline {
    display: block;
    overflow: visible;
}

.sparkline rect { fill: var(--series-muted); }
.sparkline rect.is-current { fill: var(--series-1); }
.sparkline rect.is-empty { fill: var(--surface-3); }

/* 橫向長條清單 */
.bar-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bar-item-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 5px;
}

.bar-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-size: 13px;
}

.bar-item-value {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bar-item-share {
    width: 46px;
    color: var(--text-3);
    font-size: 12px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bar-track {
    height: 6px;
    border-radius: 3px;
    background: var(--surface-3);
}

.bar-fill {
    height: 100%;
    min-width: 2px;
    border-radius: 0 3px 3px 0;
    background: var(--series-1);
}

/* 熱度圖 */
.heatmap {
    display: grid;
    grid-template-columns: 28px repeat(24, minmax(0, 1fr));
    gap: 2px;
    align-items: center;
}

.heatmap-label {
    color: var(--chart-label);
    font-size: 11.5px;
}

.heatmap-hour {
    color: var(--chart-label);
    font-size: 11px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.heat {
    height: 20px;
    border-radius: 3px;
    background: var(--heat-0);
}

.heat:hover,
.heat:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 0;
}

.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--heat-4); }
.heat-5 { background: var(--heat-5); }
.heat-6 { background: var(--heat-6); }

.heat-scale {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.heat-scale .heat {
    width: 16px;
    height: 10px;
}

.heat-scale .heat:hover { outline: 0; }

/* 每日可用率 */
.uptime-strip {
    display: flex;
    gap: 2px;
    height: 32px;
}

.uptime-day {
    flex: 1;
    min-width: 2px;
    border-radius: 2px;
    background: var(--surface-3);
}

.uptime-day:hover,
.uptime-day:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 0;
}

.uptime-day.is-good { background: var(--good); }
.uptime-day.is-warning { background: var(--warning); }
.uptime-day.is-serious { background: var(--serious); }
.uptime-day.is-critical { background: var(--critical); }

.uptime-strip-sm { height: 20px; }

.uptime-axis {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    color: var(--chart-label);
    font-size: 11.5px;
}

/* ---------- 問題列表 ---------- */

.issue-row-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    min-width: 0;
}

.issue-class {
    color: var(--text);
    font-weight: 600;
    overflow-wrap: anywhere;
}

a.issue-class:hover { color: var(--accent-text); }

.issue-message {
    margin-top: 2px;
    color: var(--text-2);
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.issue-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    margin-top: 6px;
    color: var(--text-3);
    font-size: 12.5px;
}

.issue-meta .mono { font-size: 12px; }

/* ---------- 問題詳情 ---------- */

.issue-head {
    padding: 20px 22px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.issue-head-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.issue-head-title {
    flex: 1 1 320px;
    min-width: 0;
}

.issue-head-class {
    font-family: var(--font-mono);
    font-size: 17px;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.issue-head-message {
    margin-top: 8px;
    color: var(--text-2);
    font-size: 14.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 240px;
    overflow-y: auto;
}

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px 20px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.fact-label {
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
}

.fact-value {
    margin-top: 2px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.fact-value.is-large {
    font-size: 20px;
    line-height: 1.2;
}

.occurrence-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 14px 10px 18px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* 堆疊追蹤 */
.frames {
    display: flex;
    flex-direction: column;
}

.frame {
    border-bottom: 1px solid var(--border);
}

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

.frame-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
    padding: 10px 18px;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.frame-head:hover { background: var(--surface-2); }

.frame-head .chevron {
    margin-top: 3px;
    color: var(--text-3);
    transition: transform 0.12s;
}

.frame.is-open .frame-head .chevron { transform: rotate(90deg); }

.frame-index {
    width: 22px;
    margin-top: 1px;
    color: var(--text-3);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    flex: none;
}

.frame-info { flex: 1; min-width: 0; }

.frame-file {
    font-family: var(--font-mono);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.frame-file .line { color: var(--text-3); }

.frame-call {
    margin-top: 1px;
    color: var(--text-3);
    font-family: var(--font-mono);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.frame.is-vendor .frame-file { color: var(--text-2); }
.frame.is-app .frame-file { font-weight: 600; }

.frame-body { display: none; }
.frame.is-open .frame-body { display: block; }

.frames.hide-vendor .frame.is-vendor { display: none; }

.frame-group {
    display: none;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 18px 7px 50px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font: inherit;
    font-size: 12.5px;
    text-align: left;
    cursor: pointer;
}

.frame-group:hover { color: var(--text); }
.frames.hide-vendor .frame-group { display: flex; }

.code {
    margin: 0;
    padding: 8px 0;
    overflow-x: auto;
    border-top: 1px solid var(--border);
    background: var(--code-bg);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.65;
    tab-size: 4;
}

.code-line {
    display: flex;
    min-width: max-content;
    padding-right: 18px;
    border-left: 3px solid transparent;
}

.code-line.is-highlighted {
    background: var(--code-highlight);
    border-left-color: var(--code-highlight-border);
}

.code-no {
    width: 56px;
    padding-right: 14px;
    color: var(--text-3);
    text-align: right;
    user-select: none;
    flex: none;
}

.code-text { white-space: pre; }

.tok-keyword { color: var(--tok-keyword); }
.tok-string { color: var(--tok-string); }
.tok-variable { color: var(--tok-variable); }
.tok-number { color: var(--tok-number); }
.tok-comment { color: var(--tok-comment); font-style: italic; }
.tok-tag { color: var(--tok-tag); }
.tok-html { color: var(--text-2); }

.code-missing {
    padding: 10px 18px 12px 50px;
    border-top: 1px solid var(--border);
    background: var(--code-bg);
    color: var(--text-3);
    font-size: 12.5px;
}

/* 鍵值資料 */
.kv {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.kv th,
.kv td {
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.kv tr:last-child th,
.kv tr:last-child td { border-bottom: 0; }

.kv th {
    width: 220px;
    max-width: 40%;
    color: var(--text-2);
    font-family: var(--font-mono);
    font-size: 12.5px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.kv td {
    font-family: var(--font-mono);
    font-size: 12.5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.kv td.is-text { font-family: var(--font); font-size: 13px; }
.kv .is-null { color: var(--text-3); font-style: italic; }
.kv .is-masked { color: var(--text-3); letter-spacing: 0.08em; }

.kv-title {
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
}

.kv-title:not(:first-child) { border-top: 1px solid var(--border); }

.section-tabs {
    display: flex;
    gap: 2px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar { display: none; }
.section-tabs .tab { padding: 12px 10px 11px; }

.query {
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
}

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

.query-sql {
    font-family: var(--font-mono);
    font-size: 12.5px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.query-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 4px;
    color: var(--text-3);
    font-size: 12px;
}

.log-line {
    display: flex;
    gap: 10px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
}

.log-line:last-child { border-bottom: 0; }
.log-time { color: var(--text-3); font-family: var(--font-mono); white-space: nowrap; }
.log-level { width: 64px; font-weight: 600; font-family: var(--font-mono); flex: none; }
.log-level.is-error { color: var(--critical-text); }
.log-level.is-warning { color: var(--warning-text); }
.log-message { flex: 1; min-width: 0; font-family: var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 安裝說明 ---------- */

.steps {
    display: flex;
    flex-direction: column;
    gap: 22px;
    counter-reset: step;
}

.step {
    position: relative;
    padding-left: 44px;
    counter-increment: step;
}

.step::before {
    content: counter(step);
    position: absolute;
    top: -2px;
    left: 0;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-weight: 650;
    font-size: 13px;
}

.step-title {
    margin-bottom: 4px;
    font-size: 14.5px;
    font-weight: 600;
}

.step-desc {
    margin-bottom: 10px;
    color: var(--text-2);
}

.snippet {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
}

.snippet pre {
    margin: 0;
    padding: 12px 88px 12px 14px;
    overflow-x: auto;
    font-size: 12.5px;
    line-height: 1.7;
    white-space: pre;
}

.snippet .copy {
    position: absolute;
    top: 7px;
    right: 7px;
    box-shadow: 0 0 0 6px var(--code-bg);
}

.snippet + .snippet { margin-top: 8px; }

.key-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    font-family: var(--font-mono);
    font-size: 13px;
}

.key-box span {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* 可摺疊區塊 */
details.disclosure {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

details.disclosure > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

details.disclosure > summary::-webkit-details-marker { display: none; }

details.disclosure > summary::before {
    content: "";
    width: 6px;
    height: 6px;
    border-right: 1.75px solid var(--text-3);
    border-bottom: 1.75px solid var(--text-3);
    transform: rotate(-45deg);
    transition: transform 0.12s;
}

details.disclosure[open] > summary::before { transform: rotate(45deg); }

details.disclosure > .disclosure-body {
    padding: 4px 14px 14px;
}

details.disclosure + details.disclosure { margin-top: 8px; }

/* ---------- 登入頁 ---------- */

.auth {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 30px 30px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
    font-size: 18px;
    font-weight: 650;
}

.auth-title { font-size: 19px; }
.auth-subtitle { margin: 4px 0 22px; color: var(--text-2); }
.auth .btn-primary { width: 100%; height: 38px; }

/* ---------- 其他 ---------- */

.definition {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 10px 16px;
    font-size: 13.5px;
}

.definition dt { color: var(--text-2); }
.definition dd { margin: 0; overflow-wrap: anywhere; }

.list-plain {
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.list-item:last-child { border-bottom: 0; }
.list-item-body { flex: 1; min-width: 0; }

.danger-zone { border-color: color-mix(in srgb, var(--critical) 45%, var(--border)); }
.danger-zone .card-title { color: var(--critical-text); }

/* ---------- 響應式 ---------- */

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.18s ease;
        box-shadow: none;
    }

    .app.nav-open .sidebar {
        transform: none;
        box-shadow: var(--shadow-md);
    }

    .app.nav-open .backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 35;
        background: rgba(0, 0, 0, 0.4);
    }

    .main { margin-left: 0; }
    .topbar .menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 18px 16px 48px; }
    .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
    .hide-mobile { display: none !important; }
    .kv th { width: 130px; }
    .definition { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
    .definition dd { margin-bottom: 10px; }
}

@media (max-width: 560px) {
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .heatmap { grid-template-columns: 24px repeat(24, minmax(0, 1fr)); gap: 1px; }
    .heat { height: 16px; border-radius: 2px; }
    .heatmap-hour:nth-child(odd) { visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
