:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #6c7587;
    --line: #e5e9f0;
    --surface: #ffffff;
    --background: #f4f6fa;
    --primary: #1668e3;
    --primary-dark: #0f4faa;
    --success: #087a55;
    --danger: #c6363d;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--background); color: var(--ink); }
body { min-width: 320px; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 76px; padding: 0 clamp(20px, 5vw, 72px); background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo-frame { width: 64px; height: 56px; display: grid; place-items: center; padding: 4px 5px; overflow: hidden; border-radius: 12px; background: linear-gradient(145deg, #111827, #25324a); box-shadow: 0 8px 20px rgba(23,32,51,.2); }
.brand-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.user-area { display: flex; align-items: center; gap: 16px; }
.user-name { color: var(--muted); font-size: 14px; }
.page-content { width: min(1180px, calc(100% - 40px)); margin: 0 auto; flex: 1; padding: 50px 0 64px; }
footer { min-height: 64px; padding: 18px clamp(20px, 5vw, 72px); display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; background: #fff; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(30px, 4vw, 44px); letter-spacing: -.035em; margin-bottom: 12px; }
h2 { font-size: 21px; letter-spacing: -.015em; margin-bottom: 7px; }
h3 { margin-bottom: 7px; }
.muted { color: var(--muted); }
.eyebrow { display: block; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; margin-bottom: 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 38px rgba(32,50,82,.055); }
.btn { border: 0; border-radius: 10px; padding: 11px 17px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: wait; transform: none; }
.btn-primary { color: #fff; background: var(--primary); box-shadow: 0 8px 18px rgba(22,104,227,.2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #eef2f7; color: #354158; }
.btn-danger { background: #fff0f1; color: var(--danger); }
.btn-small { padding: 8px 11px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 5px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 27px; cursor: pointer; padding: 2px 8px; }

.login-grid { min-height: calc(100vh - 250px); display: grid; grid-template-columns: 1.2fr .8fr; align-items: center; gap: clamp(50px, 8vw, 110px); }
.login-intro h1 { max-width: 720px; font-size: clamp(40px, 5vw, 67px); line-height: 1.04; }
.login-intro p { max-width: 680px; color: var(--muted); font-size: 18px; line-height: 1.7; }
.feature-row { display: flex; flex-wrap: wrap; gap: 12px 22px; margin-top: 28px; color: #33415a; font-weight: 650; font-size: 14px; }
.login-card { padding: 32px; max-width: 450px; width: 100%; justify-self: end; }
.password-page { min-height: calc(100vh - 250px); display: grid; place-items: center; }
.password-card { justify-self: center; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 750; }
.field input, .field select, .search-box input { width: 100%; border: 1px solid #d7dce6; border-radius: 10px; padding: 12px 13px; outline: none; color: var(--ink); background: #fff; }
.field input:focus, .field select:focus, .search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,104,227,.11); }
.validation-message { color: var(--danger); font-size: 12px; margin-top: 5px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 23px; }
.page-header p { color: var(--muted); margin-bottom: 0; }
.domain-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.domain-strip strong { color: #205084; background: #eaf3ff; border: 1px solid #d4e6ff; padding: 6px 10px; border-radius: 99px; }
.editor-card { padding: 25px; margin-bottom: 22px; border-color: #c8dcf9; }
.section-title, .list-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 21px; }
.email-builder { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.list-card { overflow: hidden; }
.list-toolbar { padding: 24px 25px; border-bottom: 1px solid var(--line); align-items: center; }
.list-toolbar p { margin-bottom: 0; font-size: 13px; }
.search-box { width: min(300px, 100%); display: flex; align-items: center; gap: 7px; border: 1px solid #d7dce6; border-radius: 10px; padding-left: 12px; background: #fff; }
.search-box input { border: 0; box-shadow: none !important; padding-left: 2px; }
.forwarder-row { display: grid; grid-template-columns: 42px minmax(190px, 1fr) 35px minmax(190px, 1fr) auto; align-items: center; gap: 15px; padding: 18px 25px; border-bottom: 1px solid var(--line); }
.forwarder-row:last-child { border-bottom: 0; }
.forwarder-row:hover { background: #fafcff; }
.mail-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--primary); background: #edf5ff; }
.address-block strong, .address-block span { display: block; overflow-wrap: anywhere; }
.address-block span { display: none; color: var(--muted); font-size: 12px; margin-top: 2px; }
.arrow { color: #9aa3b2; font-size: 20px; text-align: center; }
.destination { color: #465168; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }
.alert { border-radius: 11px; padding: 13px 15px; margin-bottom: 18px; font-size: 14px; }
.alert-error { color: #96282f; background: #fff0f1; border: 1px solid #ffd4d7; }
.alert-success { color: #086346; background: #eafaf4; border: 1px solid #bdebd9; }
.alert-info { color: #205084; background: #eaf3ff; border: 1px solid #c8dcf9; }
.empty-state { text-align: center; padding: 80px 20px; }
.empty-state.compact { padding: 65px 20px; }
.empty-icon { font-size: 36px; color: var(--primary); margin-bottom: 15px; }
.empty-state p { color: var(--muted); }
.loading-panel, .boot-loader { min-height: 55vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #dce4ef; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui { display: none; position: fixed; inset: auto 0 0 0; z-index: 1000; padding: 13px 20px; background: #fff1bf; color: #473d12; }
#blazor-error-ui .dismiss { position: absolute; right: 15px; cursor: pointer; }

@media (max-width: 860px) {
    .login-grid { grid-template-columns: 1fr; padding: 20px 0; gap: 38px; }
    .login-card { justify-self: stretch; max-width: none; }
    .form-grid { grid-template-columns: 1fr; gap: 0; }
    .forwarder-row { grid-template-columns: 40px 1fr auto; }
    .forwarder-row .arrow { display: none; }
    .destination { grid-column: 2; }
    .row-actions { grid-column: 3; grid-row: 1 / span 2; flex-direction: column; }
    .address-block span { display: block; }
}

@media (max-width: 600px) {
    .topbar { height: 68px; padding: 0 16px; }
    .brand-logo-frame { width: 50px; height: 46px; border-radius: 10px; }
    .brand small, .user-name { display: none; }
    .user-area { gap: 7px; }
    .user-area .btn { padding: 9px 11px; font-size: 12px; }
    .page-content { width: min(100% - 28px, 1180px); padding: 30px 0 45px; }
    footer { flex-direction: column; align-items: flex-start; }
    .page-header, .list-toolbar { align-items: stretch; flex-direction: column; }
    .page-header .btn, .search-box { width: 100%; }
    .forwarder-row { padding: 16px; grid-template-columns: 38px 1fr; }
    .destination { grid-column: 2; }
    .row-actions { grid-column: 1 / -1; grid-row: auto; flex-direction: row; padding-top: 7px; }
    .row-actions .btn { flex: 1; }
    .email-builder { grid-template-columns: 1fr; }
    .email-builder > span { display: none; }
}
