/* ═══════════════════════════════════════════════════════════════
   Ollama Pay — Apple HIG Design System
   ทุกสีต้องผ่าน token — ห้าม hex ลอยใน component
   Dark = base (:root), Light = [data-bs-theme="light"] override
   ═══════════════════════════════════════════════════════════════ */

/* ========== TOKENS (dark base) ========== */
:root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --muted: #98989d;
    --accent: #0a84ff;
    --accent-strong: #3395ff;
    --on-accent: #ffffff;
    --border: rgba(255, 255, 255, 0.10);
    --hairline: rgba(255, 255, 255, 0.14);
    --material: rgba(22, 22, 24, 0.78);
    --material-strong: rgba(28, 28, 30, 0.88);
    --scrim: rgba(0, 0, 0, 0.55);
    --fill: rgba(255, 255, 255, 0.06);       /* control fills */
    --fill-2: rgba(255, 255, 255, 0.10);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-float: 0 16px 48px rgba(0, 0, 0, 0.6);

    /* Apple system colors — dark variants */
    --c-red: #ff453a;
    --c-orange: #ff9f0a;
    --c-yellow: #ffd60a;
    --c-green: #30d158;
    --c-teal: #40cbe0;
    --c-cyan: #64d2ff;
    --c-blue: #0a84ff;
    --c-indigo: #5e5ce6;
    --c-purple: #bf5af2;
    --c-pink: #ff375f;
    --c-brown: #ac8e68;
    --c-gray: #98989d;
    /* semantic text (ผ่าน contrast บนพื้นตัวเอง) */
    --ok-text: #30d158;
    --warn-text: #ffb340;
    --err-text: #ff6961;

    /* radius hierarchy: control < card < sheet */
    --r-ctl: 9px;
    --r-card: 16px;
    --r-sheet: 20px;
    --pill: 980px;

    --font: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI",
            "Thonburi", "Noto Sans Thai", "Leelawadee UI", sans-serif;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

    --transition-fast: 120ms ease-out;
    --transition-normal: 200ms ease-out;
    --transition-slow: 300ms cubic-bezier(0.32, 0.72, 0, 1);

    /* ── legacy aliases (pages/app.js ยังอ้างชื่อเก่า) ── */
    --dark-base: var(--bg);
    --dark-surface: var(--surface);
    --dark-elevated: var(--surface-2);
    --primary: var(--accent);
    --primary-glow: var(--accent-strong);
    --accent-cyan: var(--c-teal);
    --accent-violet: var(--c-purple);
    --success: var(--c-green);
    --warning: var(--c-orange);
    --danger: var(--c-red);
    --text-primary: var(--text);
    --text-secondary: var(--muted);
    --text-muted: var(--muted);
    --border-subtle: var(--border);
    --shadow-sm: var(--shadow-card);
    --shadow-md: var(--shadow-card);
    --shadow-lg: var(--shadow-float);
    --shadow-glow-blue: none;

    /* Bootstrap bridge */
    --bs-body-bg: var(--bg);
    --bs-body-color: var(--text);
    --bs-border-color: var(--border);
}

/* ========== TOKENS (light) ========== */
[data-bs-theme="light"] {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-2: #fbfbfd;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --accent: #0071e3;
    --accent-strong: #0077ed;
    --on-accent: #ffffff;
    --border: rgba(0, 0, 0, 0.09);
    --hairline: rgba(0, 0, 0, 0.12);
    --material: rgba(250, 250, 252, 0.80);
    --material-strong: rgba(245, 245, 247, 0.90);
    --scrim: rgba(0, 0, 0, 0.35);
    --fill: rgba(0, 0, 0, 0.045);
    --fill-2: rgba(0, 0, 0, 0.08);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 12px 40px rgba(0, 0, 0, 0.18);

    --c-red: #ff3b30;
    --c-orange: #ff9500;
    --c-yellow: #ffcc00;
    --c-green: #34c759;
    --c-teal: #30b0c7;
    --c-cyan: #32ade6;
    --c-blue: #007aff;
    --c-indigo: #5856d6;
    --c-purple: #af52de;
    --c-pink: #ff2d55;
    --c-brown: #a2845e;
    --c-gray: #8e8e93;
    --ok-text: #1e7e34;
    --warn-text: #a05a00;
    --err-text: #c92a20;
}

