* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ====== Themes ====== */
[data-theme="light"] {
    --bg: #f2f2f7;
    --card-bg: #fafafa;
    --card-border: transparent;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04);
    --highlight-bg: #007aff;
    --highlight-shadow: 0 4px 16px rgba(0,122,255,0.25);
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;
    --text-placeholder: #c7c7cc;
    --text-on-primary: #f5f5f7;
    --text-on-highlight: #f5f5f7;
    --text-on-highlight-secondary: rgba(250,250,250,0.55);
    --primary: #007aff;
    --primary-hover: #0062cc;
    --input-bg: #f9f9fb;
    --input-border: #e5e5ea;
    --input-focus-ring: rgba(0,122,255,0.08);
    --btn-secondary-bg: #f2f2f7;
    --btn-secondary-text: #1d1d1f;
    --btn-secondary-active: #e5e5ea;
    --tag-bg: #f2f2f7;
    --tag-text: #1d1d1f;
    --tag-active-bg: #e5e5ea;
    --divider: #f2f2f7;
    --delete-color: #c7c7cc;
    --delete-active-bg: #f2f2f7;
    --delete-active-color: #ff3b30;
    --toast-success: #34c759;
    --toast-error: #ff3b30;
    --page-disabled: #c7c7cc;
    --page-active-bg: #1d1d1f;
    --page-active-text: #f5f5f7;
}

[data-theme="dark"] {
    --bg: #0d0d14;
    --card-bg: #1a1a24;
    --card-border: #2a2a36;
    --card-shadow: none;
    --highlight-bg: #1a1a24;
    --highlight-shadow: none;
    --text: #e5e5ea;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;
    --text-placeholder: #636366;
    --text-on-primary: #e5e5ea;
    --text-on-highlight: #e5e5ea;
    --text-on-highlight-secondary: rgba(229,229,234,0.55);
    --primary: #0a84ff;
    --primary-hover: #409cff;
    --input-bg: #1a1a24;
    --input-border: #38383a;
    --input-focus-ring: rgba(10,132,255,0.15);
    --btn-secondary-bg: #2a2a36;
    --btn-secondary-text: #e5e5ea;
    --btn-secondary-active: #3a3a46;
    --tag-bg: #2a2a36;
    --tag-text: #8e8e93;
    --tag-active-bg: #3a3a46;
    --divider: #38383a;
    --delete-color: #636366;
    --delete-active-bg: #251414;
    --delete-active-color: #ff453a;
    --toast-success: #30d158;
    --toast-error: #ff453a;
    --page-disabled: #636366;
    --page-active-bg: #0a84ff;
    --page-active-text: #e5e5ea;
}

/* ====== Comic Theme ====== */
[data-theme="comic"] {
    --bg: #f9faf8;
    --card-bg: #fdfdfb;
    --card-border: #c0d0c8;
    --card-shadow: 3px 3px 0 #c8d5cc;
    --highlight-bg: #e8f5ef;
    --highlight-shadow: 3px 3px 0 #c8d5cc;
    --text: #2d3a33;
    --text-secondary: #6b8a76;
    --text-tertiary: #9bb5a4;
    --text-placeholder: #b0c8b8;
    --text-on-primary: #fff;
    --text-on-highlight: #2d3a33;
    --text-on-highlight-secondary: rgba(45,58,51,0.55);
    --primary: #55b7a4;
    --primary-hover: #459e8c;
    --input-bg: #fdfdfb;
    --input-border: #c0d0c8;
    --input-focus-ring: rgba(85,183,164,0.2);
    --btn-secondary-bg: #fdfdfb;
    --btn-secondary-text: #2d3a33;
    --btn-secondary-active: #f0f5f2;
    --tag-bg: #e8f5ef;
    --tag-text: #2d3a33;
    --tag-active-bg: #d0e8da;
    --divider: #dce5df;
    --delete-color: #9bb5a4;
    --delete-active-bg: #f0f5f2;
    --delete-active-color: #d97a6b;
    --toast-success: #55b7a4;
    --toast-error: #d97a6b;
    --page-disabled: #c8d5cc;
    --page-active-bg: #2d3a33;
    --page-active-text: #f8faf9;
}

[data-theme="comic"] body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="comic"] .app-shell {
    background-image:
        radial-gradient(circle, rgba(85,183,164,0.06) 0.8px, transparent 0.8px),
        radial-gradient(circle, rgba(85,183,164,0.04) 1.5px, transparent 1.5px);
    background-size: 16px 16px, 48px 48px;
    background-position: 0 0, 8px 8px;
}

[data-theme="comic"] .container { max-width: 480px; margin: 0 auto; }

/* ---- Cards: comic panel style ---- */
[data-theme="comic"] .stat-card {
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: var(--card-bg);
    box-shadow: 3px 3px 0 var(--card-shadow);
    position: relative;
    overflow: hidden;
}

[data-theme="comic"] .stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary);
    opacity: 0.3;
}

