@charset "UTF-8";

:root {
  color-scheme: light;
  --paper: #e4e9eb;
  --sheet: #f7f8f6;
  --ink: #142028;
  --muted: #5c6b72;
  --line: #cfd6d9;
  --nav: #10242c;
  --ribbon: #1d4f8a;
  --stamp: #c2412d;
  --ok: #1d6b43;
  --brass: #e7c56a;
  --accent: var(--brass);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(16, 36, 44, .04), transparent 220px),
    var(--paper);
  color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { touch-action: manipulation; }

:focus-visible {
  outline: 3px solid var(--ribbon);
  outline-offset: 3px;
}

.skip {
  position: fixed;
  top: -80px;
  left: 20px;
  background: white;
  padding: 12px;
  z-index: 10;
}
.skip:focus { top: 12px; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: var(--nav);
  color: #e7eef0;
  padding: 28px 18px 22px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.6px;
}

.mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: var(--brass);
  color: var(--nav);
  border-radius: 7px;
  font-size: 20px;
}

.version {
  font: 10px/1.4 ui-monospace, monospace;
  letter-spacing: 1px;
  color: #9aafb6;
  align-self: start;
  margin: 4px 0 0 2px;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
}

.sidebar-label {
  color: #8ea0a8;
  margin: 28px 8px 8px;
}

.sidebar nav { display: grid; gap: 2px; }

.sidebar nav a {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a[aria-current] {
  background: #1c3844;
  color: #fff;
}

.sidebar nav a[aria-current] { border-left-color: var(--brass); }

.sidebar .count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--stamp);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.6;
}

.sidebar-bottom {
  margin-top: auto;
  padding: 22px 8px 0;
  font-size: 12px;
}