/* ========== BASE ========== */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--fill-2) transparent;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.7;               /* สระบน-ล่างภาษาไทยต้องมีที่หายใจ */
    overscroll-behavior: none;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    text-wrap: balance;
}

h5 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

p { color: var(--muted); line-height: 1.7; }
ol li, ul li { color: var(--muted); }
.list-unstyled li { color: var(--muted); }
small, .small { color: var(--muted); }
.text-muted { color: var(--muted) !important; }
#conv-messages .text-muted { color: var(--text) !important; }

hr { border-color: var(--border); opacity: 1; }

a { color: var(--accent); }

/* ========== SIDEBAR — translucent material ========== */
.sidebar {
    min-height: 100vh;
    background: var(--material-strong);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-right: 1px solid var(--border);
    color: var(--muted);
    transition: transform var(--transition-slow);
}

.sidebar h4 {
    color: var(--text);
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.015em;
}

.sidebar hr {
    border-color: var(--border) !important;
    margin: 14px 12px !important;
}

.sidebar a {
    color: var(--text);
    text-decoration: none;
    padding: 7px 12px;
    display: flex;
    align-items: center;
    border-radius: var(--r-ctl);
    margin: 2px 8px;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition-fast), transform 100ms ease-out;
    position: relative;
    gap: 10px;
}

.sidebar a:hover {
    background: var(--fill);
    color: var(--text);
}

.sidebar a:active { transform: scale(0.98); }

.sidebar a.active {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

/* macOS System Settings-style icon tiles */
.sidebar i {
    width: 24px;
    height: 24px;
    font-size: 13px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    color: #fff;
    background: var(--c-gray);
}

.sidebar a.active i { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25); }

.sidebar a i.bi-speedometer2      { background: var(--c-blue); }
.sidebar a i.bi-bar-chart-line    { background: var(--c-indigo); }
.sidebar a i.bi-key               { background: var(--c-orange); }
.sidebar a i.bi-graph-up          { background: var(--c-green); }
.sidebar a i.bi-gear              { background: var(--c-gray); }
.sidebar a i.bi-people            { background: var(--c-teal); }
.sidebar a i.bi-calendar-heart    { background: var(--c-pink); }
.sidebar a i.bi-lock              { background: var(--c-orange); }
.sidebar a i.bi-bell              { background: var(--c-red); }
.sidebar a i.bi-cpu               { background: var(--c-indigo); }
.sidebar a i.bi-sliders           { background: var(--c-gray); }
.sidebar a i.bi-tag               { background: var(--c-yellow); color: #7a5b00; }
.sidebar a i.bi-globe             { background: var(--c-teal); }
.sidebar a i.bi-file-text         { background: var(--c-purple); }
.sidebar a i.bi-magic             { background: var(--c-purple); }
.sidebar a i.bi-plug              { background: var(--c-brown); }
.sidebar a i.bi-question-circle   { background: var(--c-cyan); }
.sidebar a i.bi-envelope          { background: var(--c-blue); }
.sidebar a i.bi-shield-exclamation{ background: var(--c-orange); }
.sidebar a i.bi-journal-text      { background: var(--c-brown); }
.sidebar a i.bi-shield-check      { background: var(--c-green); }
.sidebar a i.bi-person-plus       { background: var(--c-blue); }
.sidebar a i.bi-box-arrow-right   { background: var(--c-red); }

/* Theme segmented control (in sidebar footer) */
.theme-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    background: var(--fill);
    border-radius: var(--r-ctl);
    padding: 2px;
    margin: 10px 18px 6px;
}
.theme-seg button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 0;
    border-radius: 7px;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-seg button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ========== CARDS ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-normal);
    overflow: hidden;
    color: var(--text);
}

.card-title {
    color: var(--text);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.card-text { color: var(--muted); }

/* ========== STAT CARDS ========== */
.stat-cards-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

.stat-card-item { min-width: 0; }

.stat-card-body {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    padding: 18px 16px 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
}

.stat-icon-wrap.primary { background: color-mix(in srgb, var(--c-blue) 14%, transparent);   color: var(--c-blue); }
.stat-icon-wrap.violet  { background: color-mix(in srgb, var(--c-indigo) 14%, transparent); color: var(--c-indigo); }
.stat-icon-wrap.success { background: color-mix(in srgb, var(--c-green) 14%, transparent);  color: var(--c-green); }
.stat-icon-wrap.cyan    { background: color-mix(in srgb, var(--c-teal) 14%, transparent);   color: var(--c-teal); }
.stat-icon-wrap.warning { background: color-mix(in srgb, var(--c-orange) 14%, transparent); color: var(--c-orange); }

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

.stat-progress-track {
    margin-top: 8px;
    height: 4px;
    background: var(--fill-2);
    border-radius: 4px;
    overflow: hidden;
}

.stat-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.32, 0.72, 0, 1);
}