[data-theme="comic"] .stat-card.highlight {
    background: linear-gradient(135deg, #e8f5ef 0%, var(--card-bg) 100%);
    border-color: var(--primary);
    box-shadow: 3px 3px 0 rgba(85,183,164,0.3);
}

/* ---- Top bar ---- */
[data-theme="comic"] .top-bar {
    border-bottom: 2px solid var(--card-border);
    background: linear-gradient(180deg, #e8f5ef 0%, #f0f7f3 100%);
    padding-bottom: 0;
}

[data-theme="comic"] .top-bar h1 {
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ---- Amount display ---- */
[data-theme="comic"] .stat-value {
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

[data-theme="comic"] .expense-row .amount {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* ---- Buttons ---- */
[data-theme="comic"] .btn-p,
[data-theme="comic"] .btn-login-full,
[data-theme="comic"] .btn-action-primary {
    border: 2px solid var(--primary);
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 2px 2px 0 rgba(85,183,164,0.4);
    transition: transform 0.1s, box-shadow 0.1s;
}

[data-theme="comic"] .btn-p:active,
[data-theme="comic"] .btn-login-full:active {
    transform: translate(1px, 1px);
    box-shadow: 0 0 0 transparent;
}

[data-theme="comic"] .btn-s,
[data-theme="comic"] .btn-admin-secondary {
    border: 2px solid var(--card-border);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text);
    font-weight: 500;
    box-shadow: 2px 2px 0 var(--card-shadow);
}

[data-theme="comic"] .btn { border-radius: 10px; font-weight: 500; }

[data-theme="comic"] .icon-btn {
    border-radius: 50%;
    transition: background 0.15s;
}

[data-theme="comic"] .icon-btn:active {
    background: var(--btn-secondary-active);
}

/* ---- Input fields ---- */
[data-theme="comic"] input[type="text"],
[data-theme="comic"] input[type="password"],
[data-theme="comic"] input[type="number"],
[data-theme="comic"] input[type="email"],
[data-theme="comic"] input[type="tel"],
[data-theme="comic"] textarea,
[data-theme="comic"] select,
[data-theme="comic"] .inp {
    border: 2px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03), 1px 1px 0 var(--card-shadow);
}

[data-theme="comic"] input:focus,
[data-theme="comic"] textarea:focus,
[data-theme="comic"] .inp:focus {
    border-color: var(--primary);
    box-shadow: inset 0 1px 2px rgba(85,183,164,0.1), 0 0 0 3px rgba(85,183,164,0.12);
    outline: none;
}

/* ---- Expense rows ---- */
[data-theme="comic"] .expense-row {
    border-bottom: 1.5px dotted var(--divider);
    transition: background 0.15s;
}

[data-theme="comic"] .expense-row:active {
    background: rgba(85,183,164,0.05);
}

/* ---- Toggle switches ---- */
[data-theme="comic"] .tgl-sw input:checked + .tgl-sl {
    background: var(--primary);
}

[data-theme="comic"] .tgl-sw2 input:checked + .tgl-sl2 {
    background: var(--primary);
}

/* ---- Bottom tab bar ---- */
[data-theme="comic"] .tab-bar {
    border-top: 2px solid var(--card-border);
    background: var(--card-bg);
}

[data-theme="comic"] .tab-bar .tab {
    position: relative;
    transition: color 0.2s;
}

[data-theme="comic"] .tab-bar .tab.active {
    color: var(--primary);
}

[data-theme="comic"] .tab-bar .tab.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

/* ---- Modals ---- */
[data-theme="comic"] .modal-bx {
    border: 2px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 4px 4px 0 var(--card-shadow);
    background: var(--card-bg);
}

/* ---- Toast ---- */
[data-theme="comic"] .toast {
    border: 2px solid var(--card-border);
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 2px 2px 0 var(--card-shadow);
}

/* ---- Budget bar ---- */
[data-theme="comic"] .budget-bar {
    background: var(--btn-secondary-active);
    border-radius: 6px;
    overflow: hidden;
}

[data-theme="comic"] .budget-fill {
    background: linear-gradient(90deg, var(--primary), #6bc4b0);
    border-radius: 6px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Tags ---- */
[data-theme="comic"] .tag {
    border: 1.5px solid var(--card-border);
    border-radius: 20px;
    background: var(--tag-bg);
    font-weight: 500;
}

/* ---- Category selector ---- */
[data-theme="comic"] .cat-icon {
    border: 2px solid var(--card-border);
    border-radius: 12px;
    transition: border-color 0.2s, transform 0.15s;
}

[data-theme="comic"] .cat-icon.active {
    border-color: var(--primary);
    box-shadow: 2px 2px 0 rgba(85,183,164,0.3);
}

/* ---- Panel / section headers ---- */
[data-theme="comic"] .pnl-hd h3 {
    font-weight: 700;
    position: relative;
    display: inline-block;
}

[data-theme="comic"] .pnl-hd h3::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    opacity: 0.5;
}

/* ---- Theme cards on theme.php ---- */
[data-theme="comic"] .theme-card2 {
    border: 2px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 3px 3px 0 var(--card-shadow);
    background: var(--card-bg);
    transition: transform 0.15s, box-shadow 0.15s;
}

[data-theme="comic"] .theme-card2:hover {
    transform: translateY(-1px);
    box-shadow: 4px 4px 0 var(--card-shadow);
}

[data-theme="comic"] .theme-card2.selected {
    border-color: var(--primary);
    box-shadow: 3px 3px 0 rgba(85,183,164,0.4);
}

[data-theme="comic"] .theme-card2:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 var(--card-shadow);
}

/* ---- Theme toggle row ---- */
[data-theme="comic"] .tg-item {
    border: 2px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 3px 3px 0 var(--card-shadow);
    background: var(--card-bg);
}

/* ---- Splash / Login ---- */
[data-theme="comic"] .splash-card {
    border: 2px solid var(--card-border);
    border-radius: 14px;
    box-shadow: 4px 4px 0 var(--card-shadow);
    background: var(--card-bg);
}

[data-theme="comic"] .splash-logo {
    border: 2px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 3px 3px 0 var(--card-shadow);
    background: linear-gradient(135deg, #e8f5ef, #d0e8da);
    color: var(--text);
    font-weight: 700;
}

/* ---- Empty state ---- */
[data-theme="comic"] .empty {
    border: 2px dashed var(--card-border);
    border-radius: 14px;
    padding: 36px 20px;
}

/* ---- Form groups ---- */
[data-theme="comic"] .fld {
    margin-bottom: 14px;
}

[data-theme="comic"] .lbl {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

/* ---- Highlight amount pills ---- */
[data-theme="comic"] .amount-positive {
    color: var(--primary);
    font-weight: 600;
}

[data-theme="comic"] .amount-negative {
    color: var(--delete-active-color);
    font-weight: 600;
}

/* ---- Dividers ---- */
[data-theme="comic"] hr {
    border: none;
    border-top: 1.5px dotted var(--divider);
}

/* ---- Links ---- */
[data-theme="comic"] a {
    color: var(--primary);
    font-weight: 500;
}

/* ---- Scrollbar ---- */
[data-theme="comic"] ::-webkit-scrollbar {
    width: 6px;
}

[data-theme="comic"] ::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 3px;
}

[data-theme="comic"] ::-webkit-scrollbar-track {
    background: transparent;
}

/* ---- Animations ---- */
@keyframes comicPopIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

[data-theme="comic"] .stat-card,
[data-theme="comic"] .expense-row {
    animation: comicPopIn 0.3s ease-out;
}

[data-theme="comic"] .stat-card:nth-child(odd) { animation-duration: 0.25s; }
[data-theme="comic"] .stat-card:nth-child(even) { animation-duration: 0.35s; }

/* Number change pulse */
@keyframes comicPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

[data-theme="comic"] .stat-value.pulse {
    animation: comicPulse 0.3s ease;
}

/* ---- Manga / Cartoon Elements ---- */

/* Manga panel corner marks on stat cards */
[data-theme="comic"] .stat-card::after {
    content: '\273F';
    position: absolute;
    bottom: -1px;
    right: 5px;
    font-size: 10px;
    color: var(--primary);
    opacity: 0.25;
    pointer-events: none;
}

[data-theme="comic"] .stat-card:nth-child(3n)::after { content: '\2741'; }
[data-theme="comic"] .stat-card:nth-child(3n+2)::after { content: '\273F'; }

/* Sparkle decorations on highlight cards */
[data-theme="comic"] .stat-card.highlight::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 10px;
    width: 12px;
    height: 12px;
    background: var(--primary);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: comicSparkle 1.5s ease-in-out infinite;
}

/* Speech bubble on splash */
[data-theme="comic"] .splash-desc {
    position: relative;
    display: inline-block;
    background: var(--card-bg);
    border: 1.5px solid var(--card-border);
    border-radius: 14px;
    padding: 6px 16px;
    margin-top: 4px;
}

[data-theme="comic"] .splash-desc::after {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 7px solid var(--card-border);
}

/* Action/speed lines on panel headers */
[data-theme="comic"] .pnl-hd {
    position: relative;
}

[data-theme="comic"] .pnl-hd::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 16px;
    background: var(--primary);
    border-radius: 1px;
    opacity: 0.5;
}

/* Cartoon star rating / status dots */
[data-theme="comic"] .toast.success::before {
    content: '\2605  ';
    color: #fff;
    font-size: 14px;
}

[data-theme="comic"] .toast.error::before {
    content: '\26A0  ';
    color: #fff;
    font-size: 14px;
}

/* Kira-kira sparkle animation */
@keyframes comicSparkle {
    0%, 100% { opacity: 0.3; transform: scale(1) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.3) rotate(15deg); }
}

/* Floating sparkles (decorative) */
[data-theme="comic"] .empty::before {
    content: '\2728';
    display: block;
    font-size: 36px;
    text-align: center;
    margin-bottom: 12px;
    animation: comicSparkle 2s ease-in-out infinite;
}

[data-theme="comic"] .splash-logo {
    position: relative;
}

[data-theme="comic"] .splash-logo::after {
    content: '\2728';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 14px;
    animation: comicSparkle 1.8s ease-in-out infinite;
}

/* Floating bubble decorations */
@keyframes comicFloat {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.15; }
    50% { transform: translateY(-8px) scale(1.2); opacity: 0.3; }
}

/* Speed lines animation for loading */
@keyframes comicSpeedLines {
    0% { background-position: 0 0; }
    100% { background-position: 40px 0; }
}

[data-theme="comic"] .spin {
    width: 28px;
    height: 28px;
    border: 3px solid var(--card-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: comicSpin 0.7s linear infinite;
    position: relative;
}

[data-theme="comic"] .spin::after {
    content: '\2605';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: var(--primary);
}

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

/* Halftone overlay for selected items */
[data-theme="comic"] .cat-icon.active {
    position: relative;
    overflow: hidden;
}

[data-theme="comic"] .cat-icon.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, var(--primary) 0.5px, transparent 0.5px);
    background-size: 6px 6px;
    opacity: 0.12;
}

/* Decorative corner bracket on modals */
[data-theme="comic"] .modal-bx {
    position: relative;
}

[data-theme="comic"] .modal-bx::before {
    content: '\276E\276F';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--primary);
    opacity: 0.3;
    letter-spacing: 2px;
}

/* Manga-style motion lines for amounts */
[data-theme="comic"] .stat-value {
    position: relative;
}

