/* -------------------------------------------------------------
   SmartCare Pro — 工具類介面樣式
   原則：單一半透明浮動層、實體卡片、語意色彩代幣、系統字體。
   ------------------------------------------------------------- */

:root {
    color-scheme: light dark;

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, "PingFang TC", "Microsoft JhengHei",
        "Noto Sans TC", sans-serif;

    /* 表面與線條（淺色） */
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-2: #f2f2f5;
    --fill-hover: rgba(0, 0, 0, 0.04);
    --hairline: rgba(60, 60, 67, 0.14);
    --hairline-strong: rgba(60, 60, 67, 0.26);

    /* 文字（淺色） */
    --text-1: #1d1d1f;
    --text-2: rgba(60, 60, 67, 0.78);
    --text-3: rgba(60, 60, 67, 0.7);

    /* 語意色（淺色，正文對比 ≥ WCAG AA） */
    --accent: #0066cc;
    --accent-fill: rgba(0, 102, 204, 0.1);
    --success: #248a3d;
    --warning: #b45309;
    --error: #d70015;

    /* 狀態點（裝飾用，可較鮮明） */
    --dot-accent: #007aff;
    --dot-success: #34c759;
    --dot-warning: #ff9f0a;
    --dot-error: #ff3b30;
    --dot-neutral: #8e8e93;

    /* 頂層半透明結構 */
    --chrome-bg: rgba(255, 255, 255, 0.78);
    --chrome-blur: saturate(180%) blur(20px);
    --edge-highlight: rgba(255, 255, 255, 0.7);
    --chrome-fade-base: rgba(245, 245, 247, 0.9);

    --seg-bg: rgba(120, 120, 128, 0.12);
    --toast-bg: rgba(250, 250, 250, 0.92);
    --toast-text: var(--text-1);

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 14px rgba(0, 0, 0, 0.06);
    --shadow-thumb: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--hairline);

    --radius-card: 0.75rem;
    --radius-field: 0.625rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0c;
        --surface: #161618;
        --surface-2: #1e1e21;
        --fill-hover: rgba(255, 255, 255, 0.05);
        --hairline: rgba(255, 255, 255, 0.12);
        --hairline-strong: rgba(255, 255, 255, 0.24);

        --text-1: rgba(255, 255, 255, 0.92);
        --text-2: rgba(235, 235, 245, 0.7);
        --text-3: rgba(235, 235, 245, 0.58);

        --accent: #4aa3ff;
        --accent-fill: rgba(74, 163, 255, 0.16);
        --success: #32d074;
        --warning: #ffb340;
        --error: #ff6961;

        --dot-accent: #0a84ff;
        --dot-success: #30d158;
        --dot-warning: #ff9f0a;
        --dot-error: #ff453a;
        --dot-neutral: #98989d;

        --chrome-bg: rgba(20, 20, 22, 0.75);
        --edge-highlight: rgba(255, 255, 255, 0.09);
        --chrome-fade-base: rgba(10, 10, 12, 0.9);

        --seg-bg: rgba(120, 120, 128, 0.22);
        --toast-bg: rgba(40, 40, 43, 0.94);
        --toast-text: rgba(255, 255, 255, 0.92);

        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
        --shadow-thumb: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 0.5px rgba(255, 255, 255, 0.14);
    }
}

/* 減少透明度：頂層改為不透明實面，捨棄模糊 */
@media (prefers-reduced-transparency: reduce) {
    :root {
        --chrome-bg: var(--surface);
        --chrome-blur: none;
        --toast-bg: var(--surface);
    }
}

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

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

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

body {
    background-color: var(--bg);
    color: var(--text-1);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    line-height: 1.5;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
}

::selection { background: var(--accent-fill); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

button { font-family: inherit; }
input, select { font-family: inherit; }

.container {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1rem clamp(1rem, 4vw, 1.5rem) 3rem;
}

/* -------------------------------------------------------------
   頂層浮動結構（唯一半透明表面）
   ------------------------------------------------------------- */

.chrome {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--chrome-bg);
    -webkit-backdrop-filter: var(--chrome-blur);
    backdrop-filter: var(--chrome-blur);
    box-shadow:
        inset 0 1px 0 var(--edge-highlight),
        0 -0.5px 0 var(--hairline-strong) inset;
}