.stat-progress-label {
    font-size: 0.7rem;
    color: var(--muted);
    margin-top: 3px;
    display: block;
}

.stat-glow { display: none; }

@media (max-width: 992px) {
    .stat-cards-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .stat-cards-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card-body { padding: 14px 12px 16px; }
    .stat-value { font-size: 1.35rem; }
}

/* ========== HOME STATS ========== */
.home-stats-section {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.home-stats-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.home-stats-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--accent);
    flex-shrink: 0;
}

.home-stats-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.home-stats-subtitle {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 2px 0 0;
}

.home-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.home-stats-section.modern { margin-top: 1rem; }
.home-stats-section.modern .home-stats-header { display: none; }
.home-stats-section.modern .home-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.hstat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
}

.hstat-icon-box {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.hstat-icon-box.blue   { background: color-mix(in srgb, var(--c-blue) 14%, transparent);   color: var(--c-blue); }
.hstat-icon-box.violet { background: color-mix(in srgb, var(--c-indigo) 14%, transparent); color: var(--c-indigo); }
.hstat-icon-box.green  { background: color-mix(in srgb, var(--c-green) 14%, transparent);  color: var(--c-green); }
.hstat-icon-box.amber  { background: color-mix(in srgb, var(--c-orange) 14%, transparent); color: var(--c-orange); }

.hstat-info { display: flex; flex-direction: column; gap: 2px; }

.hstat-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.hstat-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

.hstat-glow { display: none; }

/* Charts wrapper */
.home-charts-wrapper { margin-top: 1.25rem; }

.home-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.home-chart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 16px 16px 10px;
}

.home-chart-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@media (max-width: 768px) {
    .home-stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .hstat-card { padding: 1rem; }
    .hstat-value { font-size: 1.25rem; }
    .home-charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .home-stats-section.modern .home-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 576px) {
    .home-stats-section.modern .home-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ========== EXPIRY WARNING CARD ========== */
#expiry-card { border-width: 1px; }
#expiry-title { color: var(--text); }
#expiry-desc { color: var(--muted); }

/* ========== TABLES ========== */
.table {
    color: var(--text);
    margin-bottom: 0;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
}

.table thead th {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-color: var(--border);
    background: transparent;
    padding: 10px 16px;
}

.table tbody td {
    border-bottom-color: var(--border);
    padding: 13px 16px;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

.table tbody tr:hover { background: var(--fill); }
.table-hover tbody tr:hover td { color: var(--text); }

.table-responsive {
    border-radius: var(--r-ctl);
    border: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--surface);
}

.table-responsive > .table { white-space: nowrap; }

/* ========== BADGES — สถานะสื่อด้วยรูปทรง pill + สี semantic ========== */
.badge {
    padding: 0.35em 0.8em;
    font-weight: 600;
    border-radius: var(--pill);
    font-size: 0.75rem;
}

.bg-success { background: color-mix(in srgb, var(--c-green) 15%, transparent) !important;  color: var(--ok-text) !important;   border: 0; }
.bg-danger  { background: color-mix(in srgb, var(--c-red) 15%, transparent) !important;    color: var(--err-text) !important;  border: 0; }
.bg-warning { background: color-mix(in srgb, var(--c-orange) 15%, transparent) !important; color: var(--warn-text) !important; border: 0; }
.bg-primary   { background: color-mix(in srgb, var(--accent) 15%, transparent) !important; color: var(--accent) !important; border: 0; }
.bg-info      { background: color-mix(in srgb, var(--c-teal) 15%, transparent) !important; color: var(--c-teal) !important; border: 0; }
.bg-secondary { background: var(--fill-2) !important; color: var(--text) !important; border: 0; }

/* ========== BUTTONS — pill, ตอบสนองตั้งแต่กด ========== */
.btn {
    font-weight: 500;
    border-radius: var(--pill);
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast), transform 100ms ease-out;
}

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

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