[data-theme="comic"] .stat-value::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--primary) 0px, var(--primary) 3px, transparent 3px, transparent 6px);
    opacity: 0.15;
    border-radius: 1px;
}

/* ---- More Manga Elements ---- */

/* Squiggly underline on links */
[data-theme="comic"] a {
    text-decoration: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='6'%3E%3Cpath d='M0 3 Q5 0 10 3 Q15 6 20 3 Q25 0 30 3 Q35 6 40 3 Q45 0 50 3 Q55 6 60 3 Q65 0 70 3 Q75 6 80 3 Q85 0 90 3 Q95 6 100 3' fill='none' stroke='%2355b7a4' stroke-width='1.5'/%3E%3C/svg%3E");
    background-position: 0 100%;
    background-repeat: repeat-x;
    background-size: 20px 4px;
    padding-bottom: 3px;
}

/* Bounce animation for buttons */
@keyframes comicBounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-3px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-1px); }
}

[data-theme="comic"] .btn-p:hover {
    animation: comicBounce 0.6s ease;
}

/* Rainbow gradient strip on top of page */
[data-theme="comic"] .top-bar {
    border-bottom: none;
    box-shadow: 0 2px 0 var(--card-border),
                0 4px 0 rgba(85,183,164,0.15),
                0 6px 0 rgba(255,200,100,0.08);
}

/* Pop effect on number highlight */
@keyframes comicBam {
    0% { transform: scale(1); }
    30% { transform: scale(1.3) rotate(-3deg); }
    60% { transform: scale(0.95) rotate(1deg); }
    100% { transform: scale(1) rotate(0); }
}

[data-theme="comic"] .amount-highlight {
    display: inline-block;
    animation: comicBam 0.5s ease;
}

/* Thought bubble on disabled inputs */
[data-theme="comic"] input:disabled {
    position: relative;
    background: repeating-linear-gradient(-45deg, transparent, transparent 4px, rgba(0,0,0,0.02) 4px, rgba(0,0,0,0.02) 8px);
}

/* Doodle frame border */
[data-theme="comic"] .splash-card {
    border-style: solid;
    border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Crect x='0' y='0' width='8' height='8' fill='%23c0d0c8' rx='1'/%3E%3C/svg%3E") 2 round;
    border-image-width: 2px;
}

@supports not (border-image: url("data:image/svg+xml")) {
    [data-theme="comic"] .splash-card { border-style: solid; }
}

/* Floating decorations on body */
[data-theme="comic"] body::before {
    content: '\273F \2663 \2764 \2726 \273F';
    position: fixed;
    top: 15%;
    left: 3%;
    font-size: 18px;
    color: var(--card-border);
    opacity: 0.12;
    pointer-events: none;
    writing-mode: vertical-rl;
    letter-spacing: 10px;
    animation: comicFloat 6s ease-in-out infinite;
    z-index: 0;
}

[data-theme="comic"] body::after {
    content: '\2605 \273F \2666 \273F \2606';
    position: fixed;
    bottom: 10%;
    right: 2%;
    font-size: 16px;
    color: var(--primary);
    opacity: 0.1;
    pointer-events: none;
    writing-mode: vertical-rl;
    letter-spacing: 12px;
    animation: comicFloat 8s ease-in-out infinite reverse;
    z-index: 0;
}

/* Concentrated lines behind panels */
@keyframes comicConcentrate {
    0% { background-position: 0 0; }
    100% { background-position: 100% 0; }
}

[data-theme="comic"] .pnl {
    position: relative;
}

[data-theme="comic"] .pnl::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 1.5px dashed var(--card-border);
    border-radius: 12px;
    opacity: 0.2;
    pointer-events: none;
    z-index: -1;
}

/* Comic-style separator ornament */
[data-theme="comic"] .divider-ornament {
    text-align: center;
    color: var(--primary);
    font-size: 12px;
    opacity: 0.3;
    letter-spacing: 6px;
    margin: 8px 0;
}

/* Manga eye-catch (important notice) */
[data-theme="comic"] .notice-manga {
    border: 2px solid var(--primary);
    background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(85,183,164,0.04) 10px, rgba(85,183,164,0.04) 20px);
    border-radius: 10px;
    padding: 14px 18px;
    position: relative;
}

[data-theme="comic"] .notice-manga::before {
    content: '\26A0';
    position: absolute;
    top: -12px;
    left: 12px;
    background: var(--bg);
    padding: 0 6px;
    font-size: 16px;
}

/* Comic "action" overlay for buttons */
[data-theme="comic"] .btn-p:active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 3px solid var(--primary);
    border-radius: 14px;
    animation: actionRing 0.4s ease-out forwards;
    pointer-events: none;
}

@keyframes actionRing {
    0% { inset: -2px; opacity: 1; }
    100% { inset: -12px; opacity: 0; }
}

/* Wobble shake on error */
@keyframes comicHeadShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-4px) rotate(-1deg); }
    30% { transform: translateX(4px) rotate(1deg); }
    45% { transform: translateX(-3px) rotate(-0.5deg); }
    60% { transform: translateX(3px) rotate(0.5deg); }
    75% { transform: translateX(-1px); }
}

[data-theme="comic"] .shake {
    animation: comicHeadShake 0.6s ease;
}

/* Cute decorative corner fold */
[data-theme="comic"] .stat-card.highlight {
    position: relative;
}

[data-theme="comic"] .stat-card.highlight::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, transparent 50%, rgba(85,183,164,0.15) 50%);
    border-radius: 0 0 10px 0;
}

/* Floating decoration bubbles */
@keyframes comicBubble {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(3px, -6px) scale(1.1); }
    50% { transform: translate(-2px, -12px) scale(0.9); }
    75% { transform: translate(-4px, -4px) scale(1.05); }
}

/* Manga-style progress dots */
[data-theme="comic"] .progress-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

[data-theme="comic"] .progress-dot {
    width: 10px;
    height: 10px;
    border: 2px solid var(--card-border);
    border-radius: 50%;
    background: var(--card-bg);
    transition: all 0.3s;
}

[data-theme="comic"] .progress-dot.active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 6px rgba(85,183,164,0.4);
    animation: comicPulse 1s ease infinite;
}

/* Zigzag / sawtooth divider */
[data-theme="comic"] .zigzag-divider {
    height: 8px;
    background: repeating-linear-gradient(45deg, transparent 0px, transparent 4px, var(--card-border) 4px, var(--card-border) 6px);
    margin: 12px 0;
    opacity: 0.3;
}

/* Comic panel frame for emphasis */
[data-theme="comic"] .panel-emphasis {
    border: 3px double var(--primary);
    border-radius: 8px;
    background: var(--card-bg);
    padding: 16px;
    position: relative;
}

/* Page curl effect on cards */
[data-theme="comic"] .theme-card2 {
    position: relative;
    overflow: hidden;
}

[data-theme="comic"] .theme-card2::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 16px 16px;
    border-color: transparent transparent var(--card-border) transparent;
    opacity: 0.2;
    transition: opacity 0.2s;
}

[data-theme="comic"] .theme-card2:hover::after {
    opacity: 0.4;
}

