/* ========================================
   ListData - Premium UI v3.1 - Optimized
   Desktop & Mobile Responsive
   ======================================== */

/* CSS Variables */
:root {
    --bg: linear-gradient(145deg, #f0f4ff 0%, #e8f0fe 50%, #fce7f3 100%);
    --bg-solid: #f0f4ff;
    --card-bg: rgba(255, 255, 255, 0.92);
    --card-bg-solid: #ffffff;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.9);

    --ink: #1a1a2e;
    --ink-secondary: #4a5568;
    --ink-muted: #718096;

    --primary: #6366f1;
    --primary-light: rgba(99, 102, 241, 0.1);
    --primary-glow: rgba(99, 102, 241, 0.2);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);

    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);

    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.08);

    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);

    --border: rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.2s ease;
}

[data-theme="dark"] {
    --bg: linear-gradient(145deg, #0f0f1a 0%, #1a1a2e 50%, #16132d 100%);
    --bg-solid: #0f0f1a;
    --card-bg: rgba(30, 30, 50, 0.9);
    --card-bg-solid: #1e1e32;
    --glass: rgba(30, 30, 50, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);

    --ink: #f7fafc;
    --ink-secondary: #a0aec0;
    --ink-muted: #718096;

    --primary-light: rgba(99, 102, 241, 0.15);
    --success-light: rgba(16, 185, 129, 0.15);
    --danger-light: rgba(239, 68, 68, 0.12);
    --info-light: rgba(59, 130, 246, 0.15);

    --border: rgba(255, 255, 255, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    background-attachment: fixed;
    color: var(--ink);
    line-height: 1.5;
    font-size: 14px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   Layout - Responsive Container
   ======================================== */
.wrap {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 12px;
    padding-bottom: 100px;
}

@media (min-width: 768px) {
    .wrap {
        max-width: 98%;
        padding: 20px 24px 100px;
    }
}

@media (min-width: 1024px) {
    .wrap {
        max-width: 96%;
        padding: 24px 32px 100px;
    }
}

@media (min-width: 1400px) {
    .wrap {
        max-width: 1600px;
        padding: 32px 48px 100px;
    }
}

@media (min-width: 1800px) {
    .wrap {
        max-width: 1800px;
    }
}

/* ========================================
   Header
   ======================================== */
header {
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    pointer-events: none;
    /* Let clicks pass through gaps */
}

header>* {
    pointer-events: auto;
    /* Restore clicks on children */
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 12px;
    gap: 12px;
}

@media (min-width: 768px) {
    .header-inner {
        padding: 16px 24px;
    }
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

@media (min-width: 768px) {
    .brand-icon {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
}

.brand-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 50%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .brand-text h1 {
        font-size: 24px;
    }
}

.brand-tagline {
    font-size: 10px;
    color: var(--ink-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.save-indicator {
    font-size: 11px;
    color: var(--success);
    font-weight: 600;
    opacity: 0;
    transform: scale(0.9);
    transition: var(--transition);
    padding: 5px 10px;
    background: var(--success-light);
    border-radius: 16px;
    white-space: nowrap;
    display: none;
}

@media (min-width: 480px) {
    .save-indicator {
        display: block;
    }
}

.save-indicator.show {
    opacity: 1;
    transform: scale(1);
}

/* Report Button */
/* Report Button */
.btn-report {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    /* Slightly larger like screenshot */
    border-radius: 12px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-report-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
    margin-right: 8px;
    /* Gap between buttons */
}

.btn-report-blue:hover {
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.btn-report:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.btn-report .btn-icon {
    font-size: 14px;
}

.btn-report .btn-text {
    display: none;
}

@media (min-width: 400px) {
    .btn-report .btn-text {
        display: inline;
    }
}

/* Settings Button - Enhanced */
.btn-settings {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-settings:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

.btn-settings svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

/* Search Bar styles moved to optimized section below */

/* ========================================
   Storage Info Bar
   ======================================== */
/* ... existing storage info ... */

/* ... existing sections ... */

/* SETTINGS MODAL IMPROVEMENTS */
.settings-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Setting Sections - Clean Design */
.setting-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: visible;
    margin-bottom: 0;
}

.setting-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: transparent;
    border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .setting-section-header {
    background: rgba(255, 255, 255, 0.03);
}

.section-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.section-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.setting-item {
    padding: 16px;
}

/* Theme Setting - Better Layout */
.theme-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: nowrap;
}

/* Search Bar styles moved to optimized section below */

/* ========================================
   Storage Info Bar
   ======================================== */
.storage-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--ink-muted);
    margin-bottom: 16px;
}

.storage-icon {
    font-size: 16px;
}

/* ========================================
   Settings Modal - Fixed & Scrollable
   ======================================== */
.settings-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: hidden;
    /* Changed from auto to prevent double scrollbars, scrolling is inside modal body */
    animation: fadeIn 0.2s ease;
}

@media (min-width: 480px) {
    .settings-modal-overlay {
        align-items: center;
        padding: 20px;
    }
}

.settings-modal {
    background: var(--card-bg-solid);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin: auto 0;
    overflow: hidden;
    isolation: isolate;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.settings-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--card-bg-solid);
    z-index: 1;
}

.settings-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-title svg {
    color: var(--primary);
    width: 24px;
    height: 24px;
}

.settings-title h3 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.close-btn {
    width: 36px;
    height: 36px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--ink-muted);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}



/* Theme Toggle */
.theme-toggle {
    width: 60px;
    /* Optimal pill size */
    height: 30px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border: none;
    border-radius: 32px;
    cursor: pointer;
    position: relative;
    padding: 2px;
    transition: var(--transition);
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .theme-toggle {
    background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
}

.toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    /* Larger icons */
    z-index: 1;
    pointer-events: none;
}

.toggle-icon.light {
    left: 7px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle-icon.dark {
    right: 7px;
    opacity: 0.8;
}

.toggle-slider {
    position: absolute;
    width: 26px;
    height: 26px;
    background: white;
    border-radius: 50%;
    left: 2px;
    top: 2px;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

[data-theme="dark"] .toggle-slider {
    transform: translateX(30px);
}

/* Backup/Restore */
.backup-restore-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-backup,
.btn-restore {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    padding: 16px 14px;
    background: var(--bg-solid);
    border: 2px dashed var(--border);
    border-radius: 14px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 60px;
}

.btn-backup p,
.btn-restore p {
    margin: 0;
    font-size: 10px;
    font-weight: 400;
    color: var(--ink-muted);
    margin-top: 2px;
    line-height: 1.3;
}

.btn-backup svg,
.btn-restore svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    opacity: 0.8;
}

.btn-backup:hover {
    background: var(--success-light);
    border-color: var(--success);
    border-style: solid;
    color: var(--success);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-backup:hover svg {
    color: var(--success);
    opacity: 1;
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.setting-label span:first-child {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    line-height: 1.3;
}

.setting-desc {
    font-size: 12px;
    color: var(--ink-muted);
    line-height: 1.4;
    white-space: normal;
    word-wrap: break-word;
}

.btn-restore:hover {
    background: var(--info-light);
    border-color: var(--info);
    border-style: solid;
    color: var(--info);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-restore:hover svg {
    color: var(--info);
    opacity: 1;
}

.setting-hint {
    font-size: 11px;
    color: var(--ink-muted);
    text-align: center;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--glass);
    border-radius: 8px;
    line-height: 1.4;
}


.theme-toggle-wrapper {
    margin-right: 8px;
    /* Safe margin from edge */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Install Button - Make it match Backup/Restore style */
.btn-install {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    transition: var(--transition);
    margin: 0;
}

.btn-install:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}



/* Danger Zone */
.danger-zone {
    border-color: rgba(239, 68, 68, 0.2);
}

.danger-zone .setting-section-header {
    background: var(--danger-light);
    color: var(--danger);
}

.btn-danger {
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.danger-hint {
    color: var(--danger) !important;
}

/* App Info */
.app-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--ink-muted);
}

.storage-mini {
    color: var(--primary);
    font-weight: 600;
}

/* ========================================
   Confetti
   ======================================== */
#confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 99999;
}

/* ========================================
   Cards
   ======================================== */
.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card.collapsed .card-content {
    display: none;
}

.card.collapsed .title {
    background: var(--glass);
}

.card.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.title {
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: var(--transition);
    border-bottom: 1px solid transparent;
}

.card:not(.collapsed) .title {
    border-bottom-color: var(--border);
}

.title:hover {
    background: var(--glass);
}

.title-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.section-emoji {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.title h2 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 768px) {
    .title h2 {
        font-size: 17px;
    }
}

.count-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 16px;
    flex-shrink: 0;
}

.collapse-icon {
    color: var(--ink-muted);
    font-size: 12px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.card-content {
    padding: 16px;
    animation: slideDown 0.25s ease;
}

@media (min-width: 768px) {
    .card-content {
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .card-content {
        padding: 28px;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Form Fields
   ======================================== */
.fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 600px) {
    .fields {
        grid-template-columns: repeat(3, 1fr);
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

input,
textarea {
    padding: 12px 16px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--ink);
    font-size: 14px;
    font-family: var(--font);
    width: 100%;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.01);
}

input:hover,
textarea:hover {
    border-color: var(--ink-secondary);
    /* Slight border darkening on hover */
}

input:focus,
textarea:focus {
    outline: none;
    background: var(--card-bg-solid);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light), inset 0 1px 2px rgba(0, 0, 0, 0.01);
}

/* Search Bar - Fixed */
.header-search-row {
    margin-bottom: 12px;
}

.search-container {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
    /* Spacing from content */
}

.search-container .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--ink-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.header-search {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 2px solid var(--glass-border);
    border-radius: 14px;
    color: var(--ink);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
    height: 52px;
    /* Fixed height to ensure stability */
}

/* Textarea Optimized */
.t-area {
    min-height: 350px;
    font-family: 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', 'Menlo', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    margin-top: 20px;
    padding: 24px;
    white-space: pre;
    /* Keep 'pre' to preserve ASCII table alignment */
    overflow-x: auto;
    overflow-y: auto;
    background: var(--bg-solid);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    color: var(--ink);
    resize: vertical;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.t-area:focus {
    background: var(--card-bg-solid);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light), inset 0 1px 2px rgba(0, 0, 0, 0.03);
    outline: none;
}

@media (min-width: 768px) {
    .t-area {
        min-height: 500px;
        font-size: 14px;
        padding: 28px;
        line-height: 1.7;
    }
}

@media (min-width: 1024px) {
    .t-area {
        min-height: 600px;
        font-size: 15px;
        padding: 32px;
    }
}

/* Quick Chips */
.quick-sumber,
.quick-bank,
.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.quick-sumber button,
.quick-bank button,
.quick-chips button {
    background: var(--card-bg-solid);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.quick-sumber button:hover,
.quick-bank button:hover,
.quick-chips button:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========================================
   Action Buttons
   ======================================== */
.add-row,
.actions-bottom {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

button {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.b-add {
    flex: 1;
    min-width: 120px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3);
}

.b-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.ghost {
    background: var(--card-bg);
    color: var(--ink-secondary);
    border: 1px solid var(--border);
    flex: 1;
    min-width: 80px;
}

[data-theme="dark"] .ghost {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--ink-secondary);
}

.ghost:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .ghost:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-wa {
    background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
    color: white;
    flex: 1;
    min-width: 80px;
}

.btn-wa:hover {
    transform: translateY(-1px);
}

.danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.danger:hover {
    background: var(--danger);
    color: white;
}

/* ========================================
   List Items - OPTIMIZED for Mobile
   ======================================== */
.row-list-container {
    margin-top: 16px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 400px;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .row-list-container {
        max-height: 500px;
    }
}

.row-list {
    display: flex;
    flex-direction: column;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 14px;
}

.row-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg-solid);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    padding: 12px;
    background: var(--card-bg-solid);
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.row-item:last-child {
    border-bottom: none;
}

.row-item:hover {
    background: var(--primary-light);
}

[data-theme="dark"] .row-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.row-item.dragging {
    opacity: 0.5;
    background: var(--primary-light);
    border: 2px dashed var(--primary);
}

.row-no {
    width: 24px;
    height: 24px;
    background: var(--ink-secondary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .row-no {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

.row-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    /* Fix flex truncation */
}

/* Actions Stacked on Mobile */
.row-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

/* Desktop Layout: Single Row */
@media (min-width: 640px) {
    .row-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 16px;
        padding: 10px 16px;
    }

    .row-main {
        flex: 1;
        gap: 8px;
    }

    .row-actions {
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        grid-column: auto;
    }
}

.row-actions button {
    opacity: 1;
    /* Always visible on mobile for better UX */
}

@media (min-width: 768px) {
    .row-actions button {
        opacity: 0.6;
    }

    .row-item:hover .row-actions button {
        opacity: 1;
    }
}

.row-actions button {
    padding: 8px 12px;
    font-size: 12px;
}

@media (min-width: 768px) {
    .row-actions button {
        padding: 8px 14px;
        font-size: 13px;
    }
}

.badge {
    font-size: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 8px;
    display: inline-flex;
    gap: 5px;
    max-width: 100%;
}

[data-theme="dark"] .badge {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
}

@media (min-width: 768px) {
    .badge {
        font-size: 13px;
        padding: 5px 12px;
    }
}

.badge-label {
    color: var(--ink-muted);
    font-weight: 500;
    flex-shrink: 0;
}

.badge-value {
    color: var(--ink);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .row-actions {
        gap: 8px;
    }
}

.row-actions button {
    padding: 8px 12px;
    font-size: 12px;
}

@media (min-width: 768px) {
    .row-actions button {
        padding: 8px 14px;
        font-size: 13px;
    }
}

.btn-move {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--ink-muted);
    padding: 4px 8px !important;
    font-size: 10px !important;
    border-radius: 6px !important;
}

[data-theme="dark"] .btn-move {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
}

.btn-move:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* ========================================
   Top Up List - OPTIMIZED
   ======================================== */
.progress-container {
    margin-bottom: 10px;
}

.progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success) 0%, #34d399 100%);
    border-radius: 8px;
    transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-secondary);
    text-align: right;
}

