* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #0a1628;
    color: #e0e6ed;
    min-height: 100vh;
}

/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #0d1f3c, #142a4f);
    border-bottom: 1px solid rgba(0, 255, 170, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.top-bar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.nav-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.nav-link-btn {
    display: inline-block;
    font-size: 0.95rem;
    color: #00ffaa;
    text-decoration: none;
    padding: 8px 28px;
    border-radius: 24px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 2px solid #00ffaa;
    transition: all 0.2s;
}

.nav-link-btn:hover {
    background: #00ffaa;
    color: #0a1628;
    box-shadow: 0 0 20px rgba(0, 255, 170, 0.3);
}

.logo {
    color: #00ffaa;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.2s;
}

.logo:hover {
    color: #33ffbb;
}

.top-title {
    font-size: 2.8em;
    font-weight: 900;
    letter-spacing: 3px;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.top-badge {
    background: linear-gradient(135deg, #00c853, #00e676);
    color: #0a1628;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ===== APP CONTAINER ===== */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ===== INPUT SECTION ===== */
.input-section {
    margin-bottom: 24px;
    background: #0d1f3c;
    border: 1px solid #1e4a6f;
    border-radius: 10px;
    padding: 18px 20px;
}

.input-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #8899aa;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.token-textarea {
    width: 100%;
    background: #0d1f3c;
    border: 1px solid #1e3a5f;
    border-radius: 8px;
    padding: 14px 16px;
    color: #c8f7dc;
    font-family: 'Consolas', 'Fira Code', 'Courier New', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 160px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.token-textarea:focus {
    outline: none;
    border-color: #00ffaa;
    box-shadow: 0 0 0 3px rgba(0, 255, 170, 0.12);
}

.token-textarea::placeholder {
    color: #3a5068;
}

.input-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-group label {
    font-size: 0.82rem;
    color: #6b8299;
    white-space: nowrap;
}

.small-input {
    background: #0d1f3c;
    border: 1px solid #1e3a5f;
    border-radius: 6px;
    padding: 7px 10px;
    color: #e0e6ed;
    font-size: 0.85rem;
    width: 65px;
    transition: border-color 0.2s;
}

.small-input.wide {
    width: 160px;
}

.small-input:focus {
    outline: none;
    border-color: #00ffaa;
}

.btn-action {
    margin-left: auto;
    background: linear-gradient(135deg, #00c853, #00e676);
    color: #0a1628;
    border: none;
    padding: 9px 28px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: transform 0.15s, box-shadow 0.2s;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 200, 83, 0.35);
}

.btn-action:active {
    transform: translateY(0);
}

/* ===== RESULTS ===== */
.results-container {
    min-height: 200px;
}

.empty-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #4a6178;
    font-size: 0.95rem;
}

/* === Email Group (per account) === */
.email-group {
    margin-bottom: 28px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.email-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, #122240, #162b4d);
    border: 1px solid #1e3a5f;
    border-radius: 8px 8px 0 0;
    border-bottom: 2px solid #00ffaa22;
}

.email-group-account-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.email-group-account {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
}

.email-group-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
}

.btn-copy-email {
    border-color: #00d4ff44;
    background: #00d4ff11;
    color: #00d4ff;
}

.btn-copy-email:hover {
    background: #00d4ff22;
    border-color: #00d4ff88;
}

.btn-copy-all-codes {
    border-color: #00ffaa44;
    background: #00ffaa11;
    color: #00ffaa;
}

.btn-copy-all-codes:hover {
    background: #00ffaa22;
    border-color: #00ffaa88;
}

/* === Placeholder === */
.email-group-placeholder {
    margin-bottom: 15px;
}

.placeholder-loading {
    padding: 15px 20px;
    background: rgba(0, 212, 255, 0.05);
    border: 1px dashed #1e4a6f;
    border-radius: 8px;
    color: #6b8299;
    font-size: 0.85rem;
}

.row-hidden {
    display: none !important;
}

/* === Table === */
.mail-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #0d1b30;
    border: 1px solid #1e4a6f;
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    table-layout: fixed;
}

.mail-table thead th {
    background: #0c1a2e;
    color: #e8ecf0;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 12px;
    text-align: center;
    border-bottom: 2px solid #1e4a6f;
    border-right: 1px solid #152a45;
}

.mail-table thead th:last-child {
    text-align: center;
    border-right: none;
}

.mail-table thead th:nth-child(1) {
    width: 22%;
}

.mail-table thead th:nth-child(2) {
    width: 5%;
}

.mail-table thead th:nth-child(3) {
    width: 13%;
}

.mail-table thead th:nth-child(4) {
    width: 12%;
}

.mail-table thead th:nth-child(5) {
    width: 48%;
}

.mail-table tbody tr {
    border-bottom: 1px solid #1a3352;
    transition: background 0.15s;
}

.mail-table tbody tr:nth-child(even) {
    background: #0f2238;
}

.mail-table tbody tr:hover {
    background: #142d50;
}

.mail-table tbody tr:last-child {
    border-bottom: none;
}

.mail-table td {
    padding: 10px 12px;
    font-size: 0.72rem;
    vertical-align: middle;
    text-align: center;
    line-height: 1.5;
    border-right: 1px solid #152a45;
    border-bottom: 1px solid #1a3352;
    color: #e8ecf0;
}

.mail-table td:last-child {
    border-right: none;
}

.td-mail {
    color: #e8ecf0;
    font-size: 0.82rem;
    width: 22%;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

.td-stt {
    text-align: center;
    color: #6b8299;
    font-weight: 600;
    width: 5%;
}

.td-from {
    color: #e0e4e8;
    width: 13%;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
}

.td-time {
    color: #c0c8d0;
    white-space: nowrap;
    font-size: 0.8rem;
    width: 12%;
}

.mail-table .td-content {
    color: #e8ecf0;
    width: 48%;
    text-align: left;
    font-size: 0.82rem;
}

.td-content .highlight-code {
    color: #00ffaa;
    font-weight: 700;
}

.td-content .xem-them {
    color: #00d4ff;
    font-size: 0.72rem;
    cursor: pointer;
    float: right;
    margin-left: 8px;
    white-space: nowrap;
}

.badge-count {
    background: #3498db;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.expand-btn-row {
    text-align: center;
    padding: 6px 0;
    background: rgba(0, 255, 170, 0.05);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-expand {
    background: none;
    border: 1px solid #00ffaa;
    color: #00ffaa;
    padding: 4px 20px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-expand:hover {
    background: #00ffaa;
    color: #0a1628;
}

.inner-table {
    border: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.expand-wrapper {
    transition: max-height 0.35s ease;
}

.td-content .xem-them:hover {
    text-decoration: underline;
}

.td-code {
    text-align: center;
    width: 110px;
}

.code-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 800;
    color: #00ffaa;
    letter-spacing: 2px;
    margin-bottom: 5px;
    font-family: 'Consolas', monospace;
}

.btn-copy-code {
    padding: 3px 14px;
    border-radius: 4px;
    border: none;
    background: linear-gradient(135deg, #e74c3c, #ff6b6b);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
    letter-spacing: 0.3px;
}

.btn-copy-code:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.4);
}

.btn-copy-code.copied {
    background: linear-gradient(135deg, #00c853, #00e676);
}

.no-code {
    color: #4a5568;
    font-size: 0.8rem;
}

/* === No mail row === */
.no-mail-row td {
    text-align: center;
    color: #4a6178;
    padding: 30px;
}

/* ===== INLINE LOADING ===== */
.loading-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 255, 170, 0.2);
    border-top: 3px solid #00ffaa;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-inline span {
    color: #00ffaa;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 3000;
    transition: bottom 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid transparent;
}

.toast.show {
    bottom: 24px;
}

.toast.success {
    background: rgba(0, 200, 83, 0.15);
    color: #00e676;
    border-color: #00e67644;
}

.toast.error {
    background: rgba(231, 76, 60, 0.15);
    color: #ff6b6b;
    border-color: #ff6b6b44;
}

.toast.info {
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
    border-color: #00d4ff44;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    background: linear-gradient(135deg, #eef2f7, #e8edf3, #eef2f7);
    color: #2c3e50;
}

[data-theme="light"] .top-bar {
    background: linear-gradient(135deg, #2c3e50, #34495e);
}

[data-theme="light"] .app-container {
    background: #fff;
    border-color: #ddd;
}

[data-theme="light"] .input-label {
    color: #2c3e50;
}

[data-theme="light"] .token-textarea {
    background: #f9fafb;
    color: #2c3e50;
    border-color: #ccc;
}

[data-theme="light"] .btn-action {
    background: #27ae60;
    color: #fff;
}

[data-theme="light"] .email-group {
    border-color: #ddd;
}

[data-theme="light"] .email-group-header {
    background: #34495e;
}

[data-theme="light"] .mail-table thead {
    background: #34495e;
}

[data-theme="light"] .mail-table th {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="light"] .mail-table td {
    color: #2c3e50;
    border-color: #e0e0e0;
}

[data-theme="light"] .mail-table tbody tr:hover {
    background: #f0f4f8;
}

[data-theme="light"] .td-content .highlight-code {
    color: #e74c3c;
}

[data-theme="light"] .td-content .xem-them {
    color: #2980b9;
}

[data-theme="light"] .btn-expand {
    border-color: #2980b9;
    color: #2980b9;
}

[data-theme="light"] .btn-expand:hover {
    background: #2980b9;
    color: #fff;
}

[data-theme="light"] .expand-btn-row {
    background: rgba(41, 128, 185, 0.05);
    border-top-color: #eee;
}

[data-theme="light"] .btn-small {
    background: rgba(41, 128, 185, 0.1);
    color: #2980b9;
    border-color: #2980b9;
}

[data-theme="light"] .btn-small:hover {
    background: #2980b9;
    color: #fff;
}

[data-theme="light"] .loading-inline span {
    color: #2980b9;
}

[data-theme="light"] .toast.success {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    border-color: #27ae6044;
}

[data-theme="light"] .toast.error {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
    border-color: #e74c3c44;
}

[data-theme="light"] .toast.info {
    background: rgba(41, 128, 185, 0.1);
    color: #2980b9;
    border-color: #2980b944;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .top-bar {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .top-title {
        font-size: 1rem;
        order: -1;
        width: 100%;
        text-align: center;
    }

    .input-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-action {
        margin-left: 0;
    }

    .mail-table {
        font-size: 0.78rem;
    }

    .td-content {
        min-width: 140px;
    }
}

/* ===== EMAIL DETAIL MODAL ===== */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 5000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 10, 20, 0.88);
    backdrop-filter: blur(6px);
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: #f5f5f5;
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #0d1f3c;
    border-bottom: 2px solid #00ffaa33;
}