/* Comic theme - new expense app elements */
[data-theme="comic"] .type-toggle { background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 14px; }
[data-theme="comic"] .type-toggle button.active { box-shadow: 0 3px 12px rgba(85,183,164,.35); }
[data-theme="comic"] .cat-select { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .pay-chip { border: 2px solid var(--card-border); border-radius: 18px; }
[data-theme="comic"] .pay-chip.selected { border-color: var(--primary); background: rgba(85,183,164,.08); }
[data-theme="comic"] .exp-item { border-radius: 10px; margin: 2px 0; padding: 14px 10px; }
[data-theme="comic"] .exp-item .e-icon { border-radius: 14px; box-shadow: 0 2px 6px rgba(85,183,164,.2); }
[data-theme="comic"] .group-header { color: var(--primary); letter-spacing: 1px; }
[data-theme="comic"] .stat-card-sm { border: 2px solid var(--card-border); border-radius: 14px; }
[data-theme="comic"] .sc-income .sc-value { color: #55b7a4; }
[data-theme="comic"] .sc-expense .sc-value { color: var(--primary); }
[data-theme="comic"] .monthly-summary>div { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .amount-quick-select .amount-btn { border: 2px solid var(--card-border); border-radius: 16px; }
[data-theme="comic"] .amount-quick-select .amount-btn:active { background: rgba(85,183,164,.1); border-color: var(--primary); }
[data-theme="comic"] .empty-hint { font-style: italic; color: var(--text-secondary); }
[data-theme="comic"] .empty-hint::before { content: '\2728 '; }
[data-theme="comic"] .btn-submit { border-radius: 14px; }
[data-theme="comic"] .bottom-tab { border-top: 2px solid var(--card-border); background: repeating-linear-gradient(0deg, transparent, transparent 10px, rgba(85,183,164,.02) 10px, rgba(85,183,164,.02) 20px); }
[data-theme="comic"] .bottom-tab a.active { color: var(--primary); }
[data-theme="comic"] .bottom-tab a.active::after { content: ''; display: block; width: 4px; height: 4px; border-radius: 50%; background: var(--primary); margin-top: 2px; }
[data-theme="comic"] .modal-overlay { background: rgba(85,183,164,.2); }
[data-theme="comic"] .modal-sheet { border-top: 3px solid var(--primary); }
[data-theme="comic"] .search-bar input { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .search-bar select { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .e-delete-action { border-radius: 0 12px 12px 0; }

/* Comic theme - new expense app elements */
[data-theme="comic"] .type-toggle { background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 14px; }
[data-theme="comic"] .type-toggle button.active { box-shadow: 0 3px 12px rgba(85,183,164,.35); }
[data-theme="comic"] .cat-select { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .pay-chip { border: 2px solid var(--card-border); border-radius: 18px; }
[data-theme="comic"] .pay-chip.selected { border-color: var(--primary); background: rgba(85,183,164,.08); }
[data-theme="comic"] .exp-item { border-radius: 10px; margin: 2px 0; padding: 14px 10px; }
[data-theme="comic"] .exp-item .e-icon { border-radius: 14px; box-shadow: 0 2px 6px rgba(85,183,164,.2); }
[data-theme="comic"] .group-header { color: var(--primary); letter-spacing: 1px; }
[data-theme="comic"] .stat-card-sm { border: 2px solid var(--card-border); border-radius: 14px; }
[data-theme="comic"] .sc-income .sc-value { color: #55b7a4; }
[data-theme="comic"] .sc-expense .sc-value { color: var(--primary); }
[data-theme="comic"] .monthly-summary>div { border: 2px solid var(--card-border); border-radius: 12px; }
[data-theme="comic"] .amount-quick-select .amount-btn { border: 2px solid var(--card-border); border-radius: 16px; }
[data-theme="comic"] .amount-quick-select .amount-btn:active { background: rgba(85,183,164,.1); border-color: var(--primary); }
[data-theme="comic"] .empty-hint { font-style: italic; color: var(--text-secondary); }
[data-theme="comic"] .empty-hint::before { content: '\2728 '; }
[data-theme="comic"] .btn-submit { border-radius: 14px; }

[data-theme="modern"] body { background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Roboto", sans-serif; }
[data-theme="modern"] .app-shell { background: var(--bg); }
[data-theme="modern"] .container { max-width: 480px; margin: 0 auto; }

[data-theme="modern"] .top-bar { background: transparent; padding: 14px 0 10px; border-bottom: none; margin-bottom: 16px; justify-content: space-between; flex-direction: row; }
[data-theme="modern"] .top-bar h1 { font-size: 20px; font-weight: 700; color: var(--text); }
[data-theme="modern"] .top-bar-actions { margin-right: 0; }
[data-theme="modern"] .top-bar .icon-btn { color: var(--text-secondary); background: var(--card-bg); border-radius: 10px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }

[data-theme="modern"] .stats-row { gap: 8px; margin-bottom: 0; }
[data-theme="modern"] .stat-card { border-radius: 14px; padding: 16px 14px; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); transition: box-shadow 0.2s; }
[data-theme="modern"] .stat-card .stat-label { font-size: 12px; font-weight: 500; }
[data-theme="modern"] .stat-card .stat-value { font-size: 24px; font-weight: 700; }
[data-theme="modern"] .stat-card.highlight { background: var(--highlight-bg); border: none; color: #fff; box-shadow: var(--highlight-shadow); }
[data-theme="modern"] .stat-card.highlight .stat-label,
[data-theme="modern"] .stat-card.highlight .stat-value { color: var(--text-on-highlight); }
[data-theme="modern"] .stat-detail-hint { display: none; }

[data-theme="modern"] .panel,
[data-theme="modern"] .modal-box,
[data-theme="modern"] .dialog-box { border-radius: 16px; padding: 20px; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); margin-bottom: 12px; }
[data-theme="modern"] .form-panel h2,
[data-theme="modern"] .panel h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--divider); }

[data-theme="modern"] .form-panel input,
[data-theme="modern"] .form-panel textarea,
[data-theme="modern"] .ap-input,
[data-theme="modern"] .admin-input { background: var(--input-bg); border: 1.5px solid var(--input-border); border-radius: 12px; padding: 11px 14px; font-size: 15px; color: var(--text); transition: all 0.2s; }
[data-theme="modern"] .form-panel input:focus,
[data-theme="modern"] .ap-input:focus,
[data-theme="modern"] .admin-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--input-focus-ring); }

[data-theme="modern"] .btn-primary,
[data-theme="modern"] .btn-action-primary { border-radius: 12px; padding: 11px 20px; background: var(--primary); border: none; font-weight: 600; font-size: 14px; transition: transform 0.15s, opacity 0.15s; }
[data-theme="modern"] .btn-primary:active { transform: scale(0.97); opacity: 0.9; }

[data-theme="modern"] .amount-btn { border-radius: 10px; padding: 7px 12px; background: var(--btn-secondary-bg); border: 1px solid var(--input-border); color: var(--btn-secondary-text); font-weight: 500; font-size: 13px; }
[data-theme="modern"] .amount-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

[data-theme="modern"] .btn-action-outline,
[data-theme="modern"] .btn-ap-secondary,
[data-theme="modern"] .btn-admin-secondary { border-radius: 10px; padding: 8px 16px; border: 1px solid var(--input-border); background: var(--btn-secondary-bg); color: var(--text-secondary); }
[data-theme="modern"] .btn-admin-primary { border-radius: 12px; padding: 10px 22px; background: var(--primary); color: #fff; border: none; font-weight: 600; font-size: 14px; transition: opacity 0.15s, transform 0.15s; }
[data-theme="modern"] .btn-admin-primary:active { transform: scale(0.97); opacity: 0.9; }

[data-theme="modern"] .expense-row { border-radius: 12px; padding: 14px; margin-bottom: 4px; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: 0 1px 2px rgba(0,0,0,0.03); transition: box-shadow 0.15s; }
[data-theme="modern"] .expense-row:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.06); }
[data-theme="modern"] .expense-row .item { color: var(--text); font-weight: 500; }

[data-theme="modern"] .budget-card { border-radius: 14px; padding: 16px; margin: 14px 0; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); }
[data-theme="modern"] .budget-bar { background: var(--btn-secondary-bg); border-radius: 6px; height: 6px; overflow: hidden; }
[data-theme="modern"] .budget-fill { background: var(--primary); border-radius: 6px; }

[data-theme="modern"] .user-avatar { border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); border: 2px solid var(--card-bg); }