/* 捲動邊緣淡出：內容自 chrome 底下滾過時柔和隱沒 */
.chrome::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 0.75rem;
    background: linear-gradient(to bottom, var(--chrome-fade-base), transparent);
    pointer-events: none;
}

.topbar,
.tabs {
    max-width: 72rem;
    margin: 0 auto;
    padding-inline: clamp(1rem, 4vw, 1.5rem);
}

.topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: clamp(1rem, 3vw, 2rem);
    padding-block: 0.625rem 0.5rem;
}

.brand { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }

.brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.875rem;
    height: 1.875rem;
    border-radius: 0.5rem;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-name {
    font-size: 0.9375rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.brand-sub { font-size: 0.6875rem; color: var(--text-2); white-space: nowrap; }

.account { display: flex; flex-direction: column; align-items: flex-end; gap: 0.0625rem; min-width: 0; }

.account-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.conn-dot {
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background: var(--dot-success);
    flex-shrink: 0;
}

.account-meta {
    font-size: 0.6875rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

@media (max-width: 47.99rem) {
    .account-meta, .brand-sub { display: none; }
}

/* 分段控制（Segmented Control） */
.tabs {
    display: flex;
    gap: 0.25rem;
    padding-block: 0.25rem 0.5rem;
}

.tab-btn {
    flex: 1 1 0;
    min-height: 2.75rem;
    padding: 0 0.875rem;
    border: none;
    border-radius: 0.5625rem;
    background: transparent;
    color: var(--text-2);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.18s ease-out, color 0.18s ease-out;
}

.tab-btn:hover:not(.active) { background: var(--fill-hover); color: var(--text-1); }

.tab-btn.active {
    background: var(--surface);
    color: var(--text-1);
    font-weight: 600;
    box-shadow: var(--shadow-thumb);
}

.tab-btn:active:not(.active) { transform: scale(0.97); }

@media (max-width: 45rem) {
    .tabs {
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tab-btn { flex: 0 0 auto; min-width: 5.5rem; }
}

/* -------------------------------------------------------------
   卡片與統計列
   ------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.stat-strip {
    display: flex;
    align-items: stretch;
    margin-bottom: 1rem;
    padding-block: 0.75rem;
}

.stat {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding-inline: 1rem;
}

.stat:first-child { padding-left: 1.125rem; }
.stat + .stat { border-left: 1px solid var(--hairline); }

.stat-label { font-size: 0.6875rem; color: var(--text-2); }

.stat-value {
    font-size: 1.0625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-sync { font-size: 0.875rem; font-weight: 500; color: var(--text-2); }

@media (max-width: 33rem) {
    .stat-strip { padding-block: 0.5rem; }
    .stat { padding-inline: 0.625rem; }
    .stat-label { font-size: 0.625rem; }
    .stat-value { font-size: 0.9375rem; }
}

/* -------------------------------------------------------------
   面板
   ------------------------------------------------------------- */

.panel-intro {
    font-size: 0.8125rem;
    color: var(--text-2);
    margin-bottom: 0.875rem;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.875rem;
}

.panel-heading .panel-intro { margin: 0.25rem 0 0; }

.panel-title {
    font-size: clamp(1.25rem, 2vw, 1.5rem);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.source-note {
    flex-shrink: 0;
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 550;
    padding-top: 0.25rem;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panelIn 0.2s ease-out; }

@keyframes panelIn {
    from { opacity: 0; transform: translateY(0.25rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
   工具列
   ------------------------------------------------------------- */

.toolbar { padding: 0.875rem; margin-bottom: 0.875rem; }

.toolbar-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.625rem;
}

.field-pair {
    display: flex;
    flex-direction: column;
    gap: 0.3125rem;
    min-width: 0;
}

.field-pair.grow { flex: 1 1 14rem; }

.field-pair > label { font-size: 0.75rem; font-weight: 500; color: var(--text-2); }

.toolbar-actions { display: flex; gap: 0.625rem; margin-left: auto; }

@media (max-width: 47.99rem) {
    .field-pair { width: 100%; }
    .toolbar-actions { width: 100%; margin-left: 0; overflow-x: auto; }
    .toolbar-actions .btn { flex: 1 0 auto; }
}

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

.form-card { padding: 1.125rem; }

.form-card + .table-card,
.toolbar + .table-card,
.table-card + .form-card { margin-top: 0.875rem; }

#tab-clock .form-card { max-width: 40rem; }
#tab-jobs .form-card { max-width: 40rem; margin-bottom: 0.875rem; }

.card-title {
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin-bottom: 0.875rem;
}

.form-stack { display: flex; flex-direction: column; gap: 1rem; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }

.form-group > label { font-size: 0.8125rem; font-weight: 500; color: var(--text-2); }

.hint { font-size: 0.75rem; color: var(--text-3); }

.form-divider { height: 1px; background: var(--hairline); }

@media (max-width: 37.5rem) {
    .form-row { grid-template-columns: 1fr; }
}

/* 輸入欄位（datetime-local / month 採原生外觀，僅換膚） */
.field {
    appearance: none;
    -webkit-appearance: none;
    background: var(--surface);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius-field);
    padding: 0.55rem 0.75rem;
    min-height: 2.75rem;
    font-size: 0.9375rem;
    color: var(--text-1);
    width: 100%;
    transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.field:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-fill);
}

select.field {
    background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
        linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
    background-position: calc(100% - 1.05rem) 50%, calc(100% - 0.75rem) 50%;
    background-size: 0.3125rem 0.3125rem;
    background-repeat: no-repeat;
    padding-right: 2rem;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    min-height: 2.75rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-field);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.1s ease-out, filter 0.15s ease-out, opacity 0.15s ease-out;
}

.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 0.1s; }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-secondary { background: var(--accent-fill); color: var(--accent); }

.btn-neutral { background: var(--seg-bg); color: var(--text-1); }

.btn-lg { min-height: 3rem; font-size: 0.9375rem; }
.btn-block { width: 100%; }

/* GPS 按鈕載入狀態 */
.spinner {
    display: none;
    width: 0.875em;
    height: 0.875em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn.is-loading .spinner { display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

/* 表格內迷你按鈕：視覺緊湊、點擊熱區 ≥44px（偽元素外擴） */
.row-actions { display: inline-flex; gap: 0.375rem; }

.btn-mini {
    position: relative;
    min-height: 1.75rem;
    padding: 0.1875rem 0.6875rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease-out, filter 0.15s ease-out;
}

.btn-mini::before {
    content: "";
    position: absolute;
    inset: -0.625rem;
}

.btn-mini:active { transform: scale(0.97); }

.mini-in  { background: var(--accent-fill); color: var(--accent); }
.mini-out { background: var(--seg-bg); color: var(--text-1); }
.mini-danger { background: transparent; color: var(--error); }

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

.table-card { overflow: visible; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8438rem;
}

.data-table th {
    position: sticky;
    top: var(--thead-top, 7.25rem);
    z-index: 5;
    background: var(--surface);
    text-align: left;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-2);
    letter-spacing: 0.02em;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--hairline-strong);
    white-space: nowrap;
}

.data-table td {
    padding: 0.6875rem 0.75rem;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--fill-hover); }

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

.case-name { font-weight: 600; }

.mark { font-variant-numeric: tabular-nums; font-size: 0.8125rem; }
.mark-ok { color: var(--success); font-weight: 550; }
.mark-none { color: var(--text-3); font-size: 0.75rem; }

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.7813rem;
}

