:root {
  --ink: #12222d;
  --muted: #667680;
  --paper: #f4f7f6;
  --panel: #ffffff;
  --line: #dce5e2;
  --accent: #176b56;
  --accent-strong: #0d5644;
  --mint: #dff8ef;
  --danger: #ad3333;
  --shadow: 0 20px 60px rgba(18, 34, 45, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font: 16px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.brand-mark { width: 44px; height: 44px; border-radius: 13px; display: grid; place-content: center; background: var(--ink); color: #59dfb0; font-weight: 800; font-size: 1.35rem; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, .9fr) minmax(420px, 1.1fr); }
.auth-story { padding: clamp(2rem, 6vw, 6rem); background: var(--ink); color: white; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-story::after { content: ""; width: 28rem; height: 28rem; border: 1px solid rgba(89,223,176,.24); border-radius: 44% 56% 64% 36%; position: absolute; right: -10rem; bottom: -11rem; transform: rotate(24deg); }
.wordmark { display: flex; align-items: center; gap: .8rem; font-weight: 700; letter-spacing: -.01em; }
.wordmark .brand-mark { background: #59dfb0; color: var(--ink); }
.auth-copy { max-width: 34rem; position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; color: #7ee7c1; font-size: .78rem; font-weight: 800; }
.auth-copy h1 { font-size: clamp(2.5rem, 5vw, 5rem); line-height: .98; letter-spacing: -.055em; margin: 1rem 0 1.4rem; }
.auth-copy p { max-width: 28rem; color: #c2d1d5; font-size: 1.08rem; }
.auth-foot { color: #8fa3aa; font-size: .85rem; }
.auth-panel { display: grid; place-content: center; padding: 2rem; }
.auth-card { width: min(100%, 430px); }
.auth-card h2 { font-size: 2rem; letter-spacing: -.035em; margin: 0 0 .35rem; }
.auth-card > p { color: var(--muted); margin: 0 0 2rem; }
.field { display: grid; gap: .45rem; margin-bottom: 1rem; }
.field label { font-weight: 700; font-size: .9rem; }
.field input, .field textarea, .field select, .search { width: 100%; border: 1px solid var(--line); background: white; border-radius: 10px; padding: .78rem .9rem; color: var(--ink); outline: none; }
.field input:focus, .field textarea:focus, .field select:focus, .search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23,107,86,.12); }
.field textarea { min-height: 170px; resize: vertical; }
.hint { color: var(--muted); font-size: .83rem; margin-top: -.25rem; }
.btn { border: 0; border-radius: 10px; padding: .72rem 1rem; font-weight: 750; color: var(--ink); background: #e8eeec; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); background: #fff0f0; }
.btn.full { width: 100%; margin-top: .5rem; }
.btn.small { font-size: .86rem; padding: .55rem .75rem; }
.error { padding: .8rem 1rem; border-radius: 10px; background: #fff0f0; color: #8d2424; margin: 0 0 1rem; }
.success { padding: .8rem 1rem; border-radius: 10px; background: var(--mint); color: var(--accent-strong); margin: 0 0 1rem; }
.portal { height: 100vh; display: grid; grid-template-rows: 68px 1fr; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 1rem; background: var(--ink); color: white; padding: 0 1.1rem; }
.topbar .brand-mark { background: #59dfb0; color: var(--ink); }
.topbar .wordmark { min-width: 215px; }
.top-search { max-width: 620px; flex: 1; position: relative; }
.top-search .search { border: 0; background: rgba(255,255,255,.12); color: white; padding-left: 2.6rem; }
.top-search .search::placeholder { color: #b5c3c8; }
.top-search span { position: absolute; left: .9rem; top: .75rem; color: #b5c3c8; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: .55rem; }
.top-actions .btn { color: white; border-color: rgba(255,255,255,.16); }
.avatar { width: 35px; height: 35px; border-radius: 50%; background: #2b4450; display: grid; place-content: center; font-weight: 800; }
.menu-button { display: none; border: 0; background: transparent; color: white; font-size: 1.4rem; padding: .4rem; }
.workspace { display: grid; grid-template-columns: 240px minmax(330px, 430px) minmax(420px, 1fr); min-height: 0; }
.sidebar, .message-list, .reader { min-height: 0; overflow: auto; background: var(--panel); }
.sidebar { border-right: 1px solid var(--line); padding: 1rem; }
.sidebar .primary { width: 100%; margin-bottom: 1rem; }
.account-select { display: flex; gap: .45rem; align-items: center; margin-bottom: 1rem; }
.account-select select { min-width: 0; flex: 1; border: 1px solid var(--line); border-radius: 9px; padding: .6rem; background: white; }
.section-label { color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; margin: 1.25rem .65rem .45rem; }
.nav-list { display: grid; gap: .2rem; }
.nav-item { border: 0; background: transparent; color: var(--ink); border-radius: 9px; padding: .62rem .7rem; text-align: left; display: flex; gap: .7rem; align-items: center; width: 100%; }
.nav-item:hover, .nav-item.active { background: var(--mint); color: var(--accent-strong); }
.message-list { border-right: 1px solid var(--line); }
.list-head { padding: 1.15rem 1.2rem .85rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); position: sticky; top: 0; z-index: 2; }
.list-head h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.025em; }
.list-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.mail-row { width: 100%; text-align: left; border: 0; border-bottom: 1px solid #edf1f0; background: white; padding: 1rem 1.15rem; display: grid; gap: .2rem; }
.mail-row:hover, .mail-row.active { background: #f3fbf8; }
.mail-row.unread { border-left: 3px solid var(--accent); padding-left: calc(1.15rem - 3px); }
.mail-row.unread .sender, .mail-row.unread .subject { font-weight: 800; }
.row-top { display: flex; align-items: baseline; gap: .6rem; }
.sender { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.date { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.subject { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .93rem; }
.reader { padding: clamp(1.25rem, 3vw, 2.5rem); }
.empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 2rem; }
.empty-icon { width: 56px; height: 56px; margin: 0 auto .8rem; border-radius: 17px; display: grid; place-content: center; background: var(--mint); color: var(--accent); font-size: 1.4rem; }
.reader-head { border-bottom: 1px solid var(--line); padding-bottom: 1.2rem; }
.reader-head h2 { margin: 0 0 1rem; font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.15; letter-spacing: -.035em; }
.reader-meta { color: var(--muted); font-size: .88rem; display: grid; gap: .2rem; }
.reader-actions { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: 1.1rem; }
.message-body { padding-top: 1.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-frame { width: 100%; border: 0; min-height: 500px; background: white; }
.attachments { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.reader #mobile-back { display: none; }
.attachment { color: var(--accent-strong); background: var(--mint); border-radius: 8px; padding: .5rem .7rem; text-decoration: none; font-size: .86rem; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(7,18,25,.62); display: grid; place-items: center; padding: 1rem; z-index: 10; }
.modal { width: min(620px, 100%); max-height: 92vh; overflow: auto; background: white; border-radius: 18px; box-shadow: var(--shadow); padding: 1.4rem; }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.modal-head h2 { margin: 0; letter-spacing: -.025em; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.check { display: flex; align-items: center; gap: .6rem; margin: .4rem 0 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; background: var(--ink); color: white; border-radius: 10px; padding: .75rem 1rem; box-shadow: var(--shadow); transform: translateY(150%); transition: transform .2s ease; z-index: 20; }
.toast.show { transform: translateY(0); }
.admin-list { display: grid; gap: .55rem; margin: 1rem 0; }
.person { display: flex; justify-content: space-between; gap: 1rem; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.badge { border-radius: 999px; padding: .2rem .5rem; font-size: .72rem; font-weight: 800; background: var(--mint); color: var(--accent-strong); }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 205px 340px minmax(380px, 1fr); }
  .portal { overflow: auto; }
  .workspace { min-width: 925px; }
}
@media (max-width: 700px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-story { min-height: 240px; padding: 1.5rem; }
  .auth-copy h1 { font-size: 2.5rem; }
  .auth-foot { display: none; }
  .auth-panel { padding: 2rem 1.25rem; place-content: start center; }
  .topbar .wordmark span { display: none; }
  .topbar .wordmark { min-width: auto; }
  .workspace { min-width: 0; display: block; }
  .menu-button { display: block; }
  .sidebar { display: none; position: fixed; inset: 68px auto 0 0; width: min(88vw, 300px); z-index: 8; box-shadow: var(--shadow); }
  .workspace.menu-open .sidebar { display: block; }
  .workspace.menu-open::after { content: ""; position: fixed; inset: 68px 0 0; background: rgba(7,18,25,.45); z-index: 7; pointer-events: none; }
  .message-list, .reader { height: calc(100vh - 68px); }
  .reader { display: none; }
  .workspace.reading .message-list { display: none; }
  .workspace.reading .reader { display: block; }
  .reader #mobile-back { display: inline-flex; margin-bottom: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .top-actions .label { display: none; }
}