[data-theme="modern"] .admin-sidebar { background: var(--card-bg); border-right: 1px solid var(--divider); }
[data-theme="modern"] .admin-nav-item { border-radius: 10px; margin: 2px 8px; padding: 9px 12px; color: var(--text-secondary); transition: all 0.15s; font-size: 13px; }
[data-theme="modern"] .admin-nav-item:hover { background: var(--btn-secondary-bg); color: var(--text); }
[data-theme="modern"] .admin-nav-item.active { background: var(--highlight-bg); color: #fff; }

[data-theme="modern"] .pf-section { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; margin: 8px 0; box-shadow: var(--card-shadow); }
[data-theme="modern"] .pf-row { color: var(--text); border-bottom-color: var(--divider); }
[data-theme="modern"] .pf-row:active { background: var(--btn-secondary-active); }
[data-theme="modern"] .pf-section-label { color: var(--text-secondary); font-weight: 600; font-size: 13px; letter-spacing: 0.3px; }
[data-theme="modern"] .pf-logout { background: var(--card-bg); border: 1px solid var(--card-border); color: var(--delete-active-color); border-radius: 14px; box-shadow: var(--card-shadow); }

[data-theme="modern"] .theme-option { border-radius: 14px; padding: 12px; border: 1.5px solid var(--input-border); margin-bottom: 6px; transition: all 0.2s; background: var(--card-bg); }
[data-theme="modern"] .theme-option.selected { border-color: var(--primary); background: rgba(26,26,46,0.03); }

[data-theme="modern"] .announce-banner { border-radius: 14px; margin: 0 0 14px; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: var(--card-shadow); }

[data-theme="modern"] .toast { border-radius: 12px; padding: 12px 20px; font-weight: 500; backdrop-filter: blur(10px); }
[data-theme="modern"] .toast.success { background: var(--toast-success); color: #fff; }
[data-theme="modern"] .toast.error { background: var(--toast-error); color: #fff; }

[data-theme="modern"] .toggle-switch .toggle-slider { background: var(--input-border); border-radius: 12px; }
[data-theme="modern"] .toggle-switch input:checked + .toggle-slider { background: var(--primary); }

[data-theme="modern"] .app-shell::-webkit-scrollbar { width: 4px; }
[data-theme="modern"] .app-shell::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 4px; }

[data-theme="modern"] .stat-mini { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 16px; box-shadow: var(--card-shadow); }
[data-theme="modern"] .stat-mini.highlight-card { background: var(--highlight-bg); color: #fff; border: none; box-shadow: var(--highlight-shadow); }
[data-theme="modern"] .stat-mini.highlight-card .stat-mini-val,
[data-theme="modern"] .stat-mini.highlight-card .stat-mini-label { color: var(--text-on-highlight); }

[data-theme="modern"] .data-table { border-radius: 12px; overflow: hidden; background: var(--card-bg); border: 1px solid var(--divider); }
[data-theme="modern"] .data-table th { background: var(--btn-secondary-bg); color: var(--text-secondary); font-weight: 600; }
[data-theme="modern"] .data-table td { border-top: 1px solid var(--divider); color: var(--text); }
[data-theme="modern"] .category-tag { border-radius: 8px; padding: 6px 12px; font-weight: 500; }
[data-theme="modern"] .category-select,
[data-theme="modern"] .page-select { border-radius: 10px; background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text); }
[data-theme="modern"] .ap-section { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 16px; margin-bottom: 14px; box-shadow: var(--card-shadow); }
[data-theme="modern"] .ap-section-hd { border-bottom: 1px solid var(--divider); padding-bottom: 8px; }
[data-theme="modern"] .fb-card { border-radius: 14px; background: var(--card-bg); border: 1px solid var(--card-border); box-shadow: 0 1px 2px rgba(0,0,0,0.03); }
[data-theme="modern"] .modal-overlay { background: rgba(0,0,0,0.25); backdrop-filter: blur(4px); }

/* ====== Base ====== */
html {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

body {
    position: fixed;
    overflow: hidden;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overscroll-behavior: none;
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    height: 100%;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    -webkit-user-select: text;
    user-select: text;
}

.app-shell::-webkit-scrollbar {
    display: none;
}

.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* ====== Top bar ====== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 40px 4px 8px;
}

.top-bar h1 {
    font-size: 34px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.top-bar-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.icon-btn:active {
    transform: scale(0.92);
}

/* ====== Stats ====== */
.stats-row {
    display: flex;
    gap: 10px;
    margin: 4px 0 20px;
}

.stat-card {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border, transparent);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.stat-card.highlight {
    background: var(--highlight-bg);
    box-shadow: var(--highlight-shadow);
    border: none;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-card.highlight .stat-label {
    color: var(--text-on-highlight-secondary);
}

.stat-card.highlight .stat-value {
    color: var(--text-on-highlight);
}

.stat-detail-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-placeholder);
    margin-top: -12px;
    margin-bottom: 12px;
    display: none;
}

.stat-detail {
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-top: -8px;
    margin-bottom: 12px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--input-border);
}

.stat-card.stat-clickable {
    cursor: pointer;
    position: relative;
}

/* ====== Panel ====== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border, transparent);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.panel h2 {
    font-size: 20px;
    margin-bottom: 18px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ====== Form ====== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    outline: none;
    background: var(--input-bg);
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input::placeholder {
    color: var(--text-placeholder);
}

.form-group input:focus {
    border-color: var(--primary);
    background: var(--card-bg);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

/* Amount buttons */
.amount-quick-select {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.amount-btn {
    padding: 12px 0;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.amount-btn:active {
    transform: scale(0.96);
    background: var(--btn-secondary-active);
}

.amount-btn.active {
    background: var(--primary);
    color: var(--text-on-primary);
    border-color: var(--primary);
}

/* Submit */
.btn-submit {
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    border-radius: 14px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.3px;
    transition: opacity 0.15s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-submit:active {
    opacity: 0.8;
    transform: scale(0.98);
}

.btn-submit:disabled {
    opacity: 0.5;
    transform: none;
}

/* ====== Item history tags ====== */
.item-history {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.item-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border: none;
    border-radius: 20px;
    background: var(--tag-bg);
    color: var(--tag-text, var(--text));
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.item-tag:active {
    background: var(--tag-active-bg);
    transform: scale(0.96);
}

.tag-close {
    font-style: normal;
    font-size: 16px;
    color: var(--text-tertiary);
    line-height: 1;
    padding: 0 1px;
}

.tag-close:active {
    color: #ff3b30;
}

/* ====== Expense list ====== */
.empty-hint {
    text-align: center;
    color: var(--text-placeholder);
    padding: 56px 0;
    font-size: 15px;
    font-weight: 500;
}

.expense-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    gap: 14px;
    animation: itemIn 0.25s ease;
}

.expense-item + .expense-item {
    border-top: 1px solid var(--divider);
}

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

.expense-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    min-width: 0;
    max-width: 120px;
    text-align: right;
    flex-shrink: 1;
    letter-spacing: -0.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.expense-item-name {
    font-size: 16px;
    color: var(--text);
    word-break: break-all;
    line-height: 1.4;
    font-weight: 500;
}

.expense-meta {
    font-size: 13px;
    color: var(--text-tertiary, var(--text-secondary));
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.expense-delete {
    background: none;
    border: none;
    color: var(--delete-color);
    cursor: pointer;
    font-size: 18px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}

.expense-delete:active {
    background: var(--delete-active-bg);
    color: var(--delete-active-color);
}

/* ====== Pagination ====== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 20px 0 0;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 14px;
    border: none;
    border-radius: 10px;
    background: var(--btn-secondary-bg);
    color: var(--btn-secondary-text, var(--text));
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-width: 42px;
    min-height: 42px;
    transition: all 0.15s;
}

.pagination button:active {
    background: var(--btn-secondary-active);
}

.pagination button:disabled {
    color: var(--page-disabled);
    background: transparent;
}

.pagination button.active {
    background: var(--page-active-bg);
    color: var(--page-active-text);
}

.pagination .page-info {
    font-size: 12px;
    color: var(--text-tertiary, var(--text-secondary));
    width: 100%;
    text-align: center;
    margin-top: 6px;
}

/* ====== Toast ====== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 28px;
    border-radius: 14px;
    color: #f5f5f7;
    font-size: 15px;
    font-weight: 600;
    z-index: 20000;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: toastIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.toast.success { background: var(--primary); }
.toast.error { background: var(--toast-error); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(0.92); }
    to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    to { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.95); }
}
.toast.out { animation: toastOut 0.25s ease forwards; }
.toast.info { background: #3b82f6; }
.toast.warning { background: #f59e0b; }

/* ====== 加载状态 ====== */
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(250,250,250,0.3); border-top-color: #f5f5f7;
    border-radius: 50%; animation: spin 0.6s linear infinite;
    vertical-align: middle; margin-right: 6px;
}
.spinner-dark { border-color: rgba(0,0,0,0.15); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-loading { pointer-events: none; opacity: 0.7; }
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--divider) 50%, var(--card-bg) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite;
    border-radius: 8px; height: 16px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ====== 空状态 ====== */
.empty-state {
    text-align: center; padding: 40px 20px; color: var(--text-secondary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state-text { font-size: 15px; margin-bottom: 4px; }
.empty-state-sub { font-size: 13px; opacity: 0.7; }

/* ====== Login Page ====== */
.login-body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px 16px;
}
.login-body .app-shell {
    height: auto;
    overflow: visible;
    width: 100%;
    max-width: 400px;
    flex-shrink: 0;
}

.login-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border, transparent);
}

.login-card h1 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-card .login-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 32px;
}

.login-error {
    text-align: center;
    color: var(--toast-error);
    font-size: 14px;
    margin-bottom: 16px;
    min-height: 20px;
}

/* ====== Admin Page ====== */
.admin-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.admin-back {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--btn-secondary-bg);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
}

.admin-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: var(--btn-secondary-bg);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}

