:root {
    /* Light theme variables by default */
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --input-bg: #ffffff;
    --blue-primary: #3b5bdb;
    --blue-header: #4a6cf7;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --mono: 'JetBrains Mono', monospace;
    --sans: 'Plus Jakarta Sans', sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --radius: 12px;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --input-bg: #0f172a;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    padding: 56px 0 3rem 0;
    transition: background-color 0.3s, color 0.3s;
}

.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #a3fa5c 0%, #4a6cf7 40%, #364fc7 100%);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    box-shadow: 0 4px 12px rgba(59,91,219,0.25);
}

.top-nav .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.top-nav .brand img {
    height: 34px;
    width: auto;
    object-fit: contain;
    display: block;
}

.top-nav-menu {
    display: flex;
    align-items: center;
    gap: 24px;
    margin: 0 auto 0 40px;
}

.menu-item {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-item:hover {
    color: #ffffff;
    transform: translateY(-1px);
}

@media (max-width: 991px) {
    .top-nav-menu {
        display: none;
    }
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.25s ease;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.user-info-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 4px 12px;
    border-radius: 50px;
    color: white;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

.user-name {
    font-weight: 700;
    font-size: 13px;
}

.user-balance {
    font-size: 11px;
    font-weight: 600;
    color: #a3fa5c;
}

.logout-btn {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 50px;
    background: rgba(250, 82, 82, 0.2);
    border: 1px solid rgba(250, 82, 82, 0.3);
    transition: all 0.2s ease;
}

.logout-btn:hover {
    color: white;
    background: rgba(250, 82, 82, 0.75);
    border-color: rgba(250, 82, 82, 0.85);
}

.wrap {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px 16px;
}

.header {
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

h1 span {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-header));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 24px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s, border-color 0.3s;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--blue-header), var(--blue-primary), transparent);
}

label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

.line-count-badge {
    font-size: 11px;
    color: var(--blue-primary);
    font-weight: 600;
    background: rgba(74, 108, 247, 0.08);
    border: 1px solid rgba(74, 108, 247, 0.15);
    padding: 4px 12px;
    border-radius: 50px;
}

/* Textarea structure matching tool-get-Oauth2-token */
.editor-wrap {
    display: flex;
    border: 1.5px solid rgba(74, 108, 247, 0.3); /* Prominent primary-tinted border */
    border-radius: 10px;
    overflow: hidden;
    background: var(--input-bg);
    height: 280px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(74, 108, 247, 0.04);
}
.editor-wrap:hover {
    border-color: rgba(74, 108, 247, 0.6);
    box-shadow: 0 4px 16px rgba(74, 108, 247, 0.1);
}
.editor-wrap:focus-within {
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 4px rgba(74, 108, 247, 0.25), 0 8px 24px rgba(74, 108, 247, 0.15);
    transform: translateY(-1px);
}

.line-nums {
    white-space: pre; /* Keep newlines intact so numbers align vertically */
    padding: 14px 0;
    min-width: 44px;
    text-align: right;
    padding-right: 12px;
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
    user-select: none;
    pointer-events: none;
    overflow: hidden;
    font-family: var(--mono);
    border-right: 1px solid var(--border);
}

#mailInput {
    flex: 1;
    background: var(--input-bg);
    color: var(--text);
    border: none;
    outline: none;
    padding: 14px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.7;
    resize: none;
    overflow-y: auto;
}
#mailInput::placeholder {
    color: var(--muted);
    opacity: 0.6;
}

.btn-primary-custom {
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-header));
    border: none;
    color: white;
    font-weight: 700;
    padding: 12px 24px;
    border-radius: 8px;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.btn-primary-custom:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(74, 108, 247, 0.35);
}

.btn-primary-custom:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-clear {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-clear:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
    box-shadow: none;
    margin-bottom: 0;
}
.stat-card::before {
    display: none;
}

.stat-val {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-lbl {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--muted);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.result-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 20px;
    font-size: 13px;
    display: none;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 20px;
}
.result-box.show {
    display: flex;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
}
.result-item .rv {
    font-size: 1.5rem;
    font-weight: 700;
}
.result-item.ri-ok .rv { color: var(--success); }
.result-item.ri-dup .rv { color: var(--warning); }
.result-item.ri-tot .rv { color: var(--blue-primary); }
.result-item .rl {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--muted);
}

/* Login styling matching tool-get-Oauth2-token */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    position: relative;
}

.login-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--blue-header), var(--blue-primary));
}