/* Optimized Mobile Controls */
.tu-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.tu-controls button {
    width: 100%;
    min-width: 0;
    /* Prevent overflow */
    padding: 10px 8px;
    /* Slightly smaller horizontal padding */
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px;
    /* Consistent height */
}

/* Make "Tambah" button full width on very small screens or span 2 cols */
.tu-add {
    grid-column: span 2;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    font-size: 13px !important;
    font-weight: 700 !important;
}

/* Removed intermediate breakpoint to keep 2-column grid on larger phones */
/* 
@media (min-width: 480px) {
    .tu-controls {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .tu-add {
        grid-column: span 1;
    }
} 
*/

@media (min-width: 768px) {
    .tu-controls {
        display: flex;
        flex-wrap: wrap;
    }

    .tu-controls button {
        flex: 1;
        min-width: auto;
    }
}

.tu-list {
    margin-top: 16px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 400px;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .tu-list {
        max-height: 500px;
    }
}

.tu-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg-solid);
    transition: var(--transition);
}

.tu-no {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .tu-no {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

.tu-item:last-child {
    border-bottom: none;
}

.tu-item:hover {
    background: var(--primary-light);
}

[data-theme="dark"] .tu-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

.tu-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    /* Mobile: Allow multiline */
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

/* Actions Container - Mobile Stacked */
.tu-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

/* Desktop: Revert to single row */
@media (min-width: 640px) {
    .tu-item {
        display: flex;
        flex-direction: row;
        gap: 16px;
        padding: 10px 16px;
    }

    .tu-name {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0;
    }

    .tu-actions {
        width: auto;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        grid-column: auto;
    }
}

/* Helper to push status button to left on mobile */
.tu-actions .btn-status {
    margin-right: auto;
}

@media (min-width: 640px) {
    .tu-actions .btn-status {
        margin-right: 0;
    }
}

.btn-status {
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 18px;
    border: 1px solid var(--border);
    cursor: pointer;
    background: var(--card-bg);
    font-weight: 700;
    transition: var(--transition);
    white-space: nowrap;
    height: 30px;
    display: flex;
    align-items: center;
}

[data-theme="dark"] .btn-status {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

@media (min-width: 768px) {
    .btn-status {
        font-size: 13px;
        padding: 8px 16px;
    }
}

.btn-status:hover {
    transform: scale(1.02);
}

.btn-status.done {
    background: var(--success-light);
    border-color: var(--success);
    color: var(--success);
}



.btn-icon-only {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: var(--transition);
}

@media (min-width: 768px) {
    .btn-icon-only {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

[data-theme="dark"] .btn-icon-only {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-icon-only:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.btn-icon-only.danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.btn-small {
    padding: 6px 10px;
    font-size: 11px;
}

.mono {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

/* Edit in-place */
.tu-edit-wrap {
    display: flex;
    gap: 6px;
    flex: 1;
    grid-column: 2 / -1;
}

.tu-edit-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
}

.btn-save {
    background: var(--success);
    color: white;
    padding: 6px 10px;
}

.btn-cancel-edit {
    background: var(--ink-muted);
    color: white;
    padding: 6px 10px;
}

/* Search in sections */
.search-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 16px;
    background: var(--glass);
    border: 2px solid var(--border);
    border-radius: 12px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.search-wrap:focus-within {
    background: var(--card-bg-solid);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.search-wrap .search-icon {
    position: static;
    transform: none;
    color: var(--ink-muted);
    font-size: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-wrap:focus-within .search-icon {
    color: var(--primary);
}

.search-wrap .search-input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 12px 0;
    font-size: 15px;
    min-width: 0;
    color: var(--ink);
    box-shadow: none !important;
}

.search-wrap .search-input:focus {
    outline: none;
    box-shadow: none;
}

.search-wrap .search-input::placeholder {
    color: var(--ink-muted);
}

/* ========================================
   Footer
   ======================================== */
.app-footer {
    text-align: center;
    padding: 24px 16px;
    color: var(--ink-muted);
    font-size: 12px;
}

/* ========================================
   Install Banner
   ======================================== */
#installBanner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg-solid);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    padding: 16px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 9998;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#installBanner.show {
    transform: translateY(0);
}

.install-content {
    display: flex;
    gap: 12px;
    align-items: start;
}

.install-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.install-info {
    flex: 1;
    min-width: 0;
}

.install-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 2px;
}

.install-desc {
    font-size: 12px;
    color: var(--ink-muted);
    line-height: 1.4;
}

.install-actions {
    display: flex;
    gap: 10px;
}

.btn-banner-install {
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-banner-install:hover {
    transform: translateY(-1px);
}

.btn-banner-close {
    background: var(--glass);
    border: 1px solid var(--border);
    color: var(--ink-muted);
    padding: 12px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-banner-close:hover {
    background: var(--card-bg-solid);
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ========================================
   Scrollbar
   ======================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--ink-muted);
}

/* ========================================
   Mobile Specific Optimizations
   ======================================== */
@media (max-width: 480px) {
    .wrap {
        padding: 12px;
        padding-bottom: 80px;
    }

    .header-inner {
        padding: 10px 12px;
    }

    .brand-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .brand-text h1 {
        font-size: 18px;
    }

    .brand-tagline {
        display: none;
    }

    .btn-settings {
        width: 36px;
        height: 36px;
    }

    .btn-report {
        padding: 8px 10px;
    }

    .title {
        padding: 12px 14px;
    }

    .card-content {
        padding: 12px;
    }

    .row-item {
        padding: 8px 10px;
        gap: 8px;
    }

    .row-no {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .badge {
        font-size: 10px;
        padding: 2px 6px;
    }

    .row-actions button {
        padding: 5px 8px;
        font-size: 10px;
    }

    .tu-item {
        padding: 8px 10px;
        gap: 8px;
    }

    .tu-name {
        font-size: 12px;
    }

    .btn-status {
        font-size: 10px;
        padding: 5px 10px;
    }

    .actions-bottom {
        gap: 6px;
    }

    .actions-bottom button {
        padding: 10px 12px;
        font-size: 12px;
    }

    .tu-controls {
        gap: 6px;
    }

    .tu-controls button {
        padding: 10px 12px;
        font-size: 12px;
        min-width: 70px;
    }

    .tu-no {
        width: 22px;
        height: 22px;
        font-size: 10px;
    }

    .btn-icon-only {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .tu-actions {
        gap: 4px;
    }

    .settings-modal {
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius-lg);
    }

    .settings-body {
        max-height: 65vh;
    }
}

/* Large screens */
@media (min-width: 1200px) {
    .wrap {
        max-width: 1100px;
    }

    .row-item {
        padding: 12px 16px;
    }

    .badge {
        font-size: 12px;
        padding: 3px 10px;
    }

}

/* Custom Modal Styles */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.custom-modal {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-modal-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.custom-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--ink);
}

.custom-modal-message {
    font-size: 14px;
    color: var(--ink-secondary);
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.custom-modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--ink);
    margin-bottom: 20px;
    font-family: inherit;
    font-size: 14px;
}

.custom-modal-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.custom-modal-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.modal-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal-btn.ghost {
    background: var(--bg-solid);
    color: var(--ink);
    border: 1px solid var(--border);
}

.modal-btn.ghost:hover {
    background: var(--border);
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.modal-btn.primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Specific fix for Smart Paste input size */
.tu-input.t-area {
    min-height: 120px;
    height: 120px;
    padding: 16px;
}

/* ========================================
   Dark Mode - Comprehensive Button Fixes
   ======================================== */
[data-theme="dark"] .row-list-container {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .row-item {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .row-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .row-actions button.ghost {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .row-actions button.ghost:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .row-actions button.danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.5);
    color: #f87171;
}

[data-theme="dark"] .row-actions button.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

[data-theme="dark"] .tu-list {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .tu-item {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .tu-item:hover {
    background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .search-wrap {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .search-input {
    background: transparent;
    color: var(--ink);
}

[data-theme="dark"] .tu-controls button.ghost {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .tu-controls button.ghost:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

/* Dark mode for tu-actions buttons (Edit, Delete, Move) */
[data-theme="dark"] .tu-actions .btn-icon-only {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .tu-actions .btn-icon-only:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--primary);
}

[data-theme="dark"] .tu-actions .btn-icon-only.danger {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

[data-theme="dark"] .tu-actions .btn-icon-only.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
}

/* Dark mode for all default buttons */
[data-theme="dark"] button {
    color: var(--ink);
}

[data-theme="dark"] .card {
    background: rgba(30, 30, 50, 0.8);
    border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .header-inner {
    background: rgba(30, 30, 50, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
}
/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