.admin-tab:first-child { border-radius: 10px 0 0 10px; }
.admin-tab:last-child { border-radius: 0 10px 10px 0; }
.admin-tab.active {
    background: var(--primary);
    color: var(--text-on-primary);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 10px 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
    border-bottom: 1px solid var(--divider);
}

.admin-table td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--divider);
    color: var(--text);
}

.admin-table .btn-sm {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 4px;
    transition: opacity 0.15s;
}

.admin-table .btn-sm:active { opacity: 0.7; }

.btn-edit { background: var(--primary); color: var(--text-on-primary); }
.btn-del { background: var(--toast-error); color: #f5f5f7; }

.admin-form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.admin-form-row input {
    flex: 1;
    padding: 14px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
}

.admin-form-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

.admin-form-row .btn-sm {
    padding: 14px 20px;
    white-space: nowrap;
    border-radius: 12px;
    font-size: 16px;
}

/* ====== Theme Select Modal ====== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    width: 90%;
    max-width: 340px;
    box-shadow: var(--card-shadow);
}

.modal-box h3 {
    font-size: 18px;
    margin-bottom: 20px;
    text-align: center;
    color: var(--text);
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1.5px solid var(--input-border);
    background: var(--card-bg);
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.theme-option:active { transform: scale(0.98); }
.theme-option.selected { border-color: var(--primary); }

.theme-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

.theme-dot.light { background: #007aff; }
.theme-dot.dark { background: #0a84ff; }

.theme-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.theme-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.modal-close {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    border: none;
    border-radius: 12px;
    background: var(--btn-secondary-bg);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* User info display */
.user-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* ====== Profile Page ====== */
.profile-header {
    text-align: center;
    padding: 24px 0 28px;
}

.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-wrap {
    position: relative;
    display: inline-block;
    margin-bottom: 14px;
}

.profile-avatar-overlay { display: none; }

.profile-avatar-actions { display: none; }

.profile-avatar-img {
    width: 72px;
    height: 72px;
    max-width: 72px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.profile-qq { margin-bottom: 8px; }

.btn-qq-sync {
    font-size: 13px;
    color: var(--primary);
    background: none;
    border: 1px solid var(--primary);
    border-radius: 16px;
    padding: 4px 16px;
    cursor: pointer;
    transition: opacity .2s;
}
.btn-qq-sync:disabled { opacity: 0.5; }

.profile-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.profile-name:hover {
    opacity: 0.7;
}

.profile-uid {
    font-size: 13px;
    color: var(--text-secondary);
}
.profile-apple {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.profile-menu {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border, transparent);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 24px;
}

.profile-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.profile-menu-item + .profile-menu-item {
    border-top: 1px solid var(--divider);
}

.profile-menu-item:active {
    background: var(--btn-secondary-active, rgba(0,0,0,0.04));
}

.menu-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    color: var(--primary);
}

.menu-label {
    font-size: 16px;
    color: var(--text);
    font-weight: 500;
}

.menu-value {
    font-size: 14px;
    color: var(--text-secondary);
}

.menu-arrow {
    font-size: 16px;
    color: var(--text-tertiary, var(--text-secondary));
}

.menu-group-label {
    padding: 18px 20px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    border-top: 1px solid var(--divider);
}
.menu-group-label:first-child {
    border-top: none;
    padding-top: 10px;
}
.menu-group-label + .profile-menu-item {
    border-top: none;
}

.profile-actions {
    padding: 0;
}

.btn-logout {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: var(--card-bg);
    color: #ff3b30;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    -webkit-tap-highlight-color: transparent;
}

.btn-logout:active {
    opacity: 0.7;
}

/* ====== Top bar left (profile) ====== */
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ====== Remember label ====== */
.remember-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    font-size: 14px !important;
    color: var(--text-secondary) !important;
    cursor: pointer;
    padding: 12px 0;
}

.remember-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ====== Edit name button ====== */
.btn-edit-name {
    display: block;
    margin: 10px auto 0;
    padding: 6px 16px;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    background: transparent;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ====== Chart ====== */
.chart-container {
    padding: 8px 0;
}

.chart-empty {
    text-align: center;
    color: var(--text-placeholder);
    padding: 40px 0;
    font-size: 14px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 160px;
    padding: 0 10px;
}

.chart-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    max-width: 50px;
}

.chart-bar {
    width: 28px;
    border-radius: 6px 6px 0 0;
    background: var(--primary);
    min-height: 4px;
    transition: height 0.5s ease;
}

.chart-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ====== Category management ====== */
.cat-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.cat-form input {
    flex: 1;
    padding: 12px 14px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
}

.cat-form input:focus {
    border-color: var(--primary);
}

.cat-list {
    max-height: 300px;
    overflow-y: auto;
}

.cat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
    font-size: 15px;
    color: var(--text);
}

.cat-del {
    background: none;
    border: none;
    color: var(--delete-color);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.cat-empty {
    text-align: center;
    color: var(--text-placeholder);
    padding: 30px 0;
    font-size: 14px;
}

/* ====== Date filter ====== */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.list-header h2 {
    margin-bottom: 0 !important;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.df-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 16px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
}

.df-btn.df-active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--text-on-primary);
}

.date-input {
    width: 110px;
    padding: 6px 8px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
}

.date-sep {
    color: var(--text-secondary);
    font-size: 12px;
}

.btn-filter {
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-filter.btn-clear {
    background: var(--btn-secondary-bg);
    color: var(--text-secondary);
}

.expense-cat {
    background: var(--tag-bg);
    color: var(--tag-text, var(--text-secondary));
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 11px;
}

/* ====== Toggle switch ====== */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--divider);
}

.toggle-label {
    font-size: 15px;
    color: var(--text);
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--input-border);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider:before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: #f5f5f7;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* ====== Admin stats ====== */
.admin-stats {
    margin-bottom: 16px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.stat-mini {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 14px 8px;
    text-align: center;
    border: 1px solid var(--card-border, transparent);
    box-shadow: var(--card-shadow);
}

.stat-mini-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-mini-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.display-name-cell {
    cursor: pointer;
    color: var(--primary);
    transition: opacity 0.15s;
}

.display-name-cell:hover {
    opacity: 0.7;
}

.admin-inline-edit {
    margin: 0;
}

.admin-record-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}
.admin-record-filter .date-input {
    flex: 1;
    min-width: 100px;
}
.admin-record-filter .date-sep {
    flex-shrink: 0;
    color: var(--text-placeholder);
    font-size: 13px;
}

/* ====== Admin table (row-based) ====== */
.admin-table-wrap {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--divider);
}

.admin-table-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--divider);
    font-size: 14px;
    color: var(--text);
    gap: 4px;
}

.admin-table-row:last-child {
    border-bottom: none;
}

.admin-table-hd {
    background: var(--btn-secondary-bg);
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    font-weight: 500;
    padding: 8px 14px;
}

.col-user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-role { width: 48px; text-align: center; }
.col-op { width: auto; display: flex; gap: 4px; justify-content: flex-end; }

.name-editable {
    cursor: pointer;
    color: var(--primary);
    transition: opacity 0.15s;
}

.name-editable:hover {
    opacity: 0.7;
}

.admin-btn-reset,
.admin-btn-del {
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* ====== User avatar ====== */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s;
    position: relative;
    overflow: hidden;
}

.user-avatar:active {
    transform: scale(0.92);
}

