/* ========== 天津高考报考指南 v2 · 统一样式表 ========== */

/* ===== CSS 变量体系 ===== */
:root {
    /* 品牌色 */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --primary-dark: #1e3a8a;
    
    /* 语义色 */
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    
    /* 冲稳保 */
    --chong: #dc2626;
    --chong-light: #fef2f2;
    --chong-border: #fecaca;
    --wen: #059669;
    --wen-light: #ecfdf5;
    --wen-border: #a7f3d0;
    --bao: #2563eb;
    --bao-light: #eff6ff;
    --bao-border: #bfdbfe;
    
    /* 中性色 */
    --bg: #eef2f8;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e4eaf2;
    --separator: rgba(60, 60, 67, 0.12);
    --text: #1c1c1e;
    --text-secondary: #8e8e93;
    --text-tertiary: #aeaeb2;
    
    /* 布局 */
    --app-width: 480px;
    --header-h: 52px;
    --tab-h: 56px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --space-xs: 4px;
    --space-sm: 8px;
    --space: 16px;
    --space-lg: 24px;
    
    /* 字体 */
    --font-title: 17px;
    --font-body: 15px;
    --font-caption: 13px;
    --font-small: 12px;
    
    /* 阴影 */
    --shadow-card: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    
    /* 过渡 */
    --transition: 0.2s ease;
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    padding: 0;
    background: #d1d1d6;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: var(--font-body);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== App Frame ===== */
.app-frame {
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: stretch;
}
.app-shell {
    width: 100%;
    max-width: var(--app-width);
    min-height: 100dvh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 40px rgba(0,0,0,0.12);
}

/* ===== Header ===== */
.app-header {
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, #3b82f6 100%);
    padding: var(--space-sm) var(--space);
    padding-top: calc(var(--space-sm) + env(safe-area-inset-top, 0));
    padding-bottom: 12px;
    z-index: 50;
    box-shadow: 0 2px 12px rgba(30, 58, 138, 0.18);
}
.app-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}
.app-header-logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: contain;
    flex-shrink: 0;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.22);
}
.app-header-title {
    font-size: var(--font-title);
    font-weight: 600;
    color: #fff;
    flex: 1;
    min-width: 0;
}
.app-header-sub {
    font-size: var(--font-caption);
    color: rgba(255,255,255,0.9);
    margin: 2px 0 0 40px;
}
.app-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.btn-header-export {
    height: 30px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,0.55);
    border-radius: 15px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
}
.btn-header-export:hover { background: rgba(255,255,255,0.28); }
.btn-header-export:active { transform: scale(0.97); }
.admin-badge {
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    background: var(--success);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* ===== Main Content ===== */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0) + var(--space));
}
.app-content .container {
    max-width: none;
    margin: 0;
    padding: var(--space);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Tab Bar ===== */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--app-width);
    height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0));
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0,0,0,0.08);
    display: flex;
    z-index: 100;
}
.tab-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    padding: 5px 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition);
}
.tab-bar-item.active { color: var(--primary); font-weight: 600; }
.tab-bar-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}
.tab-bar-item svg {
    width: 24px; height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all var(--transition);
}
.tab-bar-item.active svg { stroke-width: 2.2; }

