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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #0a1628 0%, #1a2744 50%, #0d1f3c 100%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 750px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e8ecf1;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo .icon {
    font-size: 32px;
}

.logo h1 {
    font-size: 24px;
    color: #1a2744;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.subtitle {
    color: #6b7a8f;
    font-size: 14px;
    font-weight: 500;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #e8ecf1;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: #8a9ba8;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
    box-shadow: none;
}

.tab-btn:hover {
    color: #1a2744;
    background: none;
    transform: none;
    box-shadow: none;
}

.tab-btn.active {
    color: #1a2744;
    border-bottom-color: #1a2744;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

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

label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.required {
    color: #e74c3c;
}

.help-text {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #8a9ba8;
}

input, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #dce1e8;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #f8f9fb;
    color: #2c3e50;
    font-family: inherit;
}

input:focus, textarea:focus {
    outline: none;
    border-color: #1a2744;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 39, 68, 0.1);
}

input:disabled {
    background: #e8ecf1;
    color: #6b7a8f;
    cursor: not-allowed;
    opacity: 0.8;
}

textarea {
    resize: vertical;
    min-height: 150px;
    line-height: 1.6;
}

button {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #1a2744 0%, #2c3e6b 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(26, 39, 68, 0.3);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

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

/* Result */
.result {
    margin-top: 20px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.result .detail {
    margin-top: 8px;
    font-size: 12px;
    opacity: 0.8;
    word-break: break-all;
}

/* Small buttons */
.btn-small {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #2c5f8a, #3a7fc0);
}

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(44, 95, 138, 0.3);
}

.btn-back {
    background: #6b7a8f;
}

.btn-back:hover {
    box-shadow: 0 4px 15px rgba(107, 122, 143, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
}

.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

/* History */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.history-header h2 {
    font-size: 18px;
    color: #1a2744;
}

.empty-state {
    text-align: center;
    color: #8a9ba8;
    padding: 40px 20px;
    font-size: 14px;
}

.email-card {
    background: #f8f9fb;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.email-card:hover {
    border-color: #c0a060;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.email-card .email-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.email-card .email-to {
    font-weight: 600;
    color: #1a2744;
    font-size: 14px;
}

.email-card .email-subject {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 6px;
}

.email-card .email-time {
    font-size: 12px;
    color: #8a9ba8;
    white-space: nowrap;
    margin-left: 10px;
}

.email-card .email-preview {
    font-size: 13px;
    color: #6b7a8f;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.email-card .email-id {
    font-size: 11px;
    color: #a0b0c0;
    margin-top: 8px;
    font-family: monospace;
}

/* Section box */
.section-box {
    margin-bottom: 20px;
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #dce1e8, transparent);
    margin: 24px 0;
}

.header-actions {
    display: flex;
    align-items: center;
}

/* Inbox / Mailboxes */
.inbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.inbox-header h2 {
    font-size: 18px;
    color: #1a2744;
}

/* CF Create Form */
.cf-create-form {
    background: #f8f9fb;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.cf-create-form label {
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 4px;
}

.input-suffix {
    display: flex;
    align-items: center;
    border: 2px solid #dce1e8;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fb;
    transition: all 0.2s ease;
}

.input-suffix:focus-within {
    border-color: #1a2744;
    box-shadow: 0 0 0 3px rgba(26, 39, 68, 0.1);
    background: #fff;
}

.input-suffix input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 10px 14px;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.input-suffix .suffix {
    padding: 10px 14px;
    background: #e8ecf1;
    color: #6b7a8f;
    font-size: 13px;
    font-family: monospace;
    font-weight: 600;
}

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

.form-actions .btn-small {
    flex: 0;
}

/* CF Rules list */
.cf-rule-card {
    background: #f8f9fb;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.cf-rule-card:hover {
    border-color: #c0a060;
}

.cf-rule-card.disabled {
    opacity: 0.5;
}

.cf-rule-card .cf-email {
    font-weight: 600;
    color: #1a2744;
    font-family: monospace;
    font-size: 14px;
}

.cf-rule-card .cf-forward {
    font-size: 12px;
    color: #6b7a8f;
    margin-top: 3px;
}

.cf-rule-card .cf-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.mailbox-card {
    background: #f8f9fb;
    border: 2px solid #e8ecf1;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.mailbox-card:hover {
    border-color: #2c5f8a;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.mailbox-card .mailbox-email {
    font-weight: 600;
    color: #1a2744;
    font-size: 14px;
    font-family: monospace;
}

.mailbox-card .mailbox-date {
    font-size: 12px;
    color: #8a9ba8;
    margin-top: 4px;
}

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

.mailbox-card .mailbox-unread {
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.btn-icon {
    background: none;
    border: none;
    color: #8a9ba8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    width: auto;
}

.btn-icon:hover {
    background: #f0f2f5;
    color: #e74c3c;
    box-shadow: none;
    transform: none;
}

/* Inbox Viewer */
.inbox-viewer {
    margin-top: 20px;
}

.inbox-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e8ecf1;
}

.inbox-viewer-header h3 {
    font-size: 14px;
    color: #1a2744;
    font-family: monospace;
    flex: 1;
    text-align: center;
}

.inbox-message-card {
    background: #f8f9fb;
    border: 1px solid #e8ecf1;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.inbox-message-card:hover {
    border-color: #c0a060;
}

.inbox-message-card.unseen {
    border-left: 3px solid #2c5f8a;
    background: #f0f4f8;
}

.inbox-message-card .msg-from {
    font-weight: 600;
    color: #1a2744;
    font-size: 13px;
    margin-bottom: 4px;
}

.inbox-message-card .msg-subject {
    font-weight: 500;
    color: #2c3e50;
    font-size: 13px;
    margin-bottom: 4px;
}

.inbox-message-card .msg-intro {
    font-size: 12px;
    color: #6b7a8f;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.inbox-message-card .msg-time {
    font-size: 11px;
    color: #a0b0c0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 650px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 20px 24px;
    border-bottom: 1px solid #e8ecf1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    font-size: 16px;
    color: #1a2744;
    flex: 1;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #8a9ba8;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f0f2f5;
    color: #2c3e50;
    box-shadow: none;
    transform: none;
}

.modal-body {
    padding: 24px;
}

.modal-meta {
    margin-bottom: 16px;
}

.modal-field {
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 6px;
}

.modal-field strong {
    color: #1a2744;
}

.modal-divider {
    height: 1px;
    background: #e8ecf1;
    margin: 16px 0;
}

.modal-message-body {
    font-size: 14px;
    color: #2c3e50;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Loading spinner for generate */
/* CF destinations select */
.cf-destinations-select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #dce1e8;
    border-radius: 10px;
    font-size: 14px;
    background: #f8f9fb;
    color: #2c3e50;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: auto;
}

.cf-destinations-select:focus {
    outline: none;
    border-color: #1a2744;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26, 39, 68, 0.1);
}

/* Loading spinner for generate */
.generate-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 6px;
    vertical-align: middle;
}