.btn-primary:hover, .btn-primary:focus {
    background: var(--accent-strong);
    color: var(--on-accent);
    box-shadow: none;
}

.btn-primary:active { background: var(--accent); }

/* quiet tinted secondary (แทน outline เส้นขอบ) */
.btn-outline-primary {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid transparent;
    color: var(--accent);
}

.btn-outline-primary:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border-color: transparent;
    color: var(--accent);
}

.btn-secondary, .btn-light {
    background: var(--fill-2);
    border: 1px solid transparent;
    color: var(--text);
}

.btn-secondary:hover, .btn-light:hover {
    background: var(--fill);
    border-color: transparent;
    color: var(--text);
}

.btn-danger { background: var(--c-red); border: none; color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--c-red) 85%, #fff); color: #fff; }
.btn-success { background: var(--c-green); border: none; color: #fff; }
.btn-success:hover { background: color-mix(in srgb, var(--c-green) 85%, #fff); color: #fff; }

.btn-outline-danger {
    background: color-mix(in srgb, var(--c-red) 12%, transparent);
    border: 1px solid transparent;
    color: var(--err-text);
}
.btn-outline-danger:hover { background: color-mix(in srgb, var(--c-red) 18%, transparent); color: var(--err-text); border-color: transparent; }

.btn-outline-secondary {
    background: var(--fill);
    border: 1px solid transparent;
    color: var(--text);
}
.btn-outline-secondary:hover { background: var(--fill-2); color: var(--text); border-color: transparent; }

.btn-sm { border-radius: var(--pill); font-size: 13px; }

/* ========== ALERTS — tinted panel ========== */
.alert { border-radius: var(--r-ctl); }

.alert-info {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    color: var(--text);
}

.alert-warning {
    background: color-mix(in srgb, var(--c-orange) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--c-orange) 22%, transparent);
    color: var(--text);
}

.alert-danger {
    background: color-mix(in srgb, var(--c-red) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--c-red) 22%, transparent);
    color: var(--text);
}

.alert-heading { color: inherit; font-weight: 600; }

/* ========== FORMS — filled fields, focus ring accent ========== */
.form-control, .form-select {
    background: var(--fill);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-ctl);
    font-size: 15px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

textarea.form-control {
    background: var(--fill);
    color: var(--text);
    font-size: 15px;
}

.form-control:focus, .form-select:focus,
textarea.form-control:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--text);
}

.form-control::placeholder,
textarea.form-control::placeholder { color: var(--muted); }

.form-label {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-text { color: var(--muted); font-size: 12px; }

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.input-group-text {
    background: var(--fill);
    border-color: var(--border);
    color: var(--muted);
}

/* ========== MODALS — sheet material ========== */
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sheet);
    box-shadow: var(--shadow-float);
    color: var(--text);
}

.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
.modal-title { font-weight: 700; letter-spacing: -0.01em; }
.modal-backdrop { --bs-backdrop-bg: #000; }

/* ========== CHARTS ========== */
canvas { max-height: 100% !important; }

.chart-container-dark {
    background: var(--surface);
    border-radius: var(--r-ctl);
    border: 1px solid var(--border);
    padding: 16px;
    min-height: 320px;
}

[style*="min-height:300px"] {
    background: var(--fill);
    border-radius: var(--r-ctl);
    padding: 8px;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fill-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ========== ANIMATIONS ========== */
.page-content {
    animation: fadeIn 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.6); }
}