/* ===== Cell Groups (iOS style) ===== */
.cell-group { margin-bottom: var(--space-lg); }
.cell-group-title {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    padding: 0 var(--space) var(--space-sm);
    font-weight: 500;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.cell-group-sub { font-weight: 400; opacity: 0.85; }
.cell-group-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.cell {
    display: flex;
    align-items: center;
    padding: 12px var(--space);
    min-height: 44px;
    border-bottom: 0.5px solid var(--separator);
    gap: var(--space-sm);
}
.cell:last-child { border-bottom: none; }
.cell-label {
    flex-shrink: 0;
    font-size: var(--font-body);
    color: var(--text);
    min-width: 72px;
}
.cell-optional { font-size: var(--font-small); font-weight: normal; color: var(--text-secondary); }
.cell-value { flex: 1; display: flex; justify-content: flex-end; }
.cell-input, .cell-select {
    flex: 1;
    border: none;
    background: transparent;
    font-size: var(--font-body);
    color: var(--text);
    text-align: right;
    outline: none;
    min-width: 0;
    padding: 0;
    font-family: inherit;
}
.cell-input::placeholder { color: var(--text-tertiary); }
.cell-select { appearance: none; cursor: pointer; direction: rtl; }
.cell-hint {
    padding: 8px var(--space) 12px;
    font-size: var(--font-small);
    color: var(--text-secondary);
    line-height: 1.5;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-top: -1px;
}
.cell-link { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.cell-link:active { background: #f2f2f7; }
.cell-chevron { color: var(--text-secondary); font-size: 18px; font-weight: 300; margin-left: auto; }

/* ===== Chip Buttons ===== */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px var(--space);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}
.chip-item {
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid #e5e5ea;
    border-radius: 18px;
    background: var(--surface);
    font-size: var(--font-caption);
    color: var(--text);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.chip-item:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.chip-item input { position: absolute; opacity: 0; width: 0; height: 0; }

/* Subject chips - 3-col grid */
.subject-chip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.subject-chip-grid .chip-item { margin: 0; }

/* Match filter grids */
.chip-group-inline {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    gap: 8px;
}
.match-region-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.match-direction-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.match-nature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 240px;
}
.match-region-grid .chip-item,
.match-direction-grid .chip-item,
.match-nature-grid .chip-item {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 36px;
    padding: 6px 8px;
    margin: 0;
}

/* ===== Buttons ===== */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
}
.btn-primary:active { background: var(--primary-hover); transform: scale(0.97); }
.btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid #e5e5ea;
}
.btn-secondary:active { background: #f2f2f7; transform: scale(0.97); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { background: #dc2626; transform: scale(0.97); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.875rem; }

.app-action-bar { padding: var(--space) 0 var(--space-sm); }
.btn-app-primary {
    width: 100%;
    min-height: 48px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition);
}
.btn-app-primary:active { background: var(--primary-hover); transform: scale(0.98); }
.btn-app-secondary {
    width: 100%;
    min-height: 44px;
    border: none;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--primary);
    font-size: var(--font-caption);
    font-weight: 500;
    cursor: pointer;
    margin-top: var(--space-sm);
}

/* ===== Content Cards ===== */
.content-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-bottom: var(--space);
}
.content-card-head {
    padding: 10px var(--space);
    background: var(--surface-alt);
    border-bottom: 0.5px solid var(--border);
    font-size: var(--font-caption);
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== Guide Page ===== */
/* Hero score grid */
.home-hero-scores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    padding: 1px;
}
.home-hero-score {
    background: var(--surface-alt);
    padding: 10px 12px;
    min-height: 88px;
    transition: background var(--transition);
}
.home-hero-score.warning { background: var(--warning-light); }
.home-hero-score.info { background: #eff6ff; }
.home-hero-score.success { background: var(--success-light); }
.home-hero-score-top {
    display: flex;
    align-items: baseline;
    gap: 2px;
    line-height: 1.1;
}
.home-hero-score-num {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}
.home-hero-score-unit { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.home-hero-score-rank { font-size: 11px; font-weight: 600; color: var(--primary); margin-top: 4px; }
.home-hero-score-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.4; margin-top: 4px; }

/* Undergrad line card */
.undergrad-line-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: var(--space);
    box-shadow: var(--shadow-card);
}
.undergrad-line-table { margin-top: 4px; }
.undergrad-line-source {
    font-size: 10px;
    color: var(--text-secondary);
    margin: 8px 0 0;
    line-height: 1.4;
}

/* Section titles */
.home-section-title {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    padding-left: 2px;
}

/* Direction tiles */
.direction-tiles {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space);
}
.direction-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px var(--space);
    box-shadow: var(--shadow-md);
    border-left: 5px solid var(--dir-color, var(--primary));
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.direction-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--dir-color, var(--primary));
    opacity: 0.03;
    pointer-events: none;
}
.direction-tile:active { transform: scale(0.99); box-shadow: var(--shadow-card); }
.direction-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
}
.direction-tile-name {
    font-size: var(--font-body);
    font-weight: 600;
}
.direction-tile-summary {
    font-size: var(--font-small);
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.4;
}
.direction-tile-rank {
    font-size: var(--font-small);
    color: var(--primary);
    font-weight: 600;
    white-space: nowrap;
}
.direction-tile-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: 10px;
}
.btn-tile {
    flex: 1;
    min-height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-small);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-tile:active { transform: scale(0.97); }
