:root {
  --bg: #08080a;
  --surface: #0d0c0e;
  --surface-2: #111013;
  --surface-3: #18181f;
  --surface-hover: #1c1c24;
  --border: #27272a;
  --border-soft: #1d1d22;
  --text: #f5f5f7;
  --muted: #8f8f99;
  --muted-2: #62626b;
  --accent: #f3d35e;
  --accent-soft: rgba(243, 211, 94, .12);
  --danger: #f87171;
  --success: #5ee7a7;
  --radius: 14px;
  --shadow: 0 28px 90px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(243, 211, 94, .04), transparent 28%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, .025), transparent 30%),
    #08080a;
}
.auth-glow { position: absolute; width: 360px; height: 360px; border-radius: 50%; filter: blur(110px); opacity: .15; pointer-events: none; }
.auth-glow-one { background: #f3d35e; top: -180px; right: 12%; }
.auth-glow-two { background: #6f6af8; bottom: -220px; left: 8%; opacity: .08; }

.auth-card {
  width: min(100%, 500px);
  background: rgba(13, 12, 14, .92);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  position: relative;
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-auth { padding-bottom: 24px; border-bottom: 1px solid var(--border-soft); }
.brand-mark {
  width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 11px;
  display: grid; place-items: center; background: var(--surface-3); font-size: 20px; font-weight: 800;
}
.brand-name { font-weight: 750; letter-spacing: -.02em; }
.brand-sub { color: var(--muted-2); font-size: 11px; margin-top: 2px; text-transform: uppercase; letter-spacing: .08em; }
.auth-copy { padding: 30px 0 24px; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing: .13em; font-size: 10px; }
.auth-copy h1 { margin: 9px 0 10px; font-size: clamp(28px, 6vw, 38px); line-height: 1.05; letter-spacing: -.045em; }
.auth-copy p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: #09090b; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 22px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px; }
.tab.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px rgba(255,255,255,.03); }

.auth-form { display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 8px; }
.auth-form label > span { color: #c7c7cd; font-size: 12px; font-weight: 700; }
input {
  width: 100%; border: 1px solid var(--border); background: #09090b; color: var(--text);
  padding: 13px 14px; border-radius: 10px; outline: none; transition: border .18s, box-shadow .18s, background .18s;
}
input:focus { border-color: #4a4a52; background: #0c0c0f; box-shadow: 0 0 0 3px rgba(255,255,255,.035); }
input::placeholder { color: #55555e; }
.email-control, .password-control { display: flex; align-items: stretch; position: relative; }
.email-control input { border-radius: 10px 0 0 10px; border-right: 0; }
.domain-suffix { display: flex; align-items: center; padding: 0 13px; white-space: nowrap; background: var(--surface-3); border: 1px solid var(--border); color: #aaaab3; border-radius: 0 10px 10px 0; font-size: 12px; font-weight: 700; }
.password-control input { padding-right: 46px; }
.password-control .icon-button { position: absolute; right: 5px; top: 5px; bottom: 5px; }
.primary-button {
  margin-top: 4px; border: 1px solid #34343c; background: var(--surface-3); padding: 13px 16px; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 800; transition: background .18s, transform .18s, border .18s;
}
.primary-button:hover { background: var(--surface-hover); border-color: #42424b; }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button .arrow { color: var(--accent); font-size: 18px; }
.form-note { color: var(--muted-2); text-align: center; font-size: 11px; margin: 1px 0 0; }

.mail-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; background: #09090b; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; }
.sidebar-brand { padding: 4px 7px 20px; border-bottom: 1px solid var(--border-soft); }
.sidebar-action {
  width: 100%; margin: 18px 0; background: var(--surface-3); border: 1px solid var(--border); border-radius: 9px;
  padding: 11px 12px; cursor: pointer; font-size: 12px; font-weight: 800; box-shadow: 0 10px 25px rgba(0,0,0,.18);
}
.sidebar-action:hover { background: var(--surface-hover); }
.nav-list { display: grid; gap: 6px; }
.nav-item { width: 100%; border: 1px solid transparent; background: transparent; color: #c6c6ce; padding: 10px 11px; display: flex; align-items: center; gap: 10px; border-radius: 9px; cursor: pointer; text-align: left; font-size: 13px; }
.nav-item.active { border-color: var(--border); background: #111013; color: white; }
.nav-icon { width: 18px; color: #d6d6db; }
.badge { margin-left: auto; min-width: 20px; text-align: center; border-radius: 99px; background: var(--accent-soft); color: var(--accent); padding: 2px 6px; font-size: 10px; font-weight: 900; }
.sidebar-bottom { border-top: 1px solid var(--border-soft); padding-top: 14px; display: grid; gap: 10px; }
.account-card { display: flex; gap: 9px; align-items: center; min-width: 0; }
.avatar { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); display: grid; place-items: center; background: var(--surface-3); font-weight: 800; flex: none; }
.account-meta { min-width: 0; display: grid; gap: 2px; }
.account-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.account-meta span { color: var(--muted-2); font-size: 10px; }
.logout-button { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 8px; cursor: pointer; font-size: 11px; }
.logout-button:hover { color: white; background: #121216; }

.mail-content { min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar { min-height: 78px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; background: #0b0b0e; }
.topbar h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.03em; }
.status-pill { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 7px 10px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 12px rgba(94,231,167,.4); }
.mail-grid { min-height: 0; flex: 1; display: grid; grid-template-columns: minmax(310px, 38%) 1fr; }
.message-list-panel { min-width: 0; min-height: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: #0b0b0e; }
.panel-head { height: 62px; flex: none; padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-head > div { display: grid; gap: 3px; }
.panel-head strong { font-size: 13px; }
.panel-head span { color: var(--muted-2); font-size: 10px; }
.icon-button { width: 36px; min-width: 36px; height: 36px; border: 1px solid var(--border); background: var(--surface-3); border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.icon-button:hover { background: var(--surface-hover); }
.message-list { overflow-y: auto; min-height: 0; flex: 1; }
.message-row { width: 100%; display: block; text-align: left; border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; padding: 15px 16px; cursor: pointer; position: relative; }
.message-row:hover { background: var(--surface-2); }
.message-row.active { background: #141419; }
.message-row.unread::before { content: ""; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); position: absolute; left: 0; top: 12px; bottom: 12px; }
.message-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted-2); font-size: 10px; margin-bottom: 7px; }
.message-from { color: white; font-weight: 800; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-subject { margin-top: 5px; color: #dedee4; font-weight: 650; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-preview { color: var(--muted); font-size: 11px; line-height: 1.45; margin-top: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.attachment { color: var(--accent); }
.empty-state { min-height: 100%; display: grid; place-content: center; text-align: center; justify-items: center; padding: 28px; color: var(--muted); gap: 7px; }
.empty-icon { width: 50px; height: 50px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--border); display: grid; place-items: center; font-size: 20px; margin-bottom: 5px; }
.empty-state strong { color: #d7d7dc; font-size: 13px; }
.empty-state span { font-size: 11px; }

.viewer-panel { min-width: 0; min-height: 0; overflow-y: auto; background: #09090b; }
.viewer-empty { min-height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; padding: 36px; }
.viewer-logo { width: 60px; height: 60px; border-radius: 16px; background: var(--surface-3); border: 1px solid var(--border); display: grid; place-items: center; font-size: 27px; font-weight: 900; box-shadow: 0 18px 60px rgba(0,0,0,.28); }
.viewer-empty h3 { margin: 16px 0 7px; font-size: 17px; }
.viewer-empty p { margin: 0; color: var(--muted); max-width: 310px; font-size: 12px; line-height: 1.6; }
.viewer-content { min-height: 100%; }
.viewer-head { padding: 24px 28px; border-bottom: 1px solid var(--border); }
.viewer-head h3 { margin: 8px 0 14px; font-size: clamp(20px, 3vw, 30px); letter-spacing: -.035em; }
.viewer-addresses { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.viewer-addresses strong { color: #d5d5db; font-weight: 700; }
.viewer-date { color: var(--muted-2); font-size: 10px; margin-top: 12px; }
.viewer-body { padding: 28px; max-width: 950px; }
.text-body { white-space: pre-wrap; color: #dddde2; font-size: 13px; line-height: 1.7; }
.html-frame { width: 100%; min-height: 520px; border: 1px solid var(--border); background: #111116; border-radius: 10px; }
.loading { min-height: 160px; display: grid; place-content: center; color: var(--muted); font-size: 12px; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s ease; background: #18181f; border: 1px solid var(--border); color: white; padding: 11px 14px; border-radius: 10px; font-size: 12px; box-shadow: var(--shadow); max-width: min(92vw, 560px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(248, 113, 113, .45); color: #ffd1d1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #25252b; border-radius: 20px; border: 3px solid transparent; background-clip: padding-box; }

@media (max-width: 900px) {
  .mail-shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 15px 10px; }
  .sidebar-brand .brand-name, .sidebar-brand .brand-sub, .sidebar-action:not(:has(span)), .sidebar-action { font-size: 0; }
  .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-action { display: grid; place-items: center; padding: 10px; }
  .sidebar-action span { font-size: 17px; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item > span:not(.nav-icon):not(.badge) { display: none; }
  .badge { position: absolute; transform: translate(17px, -14px); }
  .nav-item { position: relative; }
  .account-meta, .logout-button { display: none; }
  .account-card { justify-content: center; }
  .mail-grid { grid-template-columns: minmax(280px, 43%) 1fr; }
}

@media (max-width: 680px) {
  .auth-shell { padding: 16px; }
  .auth-card { padding: 20px; border-radius: 18px; }
  .mail-shell { display: block; }
  .sidebar { min-height: auto; height: 64px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); flex-direction: row; align-items: center; }
  .sidebar > div:first-child { display: flex; align-items: center; gap: 10px; width: 100%; }
  .sidebar-brand { border: 0; padding: 0; margin-right: auto; }
  .sidebar-brand .brand-name { display: block; font-size: 13px; }
  .sidebar-brand .brand-sub { display: none; }
  .sidebar-action { width: 40px; margin: 0; }
  .nav-list { display: none; }
  .sidebar-bottom { border: 0; padding: 0; }
  .account-card { display: none; }
  .logout-button { display: block; font-size: 0; width: 40px; height: 40px; padding: 0; }
  .logout-button::after { content: "↪"; font-size: 16px; }
  .mail-content { height: calc(100vh - 64px); }
  .topbar { min-height: 68px; padding: 11px 14px; }
  .status-pill { display: none; }
  .mail-grid { display: block; position: relative; overflow: hidden; }
  .message-list-panel, .viewer-panel { position: absolute; inset: 0; border-right: 0; }
  .viewer-panel { transform: translateX(100%); transition: transform .2s ease; z-index: 3; }
  .viewer-panel.mobile-open { transform: translateX(0); }
  .viewer-head { padding: 18px; }
  .viewer-body { padding: 18px; }
  .viewer-head::before { content: "← Назад"; display: inline-block; color: var(--accent); font-size: 11px; font-weight: 800; margin-bottom: 9px; cursor: pointer; }
  .email-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .domain-suffix { max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
}

/* Vaultmail custom */
.sidebar-brand .brand-name {
  max-width: 185px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