.empty-cell {
    text-align: center;
    color: var(--text-2);
    font-size: 0.8438rem;
    padding: 2.25rem 1rem !important;
}

/* 任務狀態：圓點 + 文字 */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    font-size: 0.7813rem;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
}

.status::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--dot, var(--dot-neutral));
    flex-shrink: 0;
}

.status-scheduled            { --dot: var(--dot-accent); }
.status-awaiting_confirmation{ --dot: var(--dot-warning); }
.status-completed            { --dot: var(--dot-success); }
.status-expired              { --dot: var(--dot-neutral); }
.status-cancelled            { --dot: var(--dot-error); }

/* 窄螢幕：表格轉為堆疊卡片列（保留 <table> 結構） */
@media (max-width: 45rem) {
    .data-table thead { display: none; }

    .data-table, .data-table tbody,
    .data-table tr, .data-table td { display: block; width: 100%; }

    .data-table tbody { padding: 0.625rem; }

    .data-table tr {
        border: 1px solid var(--hairline);
        border-radius: 0.625rem;
        background: var(--surface);
        padding: 0.25rem 0.75rem;
        margin-bottom: 0.625rem;
    }

    .data-table tbody tr:last-child { margin-bottom: 0; }

    .data-table td {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.5rem 0;
        border-bottom: 1px solid var(--hairline);
        text-align: right;
    }

    .data-table td:last-child { border-bottom: none; }

    .data-table td[data-label]::before {
        content: attr(data-label);
        color: var(--text-2);
        font-size: 0.75rem;
        text-align: left;
        flex-shrink: 0;
    }

    .data-table tbody tr:hover td { background: transparent; }
    .empty-cell { justify-content: center; }
    .empty-cell::before { content: none !important; }
}