/* ── Active Users Card — Pills ── */
.active-user-pill-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    min-height: inherit;
}
.active-user-pill {
    font-size: 0.85rem;
    border-radius: var(--pill);
    border: 1px solid var(--border);
    background: var(--fill);
    padding: 0.375rem 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    max-width: 100%;
}
.active-user-pill.recent {
    border-color: color-mix(in srgb, var(--c-green) 45%, transparent);
    background: color-mix(in srgb, var(--c-green) 8%, transparent);
}
.active-user-pill .dot {
    width: 9px; height: 9px;
    border-radius: 50%; flex-shrink: 0;
    background: transparent;
    border: 1.5px solid var(--muted);
    position: relative;
}
.active-user-pill.recent .dot {
    background: var(--c-green);
    border: none;
}
.active-user-pill .pulse-dot-el {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--c-green);
    animation: pulse-dot 2s infinite;
    position: absolute; top: 0; left: 0;
}
.active-user-pill .pill-username {
    color: var(--text);
    font-weight: 600;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.active-user-pill.recent .pill-username { color: var(--ok-text); }
.active-user-pill .pill-token {
    font-size: 0.7rem;
    border-radius: var(--pill);
    padding: 0.125rem 0.5rem;
    font-weight: 400;
    background: var(--fill-2);
    color: var(--muted);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.active-user-pill.recent .pill-token {
    background: color-mix(in srgb, var(--c-green) 14%, transparent);
    color: var(--ok-text);
}
.active-user-pill .pill-model {
    font-size: 0.7rem;
    border-radius: var(--pill);
    padding: 0.125rem 0.5rem;
    font-weight: 400;
    background: color-mix(in srgb, var(--c-blue) 12%, transparent);
    color: var(--accent);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.active-user-pill .pill-time { color: var(--muted); flex-shrink: 0; }
.active-user-pill.recent .pill-time { color: var(--ok-text); }
@media (max-width: 576px) {
    .active-user-pill {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        gap: 0.25rem;
    }
    .active-user-pill .pill-username { max-width: 80px; }
    .active-user-pill .pill-token   { max-width: 80px; }
    .active-user-pill .pill-model   { max-width: 70px; }
    .active-users-card-header .card-title-text { font-size: 0.9rem; }
}

/* ═══════════════════════════════════════════
   HERO / HOMEPAGE — restraint, type เป็นพระเอก
   ═══════════════════════════════════════════ */

/* ของตกแต่งเดิม (particles/shapes/gradient veil) เลิกใช้ตามหลัก restraint
   — ต้อง override pseudo-element เก่าที่ยังค้างอยู่ใน Tailwind output.css ด้วย */
.hero-particles, .hero-shapes { display: none; }
.hero-section::before, .hero-section::after,
.cta-banner::before, .feature-card::before,
.sidebar a.active::before { content: none !important; }

.hero-section {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 4rem 2rem 3.25rem;
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--fill);
    border: 1px solid var(--border);
    border-radius: var(--pill);
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.hero-badge-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--c-green);
    animation: pulse-dot 2.4s ease-in-out infinite;
}

.hero-title {
    font-size: clamp(2.4rem, 5.5vw, 3.8rem);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -0.022em;      /* display ใหญ่ → tracking ติดลบ */
    margin-bottom: 1.1rem;
    color: var(--text);
}

.hero-title .gradient-text {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--accent);
}

.hero-subtitle {
    font-size: clamp(1rem, 1.5vw, 1.15rem);
    color: var(--muted);
    max-width: 42rem;
    line-height: 1.75;
    margin: 0 auto 2rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    justify-content: center;
}

.hero-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    border-radius: var(--pill);
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--on-accent);
    background: var(--accent);
    transition: background var(--transition-fast), transform 100ms ease-out;
    cursor: pointer;
    text-decoration: none;
}

.hero-btn-primary:hover { background: var(--accent-strong); color: var(--on-accent); }
.hero-btn-primary:active { transform: scale(0.97); }

.hero-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 26px;
    border-radius: var(--pill);
    font-size: 1rem;
    font-weight: 500;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: none;
    transition: background var(--transition-fast), transform 100ms ease-out;
    cursor: pointer;
    text-decoration: none;
}

.hero-btn-secondary:hover {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
}
.hero-btn-secondary:active { transform: scale(0.97); }

.hero-social-links {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    justify-content: center;
}

.hero-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: var(--muted);
    background: var(--fill);
    border: 1px solid var(--border);
    font-size: 1.1rem;
    text-decoration: none;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.hero-social-link:hover {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.hero-stats-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 44px;
    justify-content: center;
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    width: 100%;
}

.hero-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.hero-stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* orchestrated page-load reveal — จุดเดียวของ motion บนหน้าแรก */
.hero-badge     { animation: fadeInUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) both; }
.hero-title     { animation: fadeInUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) 0.06s both; }
.hero-subtitle  { animation: fadeInUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) 0.12s both; }
.hero-actions   { animation: fadeInUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) 0.18s both; }
.hero-social-links, .hero-stats-strip { animation: fadeInUp 0.5s cubic-bezier(0.32, 0.72, 0, 1) 0.24s both; }