.modal-header h3 {
    color: #00ffaa;
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #ff6b6b44;
    background: #ff6b6b11;
    color: #ff6b6b;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #ff6b6b33;
    border-color: #ff6b6b;
}

.modal-body {
    flex: 1;
    overflow: auto;
    background: #fff;
}

.modal-body iframe {
    width: 100%;
    min-height: 500px;
    border: none;
    background: #fff;
}

/* ===== THEME TOGGLE SWITCH ===== */
.theme-toggle-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0;
}

.theme-label {
    font-size: 1.3rem;
    user-select: none;
    display: inline-block;
    width: 28px;
    text-align: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #00c853;
    border-radius: 28px;
    transition: background 0.3s;
}

.switch .slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked+.slider {
    background: #1e3a5f;
}

.switch input:checked+.slider::before {
    transform: translateX(28px);
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    background: #f0f2f5;
    color: #1a1a2e;
}

[data-theme="light"] .top-bar {
    background: linear-gradient(135deg, #ffffff, #f0f4f8);
    border-bottom: 1px solid #d0d8e0;
}

[data-theme="light"] .logo {
    color: #0a8f5a;
}

[data-theme="light"] .logo:hover {
    color: #06c270;
}

[data-theme="light"] .top-title {
    background: linear-gradient(90deg, #0a8f5a, #0077b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="light"] .top-badge {
    background: linear-gradient(135deg, #0a8f5a, #06c270);
    color: #fff;
}

[data-theme="light"] .input-section {
    background: #ffffff;
    border-color: #b0bac4;
}

[data-theme="light"] .input-label {
    color: #222;
    font-weight: 700;
}

[data-theme="light"] .token-textarea {
    background: #f5f6f8;
    border-color: #a0aab4;
    color: #111;
}

[data-theme="light"] .token-textarea:focus {
    border-color: #0a8f5a;
    box-shadow: 0 0 0 3px rgba(10, 143, 90, 0.15);
}

[data-theme="light"] .token-textarea::placeholder {
    color: #777;
}

[data-theme="light"] .btn-action {
    background: linear-gradient(135deg, #0a8f5a, #06c270);
    color: #fff;
}

[data-theme="light"] .btn-action:hover {
    box-shadow: 0 6px 20px rgba(10, 143, 90, 0.3);
}

[data-theme="light"] .empty-placeholder {
    color: #8899aa;
}

[data-theme="light"] .email-group-header {
    background: linear-gradient(135deg, #eef2f6, #e2e8ee);
    border-color: #a0aab4;
    border-bottom-color: #06c27055;
}

[data-theme="light"] .email-group-account {
    color: #111;
}

[data-theme="light"] .btn-copy-email {
    border-color: #0077b644;
    background: #0077b611;
    color: #0077b6;
}

[data-theme="light"] .btn-copy-email:hover {
    background: #0077b622;
    border-color: #0077b688;
}

[data-theme="light"] .btn-copy-all-codes {
    border-color: #0a8f5a44;
    background: #0a8f5a11;
    color: #0a8f5a;
}

[data-theme="light"] .btn-copy-all-codes:hover {
    background: #0a8f5a22;
    border-color: #0a8f5a88;
}

[data-theme="light"] .mail-table {
    background: #ffffff;
    border-color: #d0d8e0;
}

[data-theme="light"] .mail-table thead th {
    background: #e2e8ee;
    color: #111;
    font-weight: 800;
    border-bottom-color: #a0aab4;
    border-right-color: #ccd5de;
}

[data-theme="light"] .mail-table tbody tr {
    border-bottom-color: #d5dce4;
}

[data-theme="light"] .mail-table tbody tr:nth-child(even) {
    background: #f5f7f9;
}

[data-theme="light"] .mail-table tbody tr:hover {
    background: #e4ecf4;
}

[data-theme="light"] .mail-table td {
    color: #111;
    border-right-color: #d5dce4;
    border-bottom-color: #d5dce4;
}

[data-theme="light"] .td-stt {
    color: #444;
}

[data-theme="light"] .td-mail {
    color: #111;
}

[data-theme="light"] .td-from {
    color: #111;
}

[data-theme="light"] .td-time {
    color: #333;
}

[data-theme="light"] .mail-table .td-content {
    color: #111;
}

[data-theme="light"] .td-content .highlight-code {
    color: #0a7a4e;
    font-weight: 800;
}

[data-theme="light"] .td-content .xem-them {
    color: #005a8f;
    font-weight: 600;
}

[data-theme="light"] .no-mail-row td {
    color: #aab4be;
}

[data-theme="light"] .loading-inline span {
    color: #0a8f5a;
}

[data-theme="light"] .spinner-small {
    border-color: rgba(10, 143, 90, 0.2);
    border-top-color: #0a8f5a;
}

[data-theme="light"] .toast.success {
    background: rgba(10, 143, 90, 0.12);
    color: #0a8f5a;
    border-color: #0a8f5a44;
}

[data-theme="light"] .toast.error {
    background: rgba(220, 50, 50, 0.1);
    color: #d32f2f;
    border-color: #d32f2f44;
}

[data-theme="light"] .toast.info {
    background: rgba(0, 119, 182, 0.1);
    color: #0077b6;
    border-color: #0077b644;
}

[data-theme="light"] .modal-overlay {
    background: rgba(0, 0, 0, 0.45);
}

[data-theme="light"] .modal-header {
    background: #f4f6f8;
    border-bottom-color: #d0d8e0;
}

[data-theme="light"] .modal-header h3 {
    color: #0a8f5a;
}

[data-theme="light"] .switch .slider {
    background: #b0bac4;
}

[data-theme="light"] .switch input:checked+.slider {
    background: #0a8f5a;
}