/* -------------------------------------------------------------
   Toast 通知
   ------------------------------------------------------------- */

.toast-container {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: min(26rem, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: var(--toast-bg);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 0 0 0.5px var(--hairline), 0 8px 24px rgba(0, 0, 0, 0.22);
    color: var(--toast-text);
    font-size: 0.8438rem;
    animation: toastIn 0.22s ease-out;
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

.toast::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--kind, var(--dot-accent));
    flex-shrink: 0;
}

.toast.success { --kind: var(--dot-success); }
.toast.error   { --kind: var(--dot-error); }
.toast.warning { --kind: var(--dot-warning); }
.toast.info    { --kind: var(--dot-accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(0.5rem) scale(0.96); filter: blur(4px); }
    to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

/* -------------------------------------------------------------
   動態與無障礙偏好
   ------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-property: opacity !important;
        transform: none !important;
    }
}

/* -------------------------------------------------------------
   列印
   ------------------------------------------------------------- */

@media print {
    body { background: #fff; color: #000; }

    .chrome, .toolbar, .toast-container,
    .panel-intro, .row-actions { display: none !important; }

    .card {
        border: none;
        box-shadow: none;
        background: none;
    }

    .tab-panel { display: none !important; }
    .tab-panel.active { display: block !important; }

    .data-table { font-size: 11px; }
    .data-table th, .data-table td {
        color: #000;
        border-bottom: 1px solid #999;
        position: static;
    }
}

/* -------------------------------------------------------------
   多使用者切換器
   ------------------------------------------------------------- */

.account {
    display: grid;
    justify-items: end;
    gap: 0.1875rem;
    min-width: 0;
}

.user-switcher {
    display: grid;
    grid-template-columns: auto minmax(10rem, 12rem) repeat(3, auto);
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.user-switcher-label {
    font-size: 0.6875rem;
    color: var(--text-2);
}

.field-compact {
    min-height: 2.125rem;
    padding-block: 0.25rem;
    font-size: 0.8125rem;
}

.user-switcher .btn-mini {
    min-height: 2.125rem;
    padding-inline: 0.625rem;
}

@media (max-width: 52rem) {
    .topbar {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .account {
        width: 100%;
        justify-items: stretch;
    }

    .account-status { justify-self: start; }
    .user-switcher { grid-template-columns: minmax(0, 1fr) repeat(3, auto); }
    .user-switcher-label { display: none; }
    .account-meta { display: none; }
}

@media (max-width: 30rem) {
    .brand-mark { width: 2rem; height: 2rem; }
    .brand-name { font-size: 1rem; }
    .user-switcher .btn-mini { padding-inline: 0.5rem; }
}

/* -------------------------------------------------------------
   月報表
   ------------------------------------------------------------- */

.report-toolbar { margin-bottom: 0.75rem; }

.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4375rem;
    min-height: 2.25rem;
    padding-inline: 0.75rem;
    border-radius: var(--radius-field);
    background: var(--surface-sunken, rgba(120, 120, 128, 0.08));
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
}

.check-inline input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent-fill);
    cursor: pointer;
}

.check-inline:has(input:checked) {
    color: var(--text-1);
}

.sim-banner {
    margin-bottom: 0.875rem;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--dot-warning);
    border-radius: var(--radius-field);
    background: var(--dot-warning-bg, rgba(255, 214, 10, 0.12));
    color: var(--text-1);
    font-size: 0.8125rem;
    font-weight: 500;
}