/* ── Feature Cards ── */
.features-section {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}
.features-header {
    text-align: center;
    margin-bottom: 2rem;
}
.features-header h3 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}
.features-header p { color: var(--muted); font-size: 0.95rem; }

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition-normal);
}

.feature-card::before { content: none; }

.feature-card:hover {
    transform: none;
    border-color: var(--hairline);
    box-shadow: var(--shadow-card);
}

.feature-icon-box {
    width: 44px; height: 44px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 1rem;
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
}

/* inline tint เดิมสีพาสเทลโทนมืด — ธีมสว่างกดให้เข้มขึ้นเพื่อ contrast */
[data-bs-theme="light"] .feature-icon-box { filter: saturate(1.1) brightness(0.72); }

.feature-card:hover .feature-icon-box { transform: none; }

.feature-card h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.65;
    margin: 0;
}

/* ── Models Preview ── */
.models-preview {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
}
.models-preview-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.models-preview-header h3 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}
.models-preview-header p { color: var(--muted); font-size: 0.95rem; }

.models-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.model-preview-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-ctl);
    padding: 12px 16px;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform 100ms ease-out;
    cursor: pointer;
    text-decoration: none;
}
.model-preview-chip:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.model-preview-chip:active { transform: scale(0.98); }
.model-preview-chip .model-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--c-green);
}
.model-preview-chip .model-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── CTA Banner ── */
.cta-banner {
    position: relative;
    background: color-mix(in srgb, var(--accent) 7%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
    border-radius: var(--r-card);
    padding: 2.5rem;
    text-align: center;
    overflow: hidden;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}
.cta-banner::before { content: none; }
.cta-banner > * { position: relative; z-index: 1; }
.cta-banner h3 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
}
.cta-banner p {
    color: var(--muted);
    max-width: 500px;
    margin: 0 auto 1.5rem;
    font-size: 0.95rem;
}

/* ── Responsive ── */
@media (max-width: 992px) {
    .hero-content { padding: 3rem 1.5rem 2.5rem; }
}
@media (max-width: 576px) {
    .hstat-card { padding: 1rem; }
    .hstat-value { font-size: 1.2rem; }
    .feature-card { padding: 1.25rem; }
    .models-preview-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-stats-strip { gap: 12px 28px; }
}

/* ========== SIDEBAR TOGGLE (mobile) ========== */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: var(--r-ctl);
    transition: background var(--transition-fast);
}
.sidebar-toggle:hover { background: var(--fill); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--scrim);
    z-index: 1020;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show { opacity: 1; }

/* ========== MOBILE HEADER — translucent toolbar ========== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1010;
    background: var(--material);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    align-items: center;
    gap: 12px;
}
.mobile-header .mobile-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    body {
        padding-top: 56px;
        overscroll-behavior: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 80vw;
        min-height: 100vh;
        z-index: 1030;
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
        overflow-y: auto;
        border-right: 1px solid var(--border);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-float);
    }

    .sidebar h4 {
        display: flex;
        padding: 16px;
        margin-bottom: 8px;
        border-bottom: 1px solid var(--border);
    }

    .sidebar hr { margin: 8px 16px !important; }

    .sidebar a {
        margin: 2px 8px;
        padding: 9px 14px;
        font-size: 14px;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay.show { display: block; }

    .mobile-header { display: flex; }

    .main-content {
        padding: 16px;
        overscroll-behavior: none;
    }

    .page-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    .page-header h2 {
        font-size: 1.2rem;
        width: 100%;
    }
    .page-header .header-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        gap: 8px;
    }

    .chart-container { min-height: 200px !important; }

    #models-grid .col-md-6 { width: 50%; }

    .table thead th,
    .table tbody td {
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .token-display {
        font-size: 0.7rem;
        word-break: break-all;
        padding: 8px;
    }

    .stat-cards-grid { gap: 10px; }
    .stat-card-body { padding: 14px 12px 16px; }
    .stat-value { font-size: 1.3rem; }
    .stat-icon-wrap {
        width: 34px;
        height: 34px;
        font-size: 0.95rem;
        border-radius: 9px;
    }

    .modal-dialog { margin: 8px; }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link {
        white-space: nowrap;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    pre {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.75rem;
    }

    #expiry-card .card-body {
        flex-direction: column;
        text-align: center;
    }
    #expiry-card .card-body > div:first-child {
        flex-direction: column !important;
    }
    #expiry-card .card-body i {
        margin-right: 0 !important;
        margin-bottom: 8px;
    }
}

@media (max-width: 480px) {
    #models-grid .col-md-6 { width: 100%; }
    .page-header .header-actions { flex-wrap: wrap; }
    .token-display { font-size: 0.65rem; }
}

/* ========== TOKEN DISPLAY ========== */
.token-display {
    font-family: var(--mono);
    background: var(--fill);
    padding: 10px;
    border-radius: var(--r-ctl);
    border: 1px solid var(--border);
    color: var(--text);
    word-break: break-all;
}

