* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    min-height: 100vh;
    background: #f3f4f6;
    color: #111827;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.container { max-width: 900px; margin: 0 auto; padding: 24px 16px 64px; }
.center   { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.center-text { text-align: center; }
.muted    { color: #6b7280; font-size: 0.9em; }

.hero {
    max-width: 640px;
    margin: 18vh auto;
    text-align: center;
    padding: 0 16px;
}

.hero h1 { font-size: 2.4rem; margin-bottom: 8px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; margin: 28px 0 12px; }

/* ---------- Cards ---------- */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

.card h1 { margin-top: 0; font-size: 1.5rem; }
.card h2 { margin-top: 0; font-size: 1.2rem; }

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #111827;
    color: #fff;
    padding: 12px 24px;
}
.navbar-brand { font-weight: 700; }
.navbar-user  { margin-left: auto; color: #d1d5db; font-size: 0.9em; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
}
.btn:hover { text-decoration: none; opacity: 0.92; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-outline { background: transparent; border-color: #d1d5db; color: #374151; }
.btn-block   { display: block; width: 100%; text-align: center; }
.btn-sm      { padding: 6px 12px; font-size: 0.85rem; }

/* ---------- Forms ---------- */
.form label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.form input[type="text"],
.form input[type="password"],
.form input[type="number"],
.form select {
    width: 100%;
    padding: 10px 12px;
    margin-top: 6px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}

.form input:focus, .form select:focus {
    outline: 2px solid #93c5fd;
    border-color: #3b82f6;
}

.form-inline { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form-inline label { flex: 1 1 180px; margin-bottom: 0; }

.input-group { display: flex; align-items: center; margin-top: 6px; }
.input-group input { margin-top: 0; border-radius: 8px 0 0 8px; }
.input-append {
    padding: 10px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-left: 0;
    border-radius: 0 8px 8px 0;
    color: #6b7280;
    white-space: nowrap;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.otp-display { font-size: 1.4rem; letter-spacing: 6px; font-weight: 800; }

/* ---------- Table ---------- */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.92rem;
}
.table th { background: #f9fafb; font-weight: 600; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }

/* ---------- Create-email form (grid) ---------- */
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.card-head h2 { margin: 0; }

.card-sub {
    margin: 4px 0 0;
    font-size: 0.85rem;
    color: #6b7280;
}

.badge-domain {
    background: #eef2ff;
    color: #4338ca;
    font-size: 0.85rem;
    text-transform: none;
    font-weight: 600;
    flex-shrink: 0;
}

.create-card {
    border-top: 3px solid #2563eb;
}

.email-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 18px;
}
.email-preview-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.email-preview-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #111827;
    word-break: break-all;
}
.email-preview-domain { color: #2563eb; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

.form-grid-narrow {
    max-width: 480px;
}

/* Create-email row: username full row, button bottom-right */
.create-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.create-row .field-grow { flex: 1 1 260px; min-width: 0; }
.create-row .field-submit { flex: 0 0 220px; }

.create-row .field-submit select {
    height: 44px;
    width: 100%;
    padding: 0 12px;
    font-size: 0.95rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
}
.create-row .field-submit select:focus {
    outline: 2px solid #93c5fd;
    border-color: #3b82f6;
}

.create-row-btn {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}
.create-row-btn .btn {
    height: 44px;
    min-width: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.field { display: block; margin: 0; }

.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}

.field-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 400;
    color: #6b7280;
}
.field-hint code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.78rem;
    color: #111827;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
}

/* Uniform control height */
.form .form-grid input[type="text"],
.form .form-grid select {
    height: 44px;
    padding: 0 12px;
}
.form .form-grid select { padding: 0 34px 0 12px; }

.input-group {
    display: flex;
    align-items: stretch;
    height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.input-group > * { border: 0; }
.form .input-group input[type="text"] {
    flex: 1;
    min-width: 0;
    width: auto;
    height: auto !important;
    margin-top: 0;
    padding: 0 12px !important;
    border: 0;
    border-radius: 0 !important;
    outline: none;
    background: #fff;
}

.input-prepend {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    flex-shrink: 0;
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 700;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-left: 0;
    color: #374151;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0;
    white-space: nowrap;
    line-height: 1;
}
.btn-icon:last-child { border-radius: 0 8px 8px 0; }
.btn-icon:hover { background: #e5e7eb; }

.field-submit .btn { height: 44px; width: 100%; display: flex; align-items: center; justify-content: center; }

/* ---------- Inbox viewer ---------- */
.th-actions { text-align: right; }
.inbox-container { max-width: 900px; }
.inbox-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.inbox-head h1 { margin: 0; font-size: 1.4rem; word-break: break-all; }

.inbox-list .table td { vertical-align: middle; }
.inbox-list .table td:nth-child(2) a {
    font-weight: 600;
    color: #1f2937;
    text-decoration: none;
}
.inbox-list .table td:nth-child(2) a:hover { color: #2563eb; text-decoration: underline; }
.row-unread td { background: #eff6ff; }
.row-unread td:nth-child(2) a { color: #2563eb; font-weight: 700; }

.msg-meta h2 { margin: 0 0 10px; word-break: break-word; }
.msg-meta p { margin: 4px 0; color: #374151; font-size: 0.9rem; }

.msg-body {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    max-height: 480px;
    overflow-y: auto;
}

/* Responsive: stack on small screens */
@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-actions { grid-column: 1 / 2; }
}

/* ---------- Auto-detected domains ---------- */
.domain-chips {
    list-style: none;
    margin: 16px 0 8px;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.domain-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
}

.domain-name {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: #111827;
}

.domain-meta {
    color: #6b7280;
    font-size: 0.78rem;
}

.detect-status {
    margin: 8px 0 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.detect-status code {
    background: #f3f4f6;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.78rem;
}

/* Default (last used) domain marker */
.domain-chip-active {
    background: #eef2ff;
    border-color: #c7d2fe;
}

/* Flash with copy-to-clipboard */
.flash-copy {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.copy-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.copy-value {
    background: #fff;
    border: 1px solid #a7f3d0;
    border-radius: 6px;
    padding: 4px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9rem;
    color: #065f46;
}

.copy-btn { background: #fff; }

.copy-btn.is-copied {
    background: #065f46;
    border-color: #065f46;
    color: #fff;
}

/* Action cells + inbox header actions */
.td-actions { text-align: right; white-space: nowrap; }
.td-actions > * { vertical-align: middle; }
.td-actions > * + * { margin-left: 6px; }

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