.report-switcher {
    display: inline-grid;
    grid-template-columns: repeat(3, auto);
    gap: 0.1875rem;
    padding: 0.1875rem;
    margin-bottom: 0.875rem;
    border-radius: var(--radius-field);
    background: var(--seg-bg);
}

.report-switcher[hidden] { display: none; }

.report-view-btn {
    min-height: 2.25rem;
    padding-inline: 0.875rem;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-2);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.16s ease-out, color 0.16s ease-out, transform 0.1s ease-out;
}

.report-view-btn:hover:not(.active) { color: var(--text-1); }
.report-view-btn:active { transform: scale(0.97); }

.report-view-btn.active {
    background: var(--surface);
    color: var(--text-1);
    box-shadow: var(--shadow-thumb);
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 1.25rem;
    border-block: 1px solid var(--hairline);
}

.report-metric {
    display: grid;
    gap: 0.1875rem;
    min-width: 0;
    padding: 0.875rem 1rem;
}

.report-metric + .report-metric { border-left: 1px solid var(--hairline); }
.report-metric span { color: var(--text-2); font-size: 0.6875rem; }

.report-metric strong {
    overflow: hidden;
    color: var(--text-1);
    font-size: 1.0625rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.015em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-metric.emphasized strong { color: var(--accent); }

.report-view[hidden] { display: none; }
.report-view.active { animation: panelIn 0.2s ease-out; }

.report-view-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--hairline-strong);
}

.report-view-heading h2 {
    font-size: 1.125rem;
    line-height: 1.25;
    letter-spacing: -0.015em;
}

.report-view-heading p {
    margin-top: 0.1875rem;
    color: var(--text-2);
    font-size: 0.75rem;
}

.report-view-heading > span {
    flex-shrink: 0;
    color: var(--text-2);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.report-case-list { border-bottom: 1px solid var(--hairline-strong); }

.report-case-disclosure {
    border-top: 1px solid var(--hairline);
    background: transparent;
}

.report-case-disclosure:first-child { border-top: 0; }

.report-case-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 0.25rem;
    cursor: pointer;
    list-style-position: outside;
}

.report-case-disclosure > summary:active { opacity: 0.72; }

.report-case-identity {
    display: grid;
    gap: 0.125rem;
    min-width: 0;
}

.report-case-identity strong {
    font-size: 0.9375rem;
    letter-spacing: -0.01em;
}

.report-case-identity small {
    overflow: hidden;
    color: var(--text-2);
    font-size: 0.75rem;
    font-weight: 450;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-case-total {
    flex-shrink: 0;
    color: var(--text-2);
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

.fee-disclosure .report-case-total {
    color: var(--accent);
    font-size: 0.9375rem;
    font-weight: 650;
}

.report-case-body {
    padding: 0 0.25rem 1rem;
}

.report-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 1rem;
    border-block: 1px solid var(--hairline);
}

.report-facts > div {
    display: grid;
    gap: 0.125rem;
    padding: 0.625rem 0.75rem;
}

.report-facts > div + div { border-left: 1px solid var(--hairline); }
.report-facts dt { color: var(--text-2); font-size: 0.6875rem; }
.report-facts dd { font-size: 0.8125rem; font-weight: 600; }

.approved-items {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.approved-items h3 {
    font-size: 0.8125rem;
    font-weight: 650;
}

.approved-items ul {
    display: grid;
    gap: 0.25rem;
    padding-left: 1.125rem;
    color: var(--text-2);
    font-size: 0.8125rem;
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-field);
    background: var(--surface);
}

.report-table { min-width: 38rem; font-size: 0.75rem; }
.report-table.fee-table { min-width: 54rem; }
.report-table th { position: static; top: auto; }
.report-table td { padding-block: 0.625rem; }

.report-table tfoot th,
.report-table tfoot td {
    padding: 0.6875rem 0.75rem;
    border-top: 1px solid var(--hairline-strong);
    background: var(--surface-2);
    font-weight: 650;
}

.report-status {
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 650;
    white-space: nowrap;
}

.report-section-title,
.report-total-section h3 {
    margin: 1.125rem 0 0.5rem;
    font-size: 0.875rem;
    letter-spacing: -0.005em;
}

.report-total-section {
    margin-top: 1.25rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--hairline-strong);
}

