:root {
  --navy: #073b84;
  --navy2: #123b72;
  --gold: #0b74f5;
  --bg: #f3f8ff;
  --line: #d7e7f8;
  --muted: #64748b;
  --danger: #b42318;
  --ok: #057a55;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --focus: rgba(11, 116, 245, .18);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--navy2);
  font-family: Roboto, "Noto Sans", Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.nav-open { overflow: hidden; }
a { color: #075ec9; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 22px;
  color: #fff;
  background: var(--navy);
  border-bottom: 4px solid var(--gold);
}
.brand { font-size: 20px; font-weight: 900; letter-spacing: .8px; }
.brand span { color: var(--gold); }
.tagline { margin-top: 4px; color: var(--gold); font-size: 12px; letter-spacing: .16em; }
.mobile-menu-button { display: none; }
.icon-button {
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.1); }

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav a,
.nav button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 11px;
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  font-size: 13px;
}
.nav a:hover { text-decoration: none; background: rgba(255,255,255,.14); }
.nav a.active { color: #fff; background: var(--gold); font-weight: 800; }
.nav-account { display: inline-flex; align-items: center; gap: 8px; }
.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: var(--gold);
  border-radius: 50%;
  font-weight: 900;
}
.nav-account-email { max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mobile-folder-link { display: none !important; }
.nav-backdrop { display: none; }

.wrap { width: 100%; max-width: 1180px; margin: 24px auto; padding: 0 16px; }
.card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(7,21,39,.08);
}
.card-pad { padding: 24px; }
.login { max-width: 460px; margin: 8vh auto; }
.grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }

.field { margin: 0 0 15px; }
.field label { display: block; margin-bottom: 7px; color: var(--navy2); font-weight: 800; }
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 13px;
  color: var(--navy2);
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  outline: 0;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: #0b74f5; box-shadow: 0 0 0 3px var(--focus); }
.field textarea { min-height: 250px; resize: vertical; }
.email-entry,
.password-entry {
  display: flex;
  align-items: stretch;
  width: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
}
.field .email-entry input,
.field .password-entry input { flex: 1; min-width: 0; width: auto; border: 0; border-radius: 0; box-shadow: none; }
.email-entry:focus-within,
.password-entry:focus-within { border-color: #0b74f5; box-shadow: 0 0 0 3px var(--focus); }
.email-domain { display: flex; align-items: center; padding: 0 13px; color: #334155; background: #eef2f7; border-left: 1px solid #cbd5e1; font-weight: 800; white-space: nowrap; }
.password-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  padding: 0;
  color: #475569;
  background: #fff;
  border: 0;
  border-left: 1px solid #e2e8f0;
  cursor: pointer;
}
.password-toggle:hover { color: var(--navy); background: #f8fafc; }
.password-toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.password-toggle [hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 10px 16px;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.gold, .btn.primary { color: #fff; background: linear-gradient(135deg,#0b74f5,#0755c8); }
.btn.red { background: var(--danger); }
.btn.light { color: var(--navy2); background: #eef2f7; }

.side { position: sticky; top: 100px; padding: 14px; }
.side a:not(.btn) { display: flex; align-items: center; gap: 10px; padding: 11px 12px; color: var(--navy2); border-radius: 11px; font-weight: 700; }
.side a.active,
.side a:not(.btn):hover { background: #eef2f7; text-decoration: none; }
.side-compose { width: 100%; margin-top: 10px; }

.mail-list { border-top: 1px solid var(--line); }
.mail-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 74px;
  padding: 11px 16px;
  color: var(--navy2);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.mail-row:hover { background: var(--surface-soft); text-decoration: none; }
.mail-row.unread { background: #fbfdff; }
.sender-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: #536b86;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 800;
}
.mail-row.unread .sender-avatar { background: var(--navy); }
.mail-row-content { display: block; min-width: 0; }
.mail-row-top,
.mail-row-bottom { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mail-row-top { margin-bottom: 4px; }
.mail-sender,
.mail-subject { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-sender { flex: 1; font-size: 15px; }
.mail-row.unread .mail-sender,
.mail-row.unread .mail-subject { font-weight: 800; }
.mail-date { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.mail-subject { flex: 1; color: #475569; font-size: 14px; }
.mail-row.unread .mail-subject { color: var(--navy2); }
.mail-attachment { display: inline-flex; flex: 0 0 auto; color: var(--muted); }
.mail-attachment .icon { width: 17px; height: 17px; }
.list-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pagination-actions { display: flex; gap: 8px; }

.muted { color: var(--muted); }
.pill { display: inline-flex; padding: 3px 8px; color: #334155; background: #eef2f7; border-radius: 999px; font-size: 12px; }
.flash { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; font-weight: 700; }
.flash.ok { color: var(--ok); background: #ecfdf3; border: 1px solid #abefc6; }
.flash.error { color: var(--danger); background: #fef3f2; border: 1px solid #fecdca; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.message-head { padding: 20px 22px; border-bottom: 1px solid var(--line); }
.message-title { margin: 0 0 14px; font-size: clamp(23px, 3vw, 34px); line-height: 1.2; overflow-wrap: anywhere; }
.message-actions { margin-top: 16px; }
.message-card { min-width: 0; }
.message-body { width: 100%; max-width: 100%; min-width: 0; padding: 22px; overflow: hidden; }
.message-frame { display: block; width: 100%; max-width: 100%; min-width: 0; height: 180px; overflow: hidden; background: #fff; border: 0; }
.mobile-back-link { display: none; }
.attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.attachment { display: flex; align-items: center; gap: 7px; padding: 10px; background: #fbfdff; border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.attachment .icon { width: 18px; height: 18px; flex: 0 0 auto; }

.footer { padding: 20px; color: var(--muted); text-align: center; font-size: 12px; }
.compose-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center; }
.install-btn { color: #fff !important; background: var(--gold) !important; font-weight: 800; cursor: pointer; }
.install-btn[hidden] { display: none !important; }
.offline-card { max-width: 560px; margin: 10vh auto; }
.app-safe-note { margin-top: 10px; color: var(--muted); font-size: 12px; }
.mobile-compose-fab { display: none; }

@media (max-width: 820px) {
  .topbar {
    justify-content: flex-start;
    gap: 10px;
    min-height: 62px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    border-bottom-width: 2px;
  }
  .mobile-menu-button { display: inline-flex; flex: 0 0 auto; }
  .brand-lockup { min-width: 0; }
  .brand { overflow: hidden; font-size: 17px; letter-spacing: .35px; text-overflow: ellipsis; white-space: nowrap; }
  .tagline { display: none; }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    display: flex;
    align-items: stretch;
    align-content: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    width: min(84vw, 320px);
    height: 100dvh;
    padding: calc(20px + env(safe-area-inset-top)) 12px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    color: var(--navy2);
    background: #fff;
    box-shadow: 12px 0 34px rgba(7,21,39,.24);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  .nav.open { transform: translateX(0); }
  .nav a,
  .nav button {
    justify-content: flex-start;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--navy2);
    background: transparent;
    border: 0;
    border-radius: 12px;
    font-size: 15px;
  }
  .nav a:hover { background: #eef2f7; }
  .nav a.active { color: var(--navy); background: rgba(201,163,58,.22); }
  .nav-account {
    display: grid;
    grid-template-columns: 42px minmax(0,1fr);
    align-items: center;
    gap: 10px;
    margin: 0 2px 12px;
    padding: 6px 4px 16px;
    border-bottom: 1px solid var(--line);
  }
  .account-avatar { width: 42px; height: 42px; }
  .nav-account-email { max-width: none; color: var(--navy2); font-size: 14px; }
  .mobile-folder-link { display: inline-flex !important; }
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(7,21,39,.48);
    border: 0;
  }
  .nav-backdrop[hidden] { display: none; }

  .wrap { max-width: none; margin: 0; padding: 0 0 calc(78px + env(safe-area-inset-bottom)); }
  .flash { margin: 10px 12px; }
  .grid { display: block; }
  .side { display: none; }
  .card { border: 0; border-radius: 0; box-shadow: none; }
  .grid > .card { min-height: calc(100dvh - 64px); }
  .card-pad { padding: 18px 16px; }
  .card-pad h1 { font-size: 23px; }

  .mail-list { border-top: 1px solid #edf1f6; }
  .mail-row {
    grid-template-columns: 42px minmax(0,1fr);
    min-height: 76px;
    padding: 10px 14px;
    border-bottom-color: #edf1f6;
  }
  .mail-row:hover { background: #fff; }
  .mail-row.unread:hover { background: #fbfdff; }
  .mail-sender { font-size: 15px; }
  .mail-subject { font-size: 14px; }
  .mail-date { font-size: 11px; }
  .list-pagination { padding: 14px 16px 24px; }

  .mobile-compose-fab {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 35;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 54px;
    padding: 0 18px;
    color: #fff;
    background: var(--gold);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(7,21,39,.28);
    font-weight: 900;
  }
  .mobile-compose-fab:hover { text-decoration: none; }

  .login { max-width: none; min-height: calc(100dvh - 64px); margin: 0; }
  .login .card-pad { padding: 32px 20px; }
  .email-domain { padding: 0 10px; font-size: 14px; }

  .message-head { padding: 16px; }
  .mobile-back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: #475569; font-weight: 700; }
  .message-title { margin-bottom: 16px; font-size: 24px; }
  .message-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 16px; }
  .message-actions > a,
  .message-actions > form,
  .message-actions form .btn { width: 100%; }
  .message-actions .btn { min-height: 44px; padding-inline: 10px; }
  .message-body { padding: 14px 12px 30px; }
  .message-frame { width: 100%; }

  .compose-grid { gap: 6px; }
  .compose-grid .field { margin-bottom: 10px; }
  .compose-grid .field input,
  .compose-grid .field textarea { border-radius: 8px; }
  .compose-grid .field textarea { min-height: 280px; }
  .footer { display: none; }
}

@media (max-width: 420px) {
  .nav { width: 88vw; }
  .mail-row { grid-template-columns: 38px minmax(0,1fr); gap: 10px; padding-inline: 12px; }
  .sender-avatar { width: 38px; height: 38px; }
  .mobile-compose-fab span { display: none; }
  .mobile-compose-fab { width: 56px; padding: 0; justify-content: center; border-radius: 18px; }
  .email-domain { padding-inline: 8px; font-size: 13px; }
}

@media (display-mode: standalone) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* SANN Opticals branding */
.brand-lockup{display:flex;flex-direction:column;justify-content:center}.topbar{background:linear-gradient(135deg,#063b86,#075ac7);border-bottom-color:#54b8ff}.brand span{color:#8ed7ff}.tagline{color:#cceaff}.login{max-width:540px}.login-pad{padding:30px}.login-brand{display:flex;align-items:center;gap:18px;margin-bottom:18px}.login-brand img{width:138px;max-height:98px;object-fit:contain;border-radius:14px}.login-brand h1{margin:0;color:#073b84;font-size:29px;line-height:1.05}.login-brand p{margin:7px 0 0;color:#0b74f5;font-size:11px;font-weight:800;letter-spacing:.08em}.login-help{margin:0 0 24px}.login-submit{width:100%;min-height:48px}.sender-avatar{background:#4777ad}.mail-row.unread .sender-avatar{background:#0b74f5}.side a.active,.side a:not(.btn):hover{background:#edf6ff}.mail-row.unread{background:#f8fbff}.footer{font-weight:700}.remote-image-note{font-size:12px;color:var(--muted)}
@media(max-width:820px){.login{margin:0}.login-pad{padding:24px 18px}.login-brand{flex-direction:column;text-align:center}.login-brand img{width:160px}.login-brand h1{font-size:26px}}