.btn-tile-primary {
    background: var(--primary);
    color: #fff;
}
.btn-tile-ghost {
    background: var(--bg);
    color: var(--primary);
}

/* CWB scroll pills */
.cwb-scroll {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.cwb-scroll::-webkit-scrollbar { display: none; }
.cwb-pill {
    flex-shrink: 0;
    width: 130px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-card);
    transition: transform var(--transition);
}
.cwb-pill:active { transform: scale(0.97); }
.cwb-pill.chong { border-top: 3px solid var(--chong); }
.cwb-pill.wen { border-top: 3px solid var(--wen); }
.cwb-pill.bao { border-top: 3px solid var(--bao); }
.cwb-pill-level { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.cwb-pill-desc { font-size: var(--font-small); color: var(--text-secondary); line-height: 1.4; }

/* Guide conclusion */
.guide-conclusion-text {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 12px var(--space);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space);
}

/* Guide expand sections */
.guide-expand-section { margin-bottom: var(--space-lg); }
.guide-detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.guide-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--space);
    cursor: pointer;
    font-weight: 600;
    font-size: var(--font-caption);
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
}
.guide-detail-header:active { background: var(--surface-alt); }
.guide-detail-body { padding: 0 var(--space) var(--space); }
.guide-detail-body.collapsed { display: none; }

/* ===== Match Page ===== */
.match-panel {
    padding-bottom: calc(var(--tab-h) + var(--space));
}

.match-hero {
    background: linear-gradient(145deg, #2563eb 0%, #1d4ed8 55%, #1e40af 100%);
    border-radius: var(--radius-lg);
    padding: var(--space) var(--space) 14px;
    margin-bottom: var(--space-lg);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.28);
    color: #fff;
}

.match-hero-label {
    font-size: var(--font-small);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 12px;
}

.match-score-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.match-input-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: text;
    transition: background var(--transition), border-color var(--transition);
}

.match-input-card:focus-within {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
}

.match-input-primary {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.35);
}

.match-input-title {
    font-size: var(--font-small);
    font-weight: 500;
    opacity: 0.9;
}

.match-input-title em {
    font-style: normal;
    color: #fde68a;
    font-weight: 600;
}

.match-input-title em.optional {
    color: rgba(255, 255, 255, 0.65);
    font-weight: 400;
}

.match-input-lg {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 32px;
    font-weight: 700;
    color: #fff;
    outline: none;
    font-family: inherit;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}

.match-input-lg::-webkit-outer-spin-button,
.match-input-lg::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.match-input-lg::placeholder {
    color: rgba(255, 255, 255, 0.35);
    font-weight: 500;
}

.match-input-hint {
    font-size: 11px;
    opacity: 0.65;
}