.report-note {
    margin-top: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-left: 3px solid var(--warning);
    border-radius: 0.25rem;
    background: rgba(180, 83, 9, 0.08);
    color: var(--warning);
    font-size: 0.75rem;
}

.empty-state,
.inline-empty {
    display: grid;
    justify-items: start;
    gap: 0.5rem;
    padding: clamp(2rem, 7vw, 4rem) 0.25rem;
    color: var(--text-2);
    font-size: 0.8125rem;
}

.empty-state .btn { margin-top: 0.25rem; }
.empty-title { color: var(--text-1); font-size: 1rem; font-weight: 650; }
.error-state { color: var(--error); }
.error-state .empty-title { color: var(--error); }

.inline-empty {
    padding-block: 2rem;
    border-bottom: 1px solid var(--hairline);
}

.report-skeleton {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 8rem));
    gap: 0.5rem;
    padding-block: 0.5rem;
}

.report-skeleton > span,
.skeleton-block {
    display: block;
    height: 2.75rem;
    border-radius: var(--radius-field);
    background: var(--surface-2);
    animation: skeletonPulse 1.1s ease-in-out infinite alternate;
}

.skeleton-block {
    grid-column: 1 / -1;
    height: 14rem;
}

@keyframes skeletonPulse {
    from { opacity: 0.55; }
    to { opacity: 1; }
}

@media (max-width: 45rem) {
    .panel-heading { display: grid; gap: 0.25rem; }
    .source-note { padding-top: 0; }
    .report-switcher { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
    .report-view-btn { padding-inline: 0.5rem; }
    .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-metric { padding-inline: 0.75rem; border-bottom: 1px solid var(--hairline); }
    .report-metric + .report-metric { border-left: 0; }
    .report-metric:nth-child(even) { border-left: 1px solid var(--hairline); }
    .report-metric:last-child { grid-column: 1 / -1; border-bottom: 0; border-left: 0; }
    .report-view-heading { align-items: start; }
    .report-view-heading > span { display: none; }
    .report-case-disclosure > summary { align-items: flex-start; }
    .report-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-facts > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--hairline); }
    .report-facts > div:nth-child(4) { border-top: 1px solid var(--hairline); }
    .approved-items { grid-template-columns: 1fr; gap: 0.375rem; }

    .table-scroll .report-table { display: table; width: 100%; }
    .table-scroll .report-table thead { display: table-header-group; }
    .table-scroll .report-table tbody { display: table-row-group; padding: 0; }
    .table-scroll .report-table tfoot { display: table-footer-group; }
    .table-scroll .report-table tr { display: table-row; width: auto; padding: 0; margin: 0; border: 0; }
    .table-scroll .report-table th,
    .table-scroll .report-table td {
        display: table-cell;
        width: auto;
        padding: 0.625rem 0.75rem;
        border-bottom: 1px solid var(--hairline);
        text-align: left;
    }
    .table-scroll .report-table td.num { text-align: right; }
    .table-scroll .report-table td::before { display: none; }
}

@media print {
    .report-switcher, .source-note { display: none !important; }
    #tab-report [data-report-panel] { display: block !important; }
    .report-case-disclosure > :not(summary) { display: block !important; }
    .report-summary { grid-template-columns: repeat(5, 1fr); }
    .table-scroll { overflow: visible; border-color: #aaa; }
    .report-table { min-width: 0; }
}