.sidebar .muted { color: #9aafb6; }
.local-state { display: flex; align-items: center; gap: 9px; }
.local-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--brass); }
.identity { overflow-wrap: anywhere; border-top: 1px solid #2c4650; padding-top: 16px; margin-top: 18px; }

.logout {
  padding: 0;
  min-height: 40px;
  background: none;
  color: var(--brass);
  text-align: left;
  width: auto;
}
.logout:hover { background: none; text-decoration: underline; }

main {
  margin-left: 248px;
  padding: 36px clamp(20px, 4vw, 64px) 64px;
  max-width: 1680px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.page-header .eyebrow { color: var(--muted); margin: 0 0 6px; font-family: ui-monospace, monospace; letter-spacing: .4px; text-transform: none; font-weight: 500; }

h1 {
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.15;
  letter-spacing: -1px;
  font-weight: 650;
  margin: 0;
  overflow-wrap: anywhere;
}

h2 { font-size: 18px; line-height: 1.35; font-weight: 650; letter-spacing: -.3px; margin: 0; }
h3 { font-size: 16px; margin: 6px 0; }

.badge, .tag {
  font-size: 11px;
  white-space: nowrap;
  background: #e7ecee;
  padding: 4px 9px;
  border-radius: 4px;
}
.badge { background: transparent; border: 1px solid #c5ced1; color: #4d5c63; font-family: ui-monospace, monospace; }
.tag { color: var(--ok); background: #e7f3ec; }

.lead { color: var(--muted); margin: 0 0 22px; }
.muted, .small, .footnote { color: var(--muted); }
.small { font-size: 12px; line-height: 1.65; }
.footnote { font-size: 12px; margin-top: 28px; }

.panel {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  min-width: 0;
}

.panel + .panel { margin-top: 16px; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.step { font: 12px ui-monospace, monospace; color: #7d8b90; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 24px;
  margin: 0 0 28px;
  border-block: 1px solid var(--line);
  padding: 18px 0;
}
.stats > div { display: grid; gap: 6px; }
.stats .eyebrow { color: var(--muted); }
.stats strong { font-size: 34px; line-height: 1.1; font-weight: 560; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.stats strong.text-stat { font-size: 22px; align-self: center; }

.admin-intro {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.admin-intro .lead { margin-bottom: 4px; }
.admin-intro p { margin-top: 0; }
.admin-quicklinks { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-quicklinks a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid #bcc8cc;
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ribbon);
  font-size: 12px;
  font-weight: 650;
}
.admin-quicklinks a:hover { border-color: var(--ribbon); background: #eef3f7; }
.admin-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.admin-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
}
.admin-search input { flex: 1; margin: 0; }
.admin-search button { margin: 0; min-width: 96px; justify-content: center; }
.admin-search .clear-filter { color: var(--ribbon); font-size: 12px; font-weight: 650; padding: 8px; white-space: nowrap; }
.admin-search .clear-filter:hover { text-decoration: underline; text-underline-offset: 3px; }
.admin-resource-grid { display: grid; grid-template-columns: minmax(360px, .8fr) minmax(560px, 1.2fr); gap: 18px; align-items: start; }
.admin-list-panel { padding: 0; overflow: hidden; }
.admin-list-panel > .section-title { padding: 18px 20px 14px; margin: 0; }
.admin-list-panel .section-title p { margin: 2px 0 0; }
.resource-count { color: var(--muted); font: 11px/1.4 ui-monospace, monospace; white-space: nowrap; }
.admin-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 12px 16px; text-align: left; vertical-align: top; }
.admin-table th {
  color: var(--muted);
  background: #edf1f2;
  font-size: 10px;
  letter-spacing: .7px;
  text-transform: uppercase;
  white-space: nowrap;
}
.admin-table tbody tr + tr td { border-top: 1px solid var(--line); }
.admin-table tbody tr:hover td { background: #f0f4f5; }
.admin-table td:first-child { overflow-wrap: anywhere; }
.admin-table td:last-child a { display: inline-block; color: var(--ribbon); font-weight: 650; margin: 0 12px 4px 0; }
.admin-table td:last-child a:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty-table { color: var(--muted); text-align: center !important; padding-block: 32px !important; }
.result-hint { padding: 10px 20px; margin: 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.status { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-ok { color: var(--ok); background: #e7f3ec; }
.status-danger { color: #8a2b1c; background: #fdecea; }
.status-warn { color: #7a5200; background: #fff4d6; }
.status-muted { color: var(--muted); background: #eef1f2; }
.dns-value { display: block; margin: 6px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 4px; background: #f4f7f8; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
button.copy { padding: 4px 10px; font-size: 12px; }
.admin-create-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.admin-create.panel { padding: 0; margin: 0; }
.admin-create summary {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  list-style: none;
  cursor: pointer;
}
.admin-create summary::-webkit-details-marker { display: none; }
.admin-create summary > span:first-child { display: grid; gap: 2px; }
.admin-create summary small { color: var(--muted); font-size: 11px; font-weight: 400; }
.admin-create summary > span:last-child { color: var(--ribbon); font-size: 20px; }
.admin-create[open] summary { border-bottom: 1px solid var(--line); background: #edf1f2; }
.admin-create form { padding: 2px 18px 18px; }
.admin-actions form { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-actions form > button { margin: 0; }
.compact { min-height: 34px; padding: 5px 9px; gap: 0; font-size: 11px; }
.row-details { margin: 8px 0 0; }
.row-details summary { color: var(--ribbon); font-size: 11px; font-weight: 650; }
.row-details form { display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 8px; margin-top: 8px; align-items: end; }
.row-details label { grid-column: 1 / -1; margin: 0; }
.row-details input { min-height: 38px; }

.items { padding: 0; list-style: none; margin: 16px 0 22px; }
.items li {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  overflow-wrap: anywhere;
}
.items .empty { color: var(--muted); font-size: 13px; }

label { display: block; font-size: 12px; font-weight: 650; margin: 16px 0 6px; }

input, textarea, select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid #c5ced1;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
}

input::placeholder { color: #7d8b90; }
textarea { resize: vertical; line-height: 1.5; }
input[type="hidden"] { display: none; }

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  display: inline-block;
  margin: 0;
  accent-color: var(--nav);
}

label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  background: var(--nav);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

form > button { margin-top: 18px; }
button:hover { background: #1c3d4c; }
button[disabled] { opacity: .6; cursor: wait; }

.secondary { background: #e4e8ea; color: var(--ink); }
.secondary:hover { background: #d5dbde; }

.alert { padding: 12px 16px; margin: 0 0 18px; border-radius: 8px; border: 1px solid; font-size: 14px; }
.error { background: #fdecea; color: #8a2b1c; border-color: #f0c2ba; }
.success { background: #e8f5ec; color: var(--ok); border-color: #c5e4d0; }

.login-layout {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: clamp(28px, 5vw, 72px);
  align-items: center;
  padding-top: 28px;
}
.intro .eyebrow { color: var(--ribbon); }
.intro h2 { font-size: clamp(34px, 4vw, 52px); letter-spacing: -1.6px; line-height: 1.05; margin: 12px 0 16px; }
.intro > p { max-width: 38ch; }
.login-form { padding: 28px; }
.login-form button { background: var(--ribbon); color: #fff; width: 100%; }
.login-form button:hover { background: #163e6e; }

.mailbox-bar { margin-bottom: 18px; padding: 4px 0 16px; border-bottom: 1px solid var(--line); }
.mailbox-bar label { margin-top: 0; }
.mailbox-bar .back { margin: 12px 12px 0 0; }
.inline-form, .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form select { flex: 1; }
.actions { margin-top: 16px; }
.actions a, .reading nav.actions a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--ribbon);
  color: #fff;
  font-size: 13px;
  font-weight: 650;
}
.actions a:hover, .reading nav.actions a:hover { background: #163e6e; }

fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 16px 0; padding: 12px 14px; }
legend { font-weight: 650; overflow-wrap: anywhere; padding: 0 6px; }
.permissions { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.grant-form { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 18px; }

.folder-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.folder-tabs a { padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 650; color: var(--muted); }
.folder-tabs a:hover { background: #dfe6e8; color: var(--ink); }
.folder-tabs a[aria-current] { background: var(--nav); color: #fff; }
.folder-tabs .compose-tab { margin-left: auto; background: var(--ribbon); color: #fff; }
.folder-tabs .compose-tab:hover { background: #163e6e; color: #fff; }
.folder-tabs .count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4em;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--stamp);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
}
.folder-tabs a[aria-current] .count { background: #fff; color: var(--stamp); }

.usage-panel { margin-bottom: 16px; padding: 16px 18px; }
.usage-panel h3 { margin-top: 0; }
meter { display: block; width: min(420px, 100%); height: 12px; margin: 8px 0 12px; }

.mail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  gap: 18px;
  align-items: start;
}

.message-list { padding: 8px 0 16px; }
.message-list > .section-title { padding: 12px 20px 8px; }

.message-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 14px 20px 14px 18px;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
}
.message-row:hover { background: #eef2f3; }
.message-row.unread { background: #fff; border-left-color: var(--stamp); }
.message-row.unread h3 { font-weight: 700; }
.message-link { display: block; min-width: 0; grid-column: 1; padding-right: 18px; }
.message-link:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.message-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; flex-wrap: wrap; overflow-wrap: anywhere; }
.message-meta time, .from { font-family: ui-monospace, monospace; font-size: 12px; }
.message-meta time { color: var(--muted); }
.message-row h3 { overflow-wrap: anywhere; font-weight: 600; margin: 2px 0; }
.unread-dot {
  position: absolute;
  right: 16px;
  top: 18px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stamp);
}

.flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag {
  font-size: 11px;
  line-height: 1.4;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e7eef5;
  color: var(--ribbon);
  font-weight: 650;
}

.empty-state { text-align: center; padding: 48px 16px; color: var(--muted); font-size: 13px; }
.empty-state h3 { color: var(--ink); font-weight: 560; }
.empty-mark { display: block; font-size: 28px; color: #8aa0a8; margin-bottom: 12px; }
.pagination { display: flex; justify-content: space-between; gap: 20px; padding: 8px 20px 0; font-size: 13px; }
.pagination a { padding-top: 12px; text-decoration: underline; text-underline-offset: 3px; }

.back { display: inline-block; font-size: 13px; margin: 0 0 16px; text-decoration: underline; text-underline-offset: 4px; color: var(--ribbon); }

.reading { max-width: 880px; }
.letter-head { padding-bottom: 8px; }
.letter-subject { margin: 0 0 8px; font-size: clamp(22px, 2vw, 28px); letter-spacing: -.5px; line-height: 1.2; font-weight: 650; }
.reading dl { font-size: 13px; margin: 8px 0 0; }
.reading dl div { display: grid; grid-template-columns: 64px 1fr; gap: 12px; margin: 6px 0; }
.reading dt { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; }
.reading dd { margin: 0; overflow-wrap: anywhere; }
.letter .message-body { border-top: 1px dashed #b7c3c8; margin-top: 16px; padding-top: 18px; }
.message-body { font-size: 15px; line-height: 1.75; font-family: inherit; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.reading .actions button { width: auto; margin: 0; }

.compose { position: sticky; top: 16px; scroll-margin-top: 24px; }
.compose .section-title span { color: #8aa0a8; }
.compose form > button { width: auto; }

.row-actions { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 2; justify-self: end; }
.row-actions button { margin: 0; width: auto; min-height: 36px; padding: 6px 10px; font-size: 11px; background: #e4e8ea; color: var(--ink); gap: 0; }
.row-actions button:hover { background: #d5dbde; }
.row-actions button[value="trash"] { background: #fdecea; color: #8a2b1c; }
.row-actions button[value="restore"] { background: #e8f5ec; color: var(--ok); }

.mail-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.mail-toolbar input[type="search"],
.mail-toolbar input[type="text"] { flex: 1; min-width: 160px; margin: 0; }
.mail-toolbar label { margin: 0; }
.mail-toolbar button { margin: 0; width: auto; min-width: 0; }
.mail-toolbar .unread-filter { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; font-weight: 650; min-height: 44px; }
.mail-toolbar .clear-filter { margin: 0; white-space: nowrap; }

.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 20px 14px; }
.bulk-actions label { margin: 0; }
.bulk-actions select { min-height: 44px; width: auto; max-width: 100%; }
.bulk-actions button { margin: 0; width: auto; }
.message-select { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; min-height: 36px; margin: 0; font-weight: 600; font-size: 12px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

#app.htmx-request .page-header h1 { opacity: .55; transition: opacity .15s ease; }
.htmx-indicator { opacity: 0; }
#app.htmx-request .htmx-indicator { opacity: 1; }
#app.htmx-request .message-list,
#app.htmx-request .compose { opacity: .72; transition: opacity .12s ease; }
.alert.success { animation: flash-in .25s ease; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

details { margin-top: 16px; }
details summary { cursor: pointer; font-weight: 650; }

@media (prefers-reduced-motion: reduce) {
  .alert.success, #app.htmx-request .page-header h1, #app.htmx-request .message-list, #app.htmx-request .compose { animation: none; transition: none; }
}

@media (max-width: 1100px) {
  .sidebar { width: 220px; padding: 22px 14px; }
  main { margin-left: 220px; padding: 28px 20px 48px; }
  .mail-layout, .login-layout { grid-template-columns: 1fr; }
  .compose { position: static; }
  .badge { display: none; }
  .admin-resource-grid { grid-template-columns: 1fr; }
  .admin-create-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: auto; padding: 16px; }
  .sidebar-label { margin-top: 16px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 6px; }
  .sidebar nav a { font-size: 12px; padding: 8px 10px; }
  .sidebar-bottom { padding: 12px 0 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .sidebar-bottom p { margin: 0; }
  .sidebar-bottom > .muted { display: none; }
  .identity { border: 0; padding: 0; margin: 0; }
  .sidebar-bottom form { margin-left: auto; }
  .logout { margin: 0; min-height: 36px; }
  main { margin: 0; padding: 20px 16px 40px; }
  .columns, .stats, .admin-create-grid { grid-template-columns: 1fr; }
  .admin-intro, .admin-search { align-items: stretch; flex-direction: column; }
  .admin-search button { width: 100%; }
  .admin-search .clear-filter { text-align: center; }
  .admin-table { min-width: 620px; }
  .admin-list-panel > .section-title { align-items: start; }
  .login-layout { padding-top: 8px; }
  .panel { padding: 16px; }
  .message-row { grid-template-columns: 1fr; padding: 12px 14px; }
  .row-actions { grid-column: 1; justify-self: start; }
  .folder-tabs .compose-tab { margin-left: 0; }
  .mail-toolbar button { width: 100%; justify-content: center; }
}
