/* v6.x.4b 充電明細 — Receipt-style + 橫向時間軸
   - 沒有 card 框中框,只有髮絲線分段
   - Hairline dividers 取代 box-shadow、border
   - Inter weight scale 做 display,ui-monospace 做 IDs/時間/數字
   - Signature: thermal-printer footer + horizontal timeline (4 nodes 比例分隔)
   Tab-nums:全站 `font-feature-settings: "tnum" 1`,瀏覽器支援時數字會等寬對齊 */

:root {
    --paper:        #fbfcf9;
    --paper-card:   #ffffff;
    --ink:          #1a2a1c;
    --ink-mid:      #3a4a3c;
    --ink-soft:     #7a8a7c;
    --ink-faint:    #aab5ac;
    --line:         #d8e2dc;
    --line-soft:    #e9eee9;
    --brand:        #1f9d3e;
    --brand-deep:   #157a2e;
    --brand-tint:   #e9f6ed;
    --pay:          #00c300;
    --warn:         #d04545;
    --warn-tint:    #fdecec;
    --info:         #3b7ddd;
    --info-tint:    #e8f0fc;
    --kpi:          #0a7e9f;

    --type-display: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
                    "PingFang TC", "Microsoft JhengHei", sans-serif;
    --type-mono:    ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono",
                    "Courier New", monospace;

    --radius:       4px;
    --tnum:         "tnum" 1, "lnum" 1;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--type-display);
    font-feature-settings: var(--tnum);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    font-size: 14px;
    line-height: 1.5;
}

.mono {
    font-family: var(--type-mono);
    font-feature-settings: var(--tnum);
    letter-spacing: -0.01em;
}

.eyebrow {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.container {
    max-width: 480px;
    margin: 0 auto;
    background: var(--paper-card);
    min-height: 100vh;
    padding-bottom: 56px;
    overflow-x: hidden;
}

/* ========== 主體:receipt ========== */

.receipt {
    padding: 8px 22px 0;
}

/* ========== 1) 身份條 ========== */

.r_id {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 18px 0 20px;
    border-bottom: 1px solid var(--line);
}

.r_id_avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-tint);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.r_id_text {
    min-width: 0;
}

.r_id_name {
    margin: 0 0 3px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.r_id_addr {
    margin: 0;
    font-size: 12px;
    color: var(--ink-soft);
    line-height: 1.4;
}

.r_id_sep {
    margin: 0 5px;
    color: var(--ink-faint);
}

.r_id_status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--brand);
    color: var(--brand);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: var(--brand-tint);
}

/* ========== 2) 金額 + KPIs ========== */

.r_amount {
    padding: 24px 0 22px;
    border-bottom: 1px solid var(--line);
}

.r_amount_head {
    margin-bottom: 16px;
}

.r_amount_num {
    margin-top: 8px;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
    display: flex;
    align-items: baseline;
    letter-spacing: -0.04em;
    font-size: clamp(46px, 13vw, 60px);
}

.r_amount_sign {
    font-size: 0.55em;
    color: var(--ink-soft);
    font-weight: 600;
    margin-right: 4px;
    transform: translateY(-0.4em);
}

.r_amount_value {
    color: var(--brand);
    font-variant-numeric: tabular-nums;
}

.r_amount_unit {
    font-size: 0.32em;
    color: var(--ink-soft);
    font-weight: 600;
    margin-left: 6px;
    transform: translateY(-0.4em);
}

.r_amount_pay {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.r_pay_pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border: 1px solid #d3f0d3;
    border-radius: 3px;
    background: #f4faf4;
}

.r_pay_label {
    font-size: 11px;
    font-weight: 700;
    color: var(--pay);
    letter-spacing: 0.02em;
}

.r_pay_sub {
    font-size: 12px;
    color: var(--ink-soft);
}

/* KPI 4 欄 */

.r_kpis {
    list-style: none;
    margin: 0 0 22px;
    padding: 14px 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px dashed var(--line);
    border-bottom: 1px dashed var(--line);
}