.match-inline-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.match-option {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.match-option-label {
    font-size: 11px;
    opacity: 0.75;
}

.match-select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: var(--font-caption);
    font-family: inherit;
    padding: 7px 28px 7px 10px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

.match-select option {
    color: var(--text);
    background: var(--surface);
}

.match-section {
    margin-bottom: var(--space-lg);
}

.match-section-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.match-step {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: var(--font-small);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.match-section-title {
    font-size: var(--font-body);
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.match-section-sub {
    font-size: var(--font-small);
    color: var(--text-secondary);
    margin-top: 2px;
}

.match-chip-card {
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.match-chip-card .chip-item {
    min-height: 40px;
    font-weight: 500;
}

.match-filter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.match-filter-block {
    padding: 12px var(--space);
    border-bottom: 0.5px solid var(--separator);
}

.match-filter-block:last-child {
    border-bottom: none;
}

.match-filter-label {
    display: block;
    font-size: var(--font-caption);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 10px;
    letter-spacing: 0.02em;
}

.match-footnote {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.5;
    padding: 0 2px;
}

.match-action-bar {
    position: sticky;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 10;
    padding: var(--space-sm) 0 var(--space);
    margin-top: var(--space);
}

.btn-match-start {
    width: 100%;
    min-height: 50px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #fff;
    font-size: var(--font-body);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    transition: transform var(--transition), box-shadow var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.btn-match-start:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.match-region-grid .chip-item,
.match-direction-grid .chip-item,
.match-nature-grid .chip-item,
.match-panel .subject-chip-grid .chip-item {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 36px;
    padding: 6px 8px;
    margin: 0;
}

/* Segment alert */
.segment-alert {
    background: var(--warning-light);
    border: 0.5px solid #fed7aa;
    border-radius: var(--radius);
    padding: 12px var(--space);
    margin-bottom: var(--space);
    font-size: var(--font-caption);
    color: #9a3412;
    line-height: 1.6;
}

/* Match results */
.match-results {
    margin-top: var(--space-lg);
    padding-top: var(--space);
    border-top: 0.5px solid var(--separator);
    animation: fadeInUp 0.4s ease-out;
}
.match-results-heading {
    font-size: var(--font-title);
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-sm);
    padding-top: var(--space-xs);
}

/* Result stats */
.result-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--separator);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--space);
    box-shadow: var(--shadow-card);
}
.stat-item {
    background: var(--surface);
    padding: 10px 6px;
    text-align: center;
    transition: background var(--transition);
}
.stat-item:active { background: var(--surface-alt); }
.stat-value {
    font-size: 17px;
    line-height: 1.2;
    font-weight: 700;
    color: var(--primary);
}
.stat-label {
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Result sections (冲/稳/保) */
.result-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px var(--space);
    font-weight: 600;
    font-size: var(--font-body);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
}
.result-header:active { opacity: 0.9; }
.result-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-variant-numeric: tabular-nums;
    opacity: 0.9;
}
.collapse-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
    opacity: 0.7;
}
.result-header.chong {
    background: linear-gradient(135deg, #fef2f2 0%, #fff1f1 100%);
    border-left: 4px solid var(--chong);
    color: var(--chong);
}
.result-header.wen {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-left: 4px solid var(--wen);
    color: var(--wen);
}
.result-header.bao {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f7ff 100%);
    border-left: 4px solid var(--bao);
    color: var(--bao);
}
.result-section .expandable-list {
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
.result-list { border-top: 0.5px solid var(--separator); }
.result-section.collapsed .result-list { display: none; }
.result-section.collapsed .collapse-icon { transform: rotate(-90deg); }

.result-export-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space);
    padding-bottom: var(--space-xs);
}
.result-export-actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
    border-radius: var(--radius);
    font-size: var(--font-body);
}

/* ===== Expandable List ===== */
.expandable-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.list-item {
    border-bottom: 0.5px solid var(--separator);
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item-summary {
    display: grid;
    grid-template-columns: 24px 1fr auto auto 14px;
    gap: 2px 8px;
    padding: 12px var(--space);
    align-items: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
}
.list-item-summary:active { background: var(--surface-alt); }
.list-item.expanded .list-item-summary { background: var(--primary-light); }

.col-index { font-size: var(--font-small); color: var(--text-secondary); font-weight: 600; }
.col-school { grid-column: 2; }
.col-score { grid-column: 3; grid-row: 1 / 3; align-self: center; text-align: right; }
.col-subject { grid-column: 4; grid-row: 1 / 3; align-self: center; }
.col-action { grid-column: 5; grid-row: 1 / 3; align-self: center; }

.list-school { font-size: var(--font-body); font-weight: 600; color: var(--text); }
.list-program { font-size: var(--font-small); color: var(--text-secondary); }
.list-score { font-size: var(--font-caption); font-weight: 600; color: var(--primary); }
.list-rank { font-size: var(--font-small); color: var(--text-secondary); }
.list-chevron { color: var(--text-secondary); font-size: 16px; transition: transform 0.2s; }
.list-item.expanded .list-chevron { transform: rotate(90deg); color: var(--primary); }

.list-item-detail {
    display: none;
    padding: 0 var(--space) var(--space);
    font-size: var(--font-caption);
    animation: fadeIn 0.2s ease-out;
}
.list-item.expanded .list-item-detail { display: block; }
.list-empty {
    padding: 32px var(--space);
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-caption);
}

/* Match list item adjustments */
.match-item { border-left-width: 4px; border-left-style: solid; }
.match-item .list-item-summary {
    grid-template-columns: 24px 1fr auto auto 14px;
}