.login-head {
    padding: 32px 32px 16px 32px;
    text-align: center;
}

.login-head .brand {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--blue-primary);
    margin-bottom: 8px;
}

.login-head h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
}

.login-body {
    padding: 0 32px 32px 32px;
}

.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 700;
}

.field input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border);
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: all 0.2s;
    border-radius: 8px;
}
.field input:focus {
    border-color: var(--blue-primary);
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.15);
}

.remember-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 24px;
    cursor: pointer;
    user-select: none;
}
.remember-row input[type=checkbox] {
    accent-color: var(--blue-primary);
    width: 16px;
    height: 16px;
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 12px 16px;
    font-size: 12px;
    border-radius: 8px;
    margin-bottom: 18px;
    display: none;
    font-weight: 600;
}

.toast-msg {
    position: fixed;
    bottom: 24px;
    left: 24px;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast-msg.show {
    opacity: 1;
    transform: translateY(0);
}

.footer-banner {
    margin-top: 2rem;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.footer-banner a {
    color: var(--blue-primary);
    text-decoration: none;
    font-weight: 700;
}

.spinner-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
}
.spinner-overlay.show {
    display: flex;
}
.spin-big {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--blue-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
/* Styles for Request History Tab and Table */
.tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 20px;
}
.tab-btn {
    background: none;
    border: none;
    color: var(--muted);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tab-btn:hover {
    color: var(--text);
    background: rgba(74, 108, 247, 0.05);
}
.tab-btn.active {
    color: white !important;
    background: linear-gradient(135deg, var(--blue-primary), var(--blue-header));
    box-shadow: 0 4px 10px rgba(74, 108, 247, 0.2);
}

.history-table-container {
    width: 100%;
    overflow-x: auto;
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.history-table th, .history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.history-table th {
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.8px;
    background: rgba(74, 108, 247, 0.03);
}
.history-table tr:hover td {
    background: rgba(74, 108, 247, 0.02);
}
.history-table td {
    font-weight: 600;
    color: var(--text);
}
.history-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: var(--mono);
    display: inline-block;
}
.history-badge.total { background: rgba(74, 108, 247, 0.1); color: var(--blue-primary); }
.history-badge.success { background: rgba(43, 138, 62, 0.1); color: var(--success); }
.history-badge.blocked { background: rgba(224, 49, 49, 0.1); color: var(--danger); }
.history-badge.duplicate { background: rgba(247, 103, 7, 0.1); color: var(--warning); }
.history-badge.pending { background: rgba(21, 170, 191, 0.1); color: var(--info); }

.empty-history {
    padding: 40px;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
}

/* Styles for Load More & Delete Actions */
.btn-load-more-container {
    text-align: center;
    margin-top: 15px;
}
.btn-load-more {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-load-more:hover {
    border-color: var(--blue-primary);
    color: var(--blue-primary);
    box-shadow: 0 4px 12px rgba(74, 108, 247, 0.1);
}

.btn-delete-history {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-delete-history:hover {
    background: rgba(224, 49, 49, 0.08);
    color: #ff6b6b;
    transform: scale(1.08);
}

/* Custom premium modal popup */
.custom-modal {
    position: fixed;
    inset: 0;
    z-index: 6000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    padding: 20px;
}
.custom-modal.show {
    display: flex;
}
.modal-dialog-custom {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 550px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header-custom {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(239, 68, 68, 0.03);
}
.modal-header-custom h5 {
    font-size: 16px;
    font-weight: 800;
    color: var(--danger);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-close-custom {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}
.modal-close-custom:hover {
    color: var(--text);
    transform: scale(1.1);
}
.modal-body-custom {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}
.invalid-list-container {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--danger);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin-bottom: 16px;
    line-height: 1.6;
}
.modal-footer-custom {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.btn-download-txt {
    background: var(--blue-primary);
    color: white;
    border: none;
    font-weight: 700;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-download-txt:hover {
    background: var(--blue-header);
    box-shadow: 0 4px 10px rgba(74, 108, 247, 0.2);
    color: white;
}
.btn-close-modal {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    font-weight: 700;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-close-modal:hover {
    border-color: var(--muted);
}
.invalid-explanation-panel {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text);
}
.invalid-explanation-panel p {
    margin: 0 0 8px 0;
    font-weight: 700;
    color: var(--warning);
}
.invalid-explanation-panel ul {
    margin: 0;
    padding-left: 18px;
}
.invalid-explanation-panel li {
    margin-bottom: 4px;
}