.r_kpis li {
    padding: 0 12px;
    border-right: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.r_kpis li .eyebrow {
    text-align: center;
}

.r_kpis li .r_kpi_value {
    text-align: center;
}

.r_kpis li:first-child {
    padding-left: 4px;
}

.r_kpis li:last-child {
    border-right: none;
    padding-right: 4px;
}

.r_kpi_value {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.r_kpi_value.accent {
    color: var(--brand);
}

.r_kpi_unit {
    font-size: 11px;
    color: var(--ink-soft);
    font-weight: 500;
    margin-left: 1px;
}

/* ========== 3) 流程 4 節點 — 橫向時間軸 ========== */

.r_nodes {
    padding: 24px 0 22px;
    border-bottom: 1px solid var(--line);
}

.r_section_title {
    margin: 0 0 18px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.r_section_hint {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
    text-transform: none;
}

/* timeline 本體 */

.tl {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding: 4px 4px 0;
}

/* 連線軌道 */

.tl_line {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 41px;
    height: 2px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
    z-index: 0;
}

.tl_line_fill {
    width: 0;
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--brand) 0%,
        var(--brand) 65%,
        var(--brand-deep) 100%
    );
    border-radius: 2px;
    transition: width 1.4s cubic-bezier(0.4, 0, 0.2, 1) 0.25s;
}

.tl.is_animated .tl_line_fill {
    width: 100%;
}

/* 中間 spacer segments (flex 比例,確保連線最短可見) */

.tl_gap {
    flex-shrink: 0;
}

.tl_gap--long {
    flex: 4 0 36px;       /* 充電期間長,占主要視覺寬度 */
}

.tl_gap--short {
    flex: 1 0 18px;       /* 結束後三個事件,間距短但仍可見 */
}

/* 節點按鈕 */

.tl_node {
    flex-shrink: 0;
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 1;
    background: var(--paper-card);
    border: 0;
    cursor: pointer;
    padding: 0;
    font: inherit;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.2s ease;
    outline: none;
}

.tl_node:focus-visible .tl_dot {
    box-shadow: 0 0 0 3px var(--paper-card),
                0 0 0 6px var(--info);
}

/* 節點上方時間 */

.tl_time {
    font-size: 10px;
    color: var(--ink-soft);
    margin-bottom: 6px;
    font-weight: 500;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* 圓點 + icon */

.tl_dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: grid;
    place-items: center;
    margin-bottom: 8px;
    position: relative;
    box-shadow: 0 0 0 3px var(--paper-card);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.28s ease,
                background 0.2s ease;
    opacity: 0;
    transform: scale(0.6);
}

.tl.is_animated .tl_node.is_visible .tl_dot {
    opacity: 1;
    transform: scale(1);
}

/* 各節點配色 */

.tl_node--stop .tl_dot {
    background: var(--warn);
}

.tl_node--order .tl_dot {
    background: var(--info);
}

.tl_node--payment .tl_dot {
    background: var(--brand);
}

/* 最後一個節點(success)預設 subtle glow */

.tl_node--payment .tl_dot::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(31, 157, 62, 0.22) 0%, transparent 70%);
    z-index: -1;
    opacity: 0;
    animation: tl_success_pulse 2.4s ease-in-out 1.6s infinite;
}

@keyframes tl_success_pulse {
    0%, 100% { opacity: 0; transform: scale(0.92); }
    50%      { opacity: 1; transform: scale(1.08); }
}

/* label */

.tl_label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.25;
    margin-bottom: 0;
    font-style: normal;
    white-space: nowrap;
}

/* sub 說明(展開才有) */

.tl_sub {
    font-size: 10px;
    color: var(--ink-soft);
    line-height: 1.4;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.32s ease,
                opacity 0.25s ease,
                margin-top 0.25s ease;
    opacity: 0;
    font-style: normal;
    padding: 0 2px;
    margin-top: 0;
    font-weight: 500;
}

/* 展開狀態 */

.tl_node[aria-expanded="true"] .tl_sub {
    max-height: 60px;
    opacity: 1;
    margin-top: 5px;
}

.tl_node[aria-expanded="true"] .tl_dot {
    transform: scale(1.18);
    box-shadow: 0 0 0 3px var(--paper-card),
                0 0 0 6px color-mix(in srgb, var(--brand) 18%, transparent);
}