/* Detail sections */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}
.detail-label {
    font-size: var(--font-small);
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 600;
}
.detail-value { font-size: var(--font-caption); font-weight: 500; }
.detail-section { margin-top: var(--space-sm); }
.detail-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space);
}
.detail-actions .btn { flex: 1; justify-content: center; }

/* ===== Data Page ===== */
.data-scope-banner {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px var(--space);
    margin-bottom: var(--space-sm);
    font-size: var(--font-small);
    color: var(--text-secondary);
    line-height: 1.5;
    box-shadow: var(--shadow-card);
}
.data-scope-banner strong {
    display: block;
    font-size: var(--font-caption);
    margin-bottom: 4px;
    color: var(--text);
    font-weight: 600;
}
.data-count-badge {
    font-size: var(--font-caption);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

/* Data toolbar */
.data-toolbar-app {
    display: flex;
    gap: 6px;
    margin-bottom: var(--space-sm);
    align-items: center;
}
.data-search-wrap { flex: 1; position: relative; }
.data-search-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0 36px 0 12px;
    font-size: var(--font-caption);
    outline: none;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}
.data-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.data-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px; height: 24px;
    border: none;
    border-radius: 50%;
    background: var(--text-tertiary);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}
.data-search-clear.visible { display: flex; }
.btn-search {
    width: 40px; height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
}
.btn-search:active { transform: scale(0.95); background: var(--primary-hover); }
.btn-sort-rank {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--font-small);
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-sort-rank:active { transform: scale(0.95); background: var(--surface-alt); }
.btn-sort-rank.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-sort-rank::before { content: '↕'; margin-right: 2px; }
.btn-sort-rank.asc::before { content: '🔼'; }
.btn-sort-rank.desc::before { content: '🔽'; }
.btn-icon-add {
    width: 40px; height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-icon-add:active { transform: scale(0.92); }
.data-sort-select {
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 0 10px;
    font-size: var(--font-small);
    color: var(--text);
    box-shadow: var(--shadow-card);
    max-width: 100px;
}

/* Data filter bar */
.data-filter-bar {
    margin-bottom: var(--space);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.data-filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.data-filter-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 56px;
    flex-shrink: 0;
}
.data-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.data-filter-chip {
    min-height: 32px;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition);
}
.data-filter-chip:active { transform: scale(0.96); }
.data-filter-chip.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}
.data-filter-expand {
    min-height: 32px;
    padding: 4px 14px;
    border: 1px dashed var(--border);
    border-radius: 16px;
    background: transparent;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.data-filter-expand:active { background: var(--surface-alt); }
.data-filter-collapse-wrap { display: contents; }

/* ===== Mine Page ===== */
.mine-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space);
    color: var(--text);
    margin-bottom: var(--space);
    box-shadow: var(--shadow-card);
    text-align: center;
}
.mine-summary-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}
.mine-summary-value {
    font-size: 36px;
    font-weight: 700;
    margin: 4px 0;
    color: var(--primary);
}
.mine-summary-sub { font-size: var(--font-small); color: var(--text-secondary); }
.mine-summary-meta {
    display: flex;
    justify-content: center;
    gap: var(--space-lg);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 0.5px solid var(--separator);
}
.mine-summary-meta-item {
    text-align: center;
}
.mine-summary-meta-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.mine-summary-meta-label {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Stats charts */
.stats-compact .chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space);
    margin-bottom: var(--space-sm);
    box-shadow: var(--shadow-card);
}
.stats-compact .chart-title {
    font-size: var(--font-caption);
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

/* Recent visits */
.recent-section {
    margin-bottom: var(--space);
}
.recent-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.recent-item {
    display: flex;
    align-items: center;
    padding: 10px var(--space);
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition);
    gap: var(--space-sm);
}
.recent-item:last-child { border-bottom: none; }
.recent-item:active { background: var(--surface-alt); }
.recent-item-school {
    font-size: var(--font-body);
    font-weight: 600;
    flex: 1;
}
.recent-item-program {
    font-size: var(--font-small);
    color: var(--text-secondary);
}
.recent-item-score {
    font-size: var(--font-caption);
    font-weight: 600;
    color: var(--primary);
}

/* Tool cards */
.tool-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.tool-card:active { transform: scale(0.96); background: var(--surface-alt); }
.tool-card-icon {
    font-size: 24px;
    margin-bottom: 6px;
}
.tool-card-label {
    font-size: var(--font-small);
    color: var(--text);
    font-weight: 500;
}