.user-avatar-letter {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 17px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* ====== Login logo ====== */
.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 30px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

/* ====== Chart modal ====== */
.chart-modal-box {
    min-height: 300px;
}

/* ====== Expense delete button in admin ====== */
.expense-del-btn {
    background: none;
    border: none;
    color: var(--toast-error);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.expense-del-btn:active {
    opacity: 1;
}

/* ====== Login button disabled ====== */
.btn-submit:disabled {
    opacity: 0.6;
}

/* ====== Round add button ====== */
.btn-round-add {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 24px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    padding-bottom: 2px;
    transition: transform 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.btn-round-add:active {
    transform: scale(0.9);
    opacity: 0.8;
}

/* ====== Search bar ====== */
.search-bar {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    margin-bottom: 10px;
}

.search-bar:focus {
    border-color: var(--primary);
}

.search-bar::placeholder {
    color: var(--text-placeholder);
}

/* ====== Swipe delete ====== */
.expense-swipe-container {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.expense-swipe-bg {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80px;
    background: #ff3b30;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f5f5f7;
    font-size: 14px;
    font-weight: 600;
    border-radius: 0;
    cursor: pointer;
}

.expense-swipe-inner {
    position: relative;
    z-index: 1;
    transition: transform 0.25s ease;
    background: var(--card-bg);
}

/* ====== Theme Modal ====== */

/* ====== Splash / Login rewrite ====== */
.splash-card {
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    text-align: center;
}

.splash-logo {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 36px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 30px rgba(0, 122, 255, 0.2);
}

.splash-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.splash-desc {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 36px;
}

.login-form {
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 12px;
}

.login-form input[type="text"],
.login-form input[type="password"],
.login-form input[type="email"],
.login-form input[type="tel"],
.login-form input[type="number"] {
    width: 100%;
    padding: 15px 18px;
    border: 1.5px solid var(--input-border);
    border-radius: 14px;
    font-size: 17px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    transition: border-color 0.2s;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--input-focus-ring);
}

.login-form input::placeholder {
    color: var(--text-placeholder);
}

.btn-login-full {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-login-full:disabled {
    opacity: 0.6;
}

.splash-divider {
    display: flex;
    align-items: center;
    margin: 28px 0;
}

.splash-divider::before,
.splash-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--divider);
}

.splash-divider span {
    padding: 0 16px;
    color: var(--text-placeholder);
    font-size: 13px;
}

.btn-guest {
    margin-top: 28px;
    width: 100%;
    padding: 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 14px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.btn-guest:active {
    background: var(--btn-secondary-bg);
    border-color: var(--primary);
}

.guest-hint {
    text-align: center;
    font-size: 12px;
    color: var(--text-placeholder);
    margin-top: 14px;
    line-height: 1.5;
}

/* ====== Guest mode banner ====== */
.guest-banner {
    background: var(--primary);
    color: var(--text-on-primary);
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
    border-radius: 10px;
    cursor: pointer;
}

.guest-banner:active {
    opacity: 0.8;
}

/* ====== Budget card ====== */
.budget-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 14px 18px;
    margin-bottom: 14px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
}

.budget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.budget-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

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

.budget-progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.budget-edit-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    background: var(--btn-secondary-bg);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    color: var(--text-secondary);
    -webkit-tap-highlight-color: transparent;
}

.budget-edit-btn:active {
    background: var(--input-focus-ring);
}

.budget-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--success, #34c759);
    transition: width 0.5s ease, background 0.3s;
    min-width: 0;
    max-width: 100%;
}

.budget-fill.warning {
    background: #ff9500;
}

.budget-fill.danger {
    background: #ff3b30;
}

.budget-edit-row {
    display: none;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
}

.budget-edit-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
}

.budget-edit-row input:focus {
    border-color: var(--primary);
}

.btn-budget-save {
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-budget-save:active {
    opacity: 0.8;
}

.btn-budget-cancel {
    padding: 10px 16px;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-budget-cancel:active {
    background: var(--btn-secondary-bg);
}

/* ====== Admin sidebar layout ====== */
.admin-layout {
    display: flex;
    min-height: 100%;
}

.admin-sidebar {
    width: 180px;
    min-width: 180px;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    padding: 0;
    display: flex;
    flex-direction: column;
}

.admin-sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--divider);
}

.admin-sidebar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.admin-nav {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.admin-nav-item.active {
    background: var(--primary);
    color: var(--text-on-primary);
}

.admin-nav-item:active:not(.active) {
    background: var(--btn-secondary-bg);
}

.admin-nav-icon {
    width: 20px;
    text-align: center;
}

.admin-main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.admin-select {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    -webkit-appearance: none;
}

.activity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
    font-size: 13px;
}

.activity-user { font-weight: 600; color: var(--text); min-width: 80px; }
.activity-stat { color: var(--text-secondary); }
.activity-time { color: var(--text-tertiary); font-size: 12px; }

/* ====== Generic sections (for data.php, categories.php etc) ====== */
.section {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 14px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--card-border);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px 0;
}

.section-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0 0 14px 0;
}

.btn-action {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

.restore-status {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    display: none;
}
.restore-status.success { display: block; background: rgba(52, 199, 89, 0.1); color: #34c759; }
.restore-status.error { display: block; background: rgba(255, 59, 48, 0.1); color: #ff3b30; }

/* ====== Chart standalone page ====== */
.chart-page-container {
    padding: 16px 0;
}

.chart-bars {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    justify-content: center;
    height: 220px;
    padding: 0 8px;
}

.chart-bar-col {
    flex: 1;
    max-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
    height: 100%;
}

.chart-value {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
}

.chart-bar {
    width: 100%;
    max-width: 48px;
    border-radius: 8px 8px 0 0;
    background: var(--primary);
    opacity: 0.85;
    min-height: 4px;
    transition: height 0.4s ease, opacity 0.3s;
}

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

.chart-total {
    text-align: center;
    margin-top: 16px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

/* Pie Chart */
.pie-section { margin-top: 32px; }
.pie-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}
.pie-chart-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}
.pie-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 8px;
}
.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--card-bg);
    border-radius: 10px;
}
.pie-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pie-legend-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}
.pie-legend-value {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; min-width: auto; border-right: none; border-bottom: 1px solid var(--divider); }
    .admin-sidebar-header { display: none; }
    .admin-sidebar-footer { display: flex !important; flex-direction: row !important; gap: 8px; padding: 8px 12px !important; }
    .admin-sidebar-footer .btn-back-front { width: auto; flex: 1; font-size: 12px; padding: 8px 12px; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; padding: 4px; gap: 2px; }
    .admin-nav-item { white-space: nowrap; flex-shrink: 0; padding: 8px 10px; font-size: 12px; border-radius: 8px; }
    .admin-nav-item .admin-nav-icon { display: none; }
    .admin-main { padding: 12px; }
    .admin-main-header { flex-direction: row !important; }
}

.admin-sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--divider);
    margin-top: auto;
    display:flex;
    flex-direction:column;
    gap:8px;
}

.btn-back-front {
    width: 100%;
    padding: 10px;
    border: 1.5px solid var(--primary);
    border-radius: 10px;
    background: transparent;
    color: var(--primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-back-front:active { background: var(--input-focus-ring); }

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.admin-theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    color: #1d1d1f;
    background: #fafafa;
    -webkit-tap-highlight-color: transparent;
}

.admin-theme-option.selected {
    border-color: #1a73e8;
    background: #e8f0fe;
    color: #1967d2;
    font-weight: 600;
}

.admin-theme-option .theme-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toggle-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
}

.toggle-row:last-child { border-bottom: none; }

.range-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    padding: 0 4px;
}