/* ========== NAV TABS ========== */
.nav-tabs {
    border-bottom: 1px solid var(--border);
}

.nav-tabs .nav-link {
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 16px;
    font-weight: 500;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.nav-tabs .nav-link.active {
    color: var(--accent);
    background: transparent;
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.nav-tabs .nav-link:hover {
    color: var(--text);
    border-color: transparent;
    border-bottom-color: var(--hairline);
    isolation: isolate;
}

/* ========== TAB ICONS (Admin) ========== */
.tab-icon {
    font-size: 1.1rem;
    margin-right: 6px;
    vertical-align: -2px;
    color: var(--muted);
    transition: color var(--transition-fast);
}

.nav-link.active .tab-icon { color: var(--accent); }
.nav-link:hover .tab-icon { color: var(--text); }

/* ========== PRE / CODE ========== */
pre.bg-dark {
    background: #0d1117 !important;
    border: 1px solid var(--border);
    border-radius: var(--r-ctl);
}

code, pre code {
    font-family: var(--mono);
    color: var(--accent);
    background: var(--fill);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 0.9em;
}

pre code {
    background: transparent;
    padding: 0;
}

/* ========== PAGE SURFACES (เดิมมี override ต่อหน้า — token เดียวพอ) ========== */
#home-page .card,
#settings-form .form-control,
#renew-page .card,
#docs-page .card,
#help-page .card { background: var(--surface); }

/* ========== LOADING SPINNER ========== */
.loading-spinner { display: none; }
.loading .loading-spinner { display: inline-block; }

/* ========== HEADER AREA ========== */
.d-flex.justify-content-between.align-items-center.mb-4 {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px !important;
}

#user-email {
    color: var(--muted);
    font-size: 14px;
}

#page-title {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text);
    letter-spacing: -0.02em;
}

/* ========== IMG THUMBNAIL (SLIP PREVIEW) ========== */
.img-thumbnail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-ctl);
}

/* ========== BORDER UTILITIES ========== */
.border-primary { border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important; }
.border-danger  { border-color: color-mix(in srgb, var(--c-red) 35%, transparent) !important; }
.border-warning { border-color: color-mix(in srgb, var(--c-orange) 35%, transparent) !important; }

/* ========== FOCUS STATES ========== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ════════════════════════════════════════
   CLAUDE CODE SUPPORT CARD
   ════════════════════════════════════════ */
.claude-support-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 2rem 2.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}
.claude-glow { display: none; }
.claude-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
    z-index: 1;
}
.claude-left { flex: 1; min-width: 0; }
.claude-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.claude-illustration { width: 120px; height: 120px; opacity: 0.75; }
.claude-illustration svg { width: 100%; height: 100%; }

.claude-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.claude-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--c-orange) 14%, transparent);
    color: var(--c-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.claude-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--text);
}
.claude-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
    margin-top: 0.1rem;
}
.claude-desc p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 1rem 0;
    max-width: 560px;
}
.claude-desc code {
    background: color-mix(in srgb, var(--c-orange) 12%, transparent);
    color: var(--c-orange);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
}

/* code block คงพื้นมืดทั้งสองธีม (แบบ Apple docs) */
.claude-code-block {
    border-radius: var(--r-ctl);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 0.85rem;
}
.claude-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #16181d;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.75rem;
    color: #9aa2ad;
}
.claude-copy-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: #9aa2ad;
    padding: 0.25rem 0.75rem;
    border-radius: var(--pill);
    font-size: 0.72rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.claude-copy-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.12);
}
.claude-code-pre {
    background: #0d1117;
    margin: 0;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.82rem;
    line-height: 1.7;
    color: #e6e8eb;
}
.claude-code-pre code { color: #e6e8eb; background: transparent; padding: 0; }

.claude-note {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.6;
}
.claude-note i { margin-top: 0.15rem; flex-shrink: 0; }
.claude-note code {
    background: color-mix(in srgb, var(--c-orange) 12%, transparent);
    color: var(--c-orange);
    padding: 0.05em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}
.claude-note a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 2px;
}
.claude-note a:hover { text-decoration-color: var(--accent); }