.app-version {
    text-align: center;
    font-size: var(--font-small);
    color: var(--text-secondary);
    padding: var(--space-lg) 0;
}

/* ===== Tables ===== */
.mini-table {
    width: 100%;
    font-size: var(--font-small);
    border-collapse: collapse;
}
.mini-table th, .mini-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 0.5px solid var(--separator);
}
.mini-table th {
    background: var(--surface-alt);
    font-weight: 600;
    color: var(--text-secondary);
}

/* Predict rows */
.score-predict-row td {
    color: #6d28d9 !important;
    -webkit-text-fill-color: #6d28d9 !important;
    background: #f5f3ff !important;
    border-top: 1px dashed #c4b5fd !important;
    font-weight: 600;
}
.predict-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    background: #7c3aed !important;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}
.predict-value {
    color: #6d28d9 !important;
    -webkit-text-fill-color: #6d28d9 !important;
    font-weight: 600;
}
.predict-hint {
    font-size: 11px;
    color: #7c3aed !important;
    -webkit-text-fill-color: #7c3aed !important;
    margin-top: 6px;
    line-height: 1.4;
}

/* ===== Badges & Chips ===== */
.level-chip {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #166534;
    background: #dcfce7;
    border: 1px solid #86efac;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    white-space: nowrap;
}
.level-chip-minban {
    color: #9a3412;
    background: #ffedd5;
    border-color: #fdba74;
}
.level-chip-sino {
    color: #1e40af;
    background: #dbeafe;
    border-color: #93c5fd;
}
.level-chip-voc {
    color: #5b21b6;
    background: #ede9fe;
    border-color: #c4b5fd;
}
.level-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--font-small);
    font-weight: 600;
}
.level-badge.chong { background: var(--chong-light); color: var(--chong); }
.level-badge.wen { background: var(--wen-light); color: var(--wen); }
.level-badge.bao { background: var(--bao-light); color: var(--bao); }
.meta-chip {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: var(--font-small);
    color: var(--text-secondary);
    white-space: nowrap;
}
.major-cat-chip { margin-left: 6px; vertical-align: middle; }
.civil-service-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    white-space: nowrap;
}
.civil-service-detail {
    font-size: var(--font-caption);
    color: #92400e;
    line-height: 1.5;
    margin: 0;
}
.tag {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
    font-size: var(--font-small);
    margin-right: 4px;
    margin-bottom: 4px;
    color: var(--text);
}

/* ===== Employment block ===== */
.employment-block {
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}
.employment-sub { margin-top: 10px; }
.employment-sub:first-of-type { margin-top: 8px; }
.employment-sub-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}
.employment-outlook { color: var(--text-secondary); line-height: 1.6; }

/* Data source list */
.data-source-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: var(--font-small);
    line-height: 1.6;
    color: var(--text-secondary);
}
.data-source-list a {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
}
.data-source-list a:hover { text-decoration: underline; }

/* ===== Sheet / Drawer ===== */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition);
}
.sheet-backdrop.show { opacity: 1; visibility: visible; }
.sheet {
    position: fixed;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    bottom: 0;
    width: 100%;
    max-width: var(--app-width);
    max-height: 92dvh;
    background: var(--bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 400;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.show { transform: translateX(-50%) translateY(0); }
.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--space);
    background: var(--surface);
    border-bottom: 0.5px solid var(--separator);
    flex-shrink: 0;
}
.sheet-title { font-size: var(--font-body); font-weight: 600; }
.sheet-btn {
    border: none;
    background: none;
    font-size: var(--font-body);
    cursor: pointer;
    padding: 4px 8px;
    min-height: 36px;
}
.sheet-btn-cancel { color: var(--text-secondary); }
.sheet-btn-save { color: var(--primary); font-weight: 600; }
.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space);
    -webkit-overflow-scrolling: touch;
}
.sheet .form-group { margin-bottom: var(--space); }
.sheet .form-label {
    display: block;
    font-size: var(--font-caption);
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.sheet .form-input,
.sheet .form-textarea,
.sheet .form-select {
    width: 100%;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface);
    padding: 12px;
    font-size: var(--font-body);
    font-family: inherit;
    outline: none;
    box-shadow: var(--shadow-card);
}
.sheet .form-textarea { min-height: 80px; resize: vertical; }
.sheet .checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet .checkbox-item {
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 18px;
    border: 1px solid #e5e5ea;
    background: var(--surface);
    font-size: var(--font-caption);
    cursor: pointer;
}
.sheet .checkbox-item:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.sheet .score-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 0.5px solid var(--separator);
}
.sheet .score-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.sheet .score-year {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: var(--font-caption);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    align-items: flex-end;
    justify-content: center;
}
.modal.show { display: flex; }
.modal-content {
    width: 100%;
    max-width: var(--app-width);
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 80dvh;
    overflow-y: auto;
    padding: var(--space-lg);
    animation: slideUp 0.3s ease-out;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.25rem; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    transition: var(--transition);
    border-radius: 0.25rem;
}
.modal-close:hover { background: rgba(0,0,0,0.05); }