.tl_node--stop[aria-expanded="true"] .tl_dot {
    box-shadow: 0 0 0 3px var(--paper-card),
                0 0 0 6px color-mix(in srgb, var(--warn) 22%, transparent);
}

.tl_node--order[aria-expanded="true"] .tl_dot {
    box-shadow: 0 0 0 3px var(--paper-card),
                0 0 0 6px color-mix(in srgb, var(--info) 22%, transparent);
}

.tl_node[aria-expanded="true"] .tl_label {
    color: var(--brand);
}

.tl_node--stop[aria-expanded="true"] .tl_label { color: var(--warn); }
.tl_node--order[aria-expanded="true"] .tl_label { color: var(--info); }

/* hover (僅 desktop / 非 touch) */

@media (hover: hover) {
    .tl_node:hover .tl_dot {
        transform: scale(1.08);
    }
    .tl_node--stop:hover .tl_dot {
        box-shadow: 0 0 0 3px var(--paper-card),
                    0 0 0 5px color-mix(in srgb, var(--warn) 14%, transparent);
    }
    .tl_node--order:hover .tl_dot {
        box-shadow: 0 0 0 3px var(--paper-card),
                    0 0 0 5px color-mix(in srgb, var(--info) 14%, transparent);
    }
}

/* ========== 4) 曲線 ========== */

.r_curve {
    padding: 24px 0 4px;
}

.r_curve_card {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper-card);
    overflow: hidden;
}

.chart_tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    background: #fafdfa;
}

.chart_tabs .tab {
    flex: 1;
    padding: 11px 4px;
    background: transparent;
    border: none;
    font-size: 12.5px;
    font-family: var(--type-display);
    color: var(--ink-soft);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.chart_tabs .tab.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
    font-weight: 600;
    background: #fff;
}

.chart_wrap {
    position: relative;
    height: 240px;
    padding: 10px 6px 6px;
}

.chart_hint {
    margin: 0;
    padding: 0 14px 10px;
    font-size: 11.5px;
    color: var(--ink-soft);
    min-height: 1em;
}

.chart_hint.warn {
    color: var(--warn);
}

/* skeleton */
.chart_skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(251, 252, 249, 0.94);
    z-index: 2;
    transition: opacity 0.25s ease;
}

.chart_skeleton.hide {
    opacity: 0;
    pointer-events: none;
}

.chart_skeleton_spinner {
    width: 30px;
    height: 30px;
    border: 2.5px solid var(--brand-tint);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: chart_spin 0.85s linear infinite;
}

.chart_skeleton_text {
    font-size: 12px;
    color: var(--ink-soft);
}

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

/* ========== 5) Thermal-printer footer ========== */

.r_footer {
    margin: 26px -22px 0;
    padding: 10px 22px;
    border-top: 1px dashed var(--ink-faint);
    border-bottom: 1px dashed var(--ink-faint);
    font-size: 10.5px;
    color: var(--ink-faint);
    letter-spacing: 0.04em;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 6px,
            rgba(0, 0, 0, 0.02) 6px,
            rgba(0, 0, 0, 0.02) 7px
        );
}

.r_footer_check {
    color: var(--brand);
    font-weight: 700;
}

/* ========== 進場動畫 ========== */

@media (prefers-reduced-motion: no-preference) {
    .r_id     { animation: r_fade_in 0.4s ease both; }
    .r_amount { animation: r_fade_in 0.5s ease 0.05s both; }
    .r_nodes  { animation: r_fade_in 0.55s ease 0.1s both; }
    .r_curve  { animation: r_fade_in 0.6s ease 0.15s both; }
    .r_footer { animation: r_fade_in 0.7s ease 0.2s both; }
}

@keyframes r_fade_in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

/* reduced-motion:尊重使用者偏好 */

@media (prefers-reduced-motion: reduce) {
    .tl_line_fill,
    .tl_dot,
    .tl_sub {
        transition: none !important;
        animation: none !important;
    }
    .tl_dot { opacity: 1; transform: none; }
    .tl.is_animated .tl_line_fill { width: 100%; }
}