@media (max-width: 768px) {
    .claude-support-card { padding: 1.5rem 1.25rem; }
    .claude-content { flex-direction: column; }
    .claude-right { display: none; }
    .claude-title { font-size: 1.1rem; }
    .claude-desc p { max-width: 100%; }
    .claude-code-pre { font-size: 0.75rem; padding: 0.75rem 1rem; }
}

/* ════════════════════════════════════════
   ANTHROPIC API SUPPORT CARD
   ════════════════════════════════════════ */
.anthropic-support-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-card);
    padding: 2rem 2.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}
.anthropic-glow { display: none; }
.anthropic-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 2rem;
    position: relative;
    z-index: 1;
}
.anthropic-left { flex: 1; min-width: 0; }
.anthropic-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.anthropic-illustration { width: 120px; height: 120px; opacity: 0.75; }
.anthropic-illustration svg { width: 100%; height: 100%; }

.anthropic-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.anthropic-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--c-teal) 14%, transparent);
    color: var(--c-teal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.anthropic-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 0;
    color: var(--text);
}
.anthropic-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
    margin-top: 0.1rem;
}
.anthropic-desc p {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 1rem 0;
    max-width: 560px;
}
.anthropic-desc code {
    background: color-mix(in srgb, var(--c-teal) 12%, transparent);
    color: var(--c-teal);
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.85em;
}

.anthropic-code-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}
.anthropic-code-block {
    border-radius: var(--r-ctl);
    overflow: hidden;
    border: 1px solid var(--border);
}
.anthropic-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: #16181d;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.75rem;
    color: #9aa2ad;
}
.anthropic-copy-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: #9aa2ad;
    padding: 0.25rem 0.75rem;
    border-radius: var(--pill);
    font-size: 0.72rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.anthropic-copy-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-color: rgba(255,255,255,0.12);
}
.anthropic-code-pre {
    background: #0d1117;
    margin: 0;
    padding: 1rem 1.2rem;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 0.78rem;
    line-height: 1.6;
    color: #e6e8eb;
    max-height: 200px;
}
.anthropic-code-pre code { color: #e6e8eb; background: transparent; padding: 0; }

.anthropic-note {
    display: flex;
    align-items: flex-start;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.6;
}
.anthropic-note i { margin-top: 0.15rem; flex-shrink: 0; }
.anthropic-note code {
    background: color-mix(in srgb, var(--c-teal) 12%, transparent);
    color: var(--c-teal);
    padding: 0.05em 0.35em;
    border-radius: 3px;
    font-size: 0.85em;
}
.anthropic-note a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
    text-underline-offset: 2px;
}
.anthropic-note a:hover { text-decoration-color: var(--accent); }

@media (max-width: 768px) {
    .anthropic-support-card { padding: 1.5rem 1.25rem; }
    .anthropic-content { flex-direction: column; }
    .anthropic-right { display: none; }
    .anthropic-title { font-size: 1.1rem; }
    .anthropic-desc p { max-width: 100%; }
    .anthropic-code-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .anthropic-code-pre { font-size: 0.72rem; padding: 0.75rem 1rem; max-height: 160px; }
}

/* ── Per-user DeepSeek routing threshold card (settings page) ──
   Token-based: progress fill uses --accent, warning text uses --warn-text.
   No hard-coded colors — works in both light & dark themes. */
.user-dsa-progress { display: flex; flex-direction: column; gap: 3px; }
.user-dsa-progress-track {
    height: 4px;
    background: var(--fill-2);
    border-radius: 4px;
    overflow: hidden;
}
.user-dsa-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.32, 0.72, 0, 1);
}
.user-dsa-warn-row > td { border-top: 0; padding-top: 0; padding-bottom: 8px; }
.user-dsa-warn {
    color: var(--warn-text);
    font-size: 0.78rem;
    font-weight: 500;
}