/* ===== Toast ===== */
.toast {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    max-width: calc(var(--app-width) - 32px);
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0) + 16px);
    top: auto;
    text-align: center;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease-out;
    font-size: 0.875rem;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.warning { background: var(--warning); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }

/* ===== Loading ===== */
#loadingIndicator { background: var(--bg) !important; }
.loading {
    width: 32px; height: 32px;
    border: 3px solid #e5e5ea;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space);
    padding: var(--space) 0;
}
.pagination button {
    min-height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--primary);
    font-size: var(--font-caption);
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:active:not(:disabled) { transform: scale(0.96); }
.page-info { font-size: var(--font-caption); color: var(--text-secondary); }

/* ===== Bar Charts ===== */
.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-item { display: flex; align-items: center; gap: 0.75rem; }
.bar-label { min-width: 80px; font-size: var(--font-small); flex-shrink: 0; }
.bar-wrapper {
    flex: 1;
    height: 22px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
    font-size: 11px;
    display: flex;
    align-items: center;
    padding-left: 6px;
    min-width: 24px;
    border-radius: 4px;
    transition: width 0.6s ease-out;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes slideIn {
    from { transform: translateX(-50%) translateY(20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Staggered entry for match results */
@keyframes listItemIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}
.match-item {
    animation: listItemIn 0.3s ease-out both;
}
.match-item:nth-child(1) { animation-delay: 0.05s; }
.match-item:nth-child(2) { animation-delay: 0.1s; }
.match-item:nth-child(3) { animation-delay: 0.15s; }
.match-item:nth-child(4) { animation-delay: 0.2s; }
.match-item:nth-child(5) { animation-delay: 0.25s; }
.match-item:nth-child(6) { animation-delay: 0.3s; }
.match-item:nth-child(7) { animation-delay: 0.35s; }
.match-item:nth-child(8) { animation-delay: 0.4s; }
.match-item:nth-child(9) { animation-delay: 0.45s; }
.match-item:nth-child(10) { animation-delay: 0.5s; }

/* ===== Responsive ===== */
@media (max-width: 380px) {
    .match-direction-grid { grid-template-columns: repeat(2, 1fr); }
    .match-region-grid { grid-template-columns: repeat(2, 1fr); }
    .list-item-summary {
        grid-template-columns: 20px 1fr auto;
        grid-template-rows: auto auto;
    }
    .col-score { grid-column: 3; grid-row: 1; }
    .col-subject { grid-column: 3; grid-row: 2; justify-self: end; }
    .col-action { display: none; }
    .tool-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) {
    .app-shell {
        border-radius: var(--radius-lg);
        margin: 20px auto;
        min-height: calc(100dvh - 40px);
    }
    .tab-bar {
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
}

/* ===== Utility ===== */
.admin-only[hidden] { display: none !important; }
.program-name { word-break: break-word; }

/* ===== Form styles (legacy) ===== */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text); }
.form-label .required { color: var(--danger); margin-left: 0.25rem; }
.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e5ea;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-textarea { resize: vertical; min-height: 100px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; }
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition);
}
.checkbox-item:hover { background: rgba(37, 99, 235, 0.05); }
.checkbox-item input[type="checkbox"] {
    width: 1.25rem; height: 1.25rem;
    cursor: pointer;
    accent-color: var(--primary);
}