.range-btn {
    flex: 1;
    padding: 10px 8px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.range-btn.active {
    background: var(--primary);
    color: var(--text-on-primary);
    border-color: var(--primary);
}

.range-btn:active:not(.active) { background: var(--btn-secondary-bg); }

/* ====== Admin polish ====== */
.admin-welcome { padding: 16px 20px; margin-bottom: 14px; }

.welcome-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.welcome-title { font-size: 17px; font-weight: 700; color: var(--text); }
.welcome-sub { font-size: 13px; color: var(--text-tertiary); margin-top: 2px; }

.admin-stat-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

.admin-stat-grid .stat-mini {
    padding: 14px 12px;
    border-radius: 12px;
    background: var(--btn-secondary-bg);
    text-align: center;
}

.admin-stat-grid .highlight-card {
    background: var(--primary);
    color: var(--text-on-primary);
}

.admin-stat-grid .highlight-card .stat-mini-val { color: var(--text-on-primary); }
.admin-stat-grid .highlight-card .stat-mini-label { color: rgba(255,255,255,0.7); }

.admin-add-user {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
}

.admin-input:focus { border-color: var(--primary); }

.admin-record-header { margin-bottom: 10px; }

.activity-table { font-size: 13px; }

.activity-hd {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid var(--divider);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
}

.activity-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}

.act-user { flex: 2; font-weight: 600; color: var(--text); }
.act-count { flex: 1; text-align: center; color: var(--text-secondary); }
.act-amount { flex: 1.5; text-align: center; color: var(--primary); font-weight: 600; }
.act-time { flex: 2; text-align: right; color: var(--text-tertiary); font-size: 12px; }

.config-toggles { display: flex; flex-direction: column; }

.config-toggle-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--divider);
}

.config-toggle-item:last-child { border-bottom: none; }

/* ====== User cards (admin) ====== */
.user-card-list { display: flex; flex-direction: column; gap: 10px; }

.user-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--divider, #e5e5ea);
}

.user-card-top { display: flex; align-items: center; gap: 12px; }

.user-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--text-on-primary);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-card-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

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

.user-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-card-username {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.user-card-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.4;
}

.badge-admin { background: var(--primary); color: var(--text-on-primary); }
.badge-user  { background: var(--btn-secondary-bg); color: var(--text-secondary); }
.badge-banned { background: #ff3b30; color: #fff; }

.user-card-banned-info {
    font-size: 11px;
    color: #ff3b30;
    margin-top: 2px;
}

.user-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-action-outline, .btn-action-danger, .btn-action-primary, .btn-admin-primary {
    flex: 1;
    min-width: 60px;
    padding: 10px 0;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity 0.15s;
}

.btn-admin-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}

.btn-action-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-action-primary {
    background: transparent;
    color: #ff9500;
    border: 1.5px solid #ff9500;
}

.btn-action-danger {
    background: transparent;
    color: #ff3b30;
    border: 1.5px solid #ff3b30;
}

.btn-action-outline:active, .btn-action-danger:active, .btn-action-primary:active, .btn-admin-primary:active { opacity: 0.7; }

.ban-options {
    display: flex;
    gap: 10px;
    margin: 16px 0 20px;
}

.ban-opt-btn {
    flex: 1;
    padding: 14px 0;
    border: 1.5px solid var(--input-border);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.ban-opt-btn:active, .ban-opt-btn:hover {
    border-color: var(--toast-error);
    color: var(--toast-error);
}

/* ====== Infinite scroll ====== */
.load-more {
    text-align: center;
    padding: 16px 0;
    font-size: 13px;
    color: var(--text-tertiary);
}

.config-toggle-info { flex: 1; }

.config-toggle-label { font-size: 14px; font-weight: 600; color: var(--text); }
.config-toggle-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.section-desc { font-size: 13px; color: var(--text-tertiary); margin-bottom: 12px; }

/* ====== Custom Dialog ====== */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dialogFadeIn 0.15s ease;
    padding: 20px;
}
.dialog-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 24px 20px 20px;
    max-width: 320px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    animation: dialogScaleIn 0.2s ease;
}
@keyframes dialogFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogScaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.dialog-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 8px; text-align: center; }
.dialog-message { font-size: 14px; color: var(--text-secondary); text-align: center; margin-bottom: 20px; line-height: 1.5; }
.dialog-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--input-border);
    border-radius: 10px;
    font-size: 16px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    margin-bottom: 16px;
    text-align: center;
}
.dialog-input:focus { border-color: var(--primary); }
.dialog-buttons { display: flex; gap: 8px; }
.dialog-btn {
    flex: 1;
    padding: 12px 0;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.dialog-btn:active { opacity: 0.7; }
.dialog-btn-cancel { background: var(--btn-secondary-bg); color: var(--text-secondary); }
.dialog-btn-confirm { background: var(--primary); color: var(--text-on-primary); }
.dialog-btn-danger { background: var(--toast-error); color: #fff; }
.dialog-btn-full { flex: 2; }

/* ====== Announcement Banner ====== */
.announce-banner {
    background: var(--card-bg);
    color: var(--text);
    padding: 14px 40px 14px 16px;
    font-size: 14px;
    position: relative;
    line-height: 1.5;
    font-weight: 500;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
    transition: background 0.15s;
}
.announce-banner:active { background: var(--btn-secondary-active); }
.announce-banner-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 2px;
}
.announce-banner-desc {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.announce-close {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    opacity: 0.5;
    line-height: 24px;
    text-align: center;
    background: transparent;
    color: var(--text-secondary);
    transition: opacity 0.15s;
}
.announce-close:hover { opacity: 1; }

/* ====== Announcement Popup Modal ====== */
.announce-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 24px;
    animation: overlayIn 0.25s ease;
}
@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.announce-popup {
    background: var(--card-bg);
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    animation: popupIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow: hidden;
}
@keyframes popupIn {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
}
.announce-popup-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.announce-popup-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    padding-right: 8px;
    line-height: 1.3;
}
.announce-popup-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--btn-secondary-bg);
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.announce-popup-close:hover { background: var(--btn-secondary-active); }
.announce-popup-body {
    padding: 12px 24px 0;
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
}
.announce-popup-more {
    display: block;
    margin: 20px 24px 24px;
    padding: 14px;
    text-align: center;
    background: var(--primary);
    color: #fff;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}
.announce-popup-more:active { transform: scale(0.97); }
.announce-popup-body {
    padding: 12px 20px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}
.announce-popup-more {
    display: block;
    margin: 16px 20px 20px;
    padding: 12px;
    text-align: center;
    background: var(--primary);
    color: #fff;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

/* ====== Announcement Detail Page ====== */
.announcement-article {
    padding: 8px 0;
}
.announcement-meta {
    font-size: 13px;
    color: var(--text-placeholder);
    margin-bottom: 16px;
}
.announcement-heading {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.3;
}
.announcement-summary {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
}
.announcement-body {
    font-size: 15px;
    color: var(--text);
    line-height: 1.8;
}
.announcement-body p {
    margin-bottom: 12px;
}
.announcement-body p:last-child {
    margin-bottom: 0;
}

/* ====== Admin Input Label ====== */
.admin-input-label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.admin-input-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}
.admin-input-row .admin-input-group {
    flex: 1;
    min-width: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 8px;
}
.data-table th, .data-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--divider);
}
.data-table th {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 12px;
}
.data-table code {
    background: var(--selected-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.method-radio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: 10px;
    border: 1.5px solid var(--input-border);
    background: var(--card-bg);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.15s;
    user-select: none;
}
.method-radio-card:has(input:checked) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0,122,255,0.05);
}

.settings-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.settings-panel-header h2 { margin-bottom: 2px; }
.settings-panel-header .section-desc { margin-bottom: 0; }
.settings-panel {
    margin-bottom: 8px;
}

.reg-method-select {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
.reg-sub-config { padding-top: 8px; border-top: 1px solid var(--divider); }

.btn-admin-secondary {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--input-border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-admin-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ====== Apple Sign In Button ====== */
.btn-apple {
    margin-top: 28px;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #000;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}
.btn-apple:active { opacity: 0.8; }

/* Activity rows */
.activity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-user { font-weight: 600; color: var(--text); }
.activity-count { color: var(--text-secondary); font-size: 13px; }

/* ====== Invite Generator ====== */
.invite-generator {
    background: var(--selected-bg);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}
.invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.invite-actions .btn-admin-secondary {
    font-size: 12px;
    padding: 6px 12px;
}

/* ====== Desktop & iPad Adaptations ====== */
@media (min-width: 500px) {
    .bottom-tab {
        max-width: 480px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 16px 16px 0 0;
    }
    .bottom-tab-spacer { height: 80px; }
}

@media (min-width: 768px) {
    .app-shell {
        max-width: 480px;
        margin: 0 auto;
    }
}
