/* DAF dashboard */

:root {
  --crimson: #d7192f; --crimson-2: #b51427; --maroon: #7a1b24; --deep: #3d0a10; --ink: #1f0a0d;
  --blush: #fbecee; --blush-2: #f6d9dd; --line: #ecdfe1; --bg: #f7f4f4; --panel: #ffffff; --muted: #6e5357;
  --ok: #17733a; --ok-bg: #e3f4e8; --warn: #8a5a00; --warn-bg: #fcf1da; --info: #2848a0; --info-bg: #e6edfb; --bad: #9b1c28; --bad-bg: #f9e1e4;
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --text: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--text); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
a { color: var(--maroon); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(215, 25, 47, .35); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }

/* Auth pages */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--deep); }
.auth-card { width: min(420px, 100%); background: var(--panel); border-radius: 14px; padding: 36px 32px; display: grid; gap: 16px; }
.auth-card .logo { width: 190px; height: auto; margin-bottom: 4px; }
.auth-card h1 { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: 30px; line-height: 1; color: var(--deep); }
.auth-card p { margin: 0; color: var(--muted); }
.auth-card .error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 8px; font-weight: 600; }

/* Shell */

.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 22px 16px; gap: 22px; }
.side .logo { width: 170px; height: auto; margin: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--blush); color: var(--crimson-2); font-weight: 600; }
.nav a.active svg { color: var(--crimson); }
.nav .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--crimson); color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.side-foot { margin-top: auto; display: grid; gap: 10px; padding: 14px 12px 0; border-top: 1px solid var(--line); }
.who { display: grid; gap: 1px; }
.who b { font-weight: 600; }
.who span { color: var(--muted); font-size: 13px; text-transform: capitalize; }
.side-links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.side-links a, .side-links button { color: var(--maroon); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.main { min-width: 0; padding: 28px 32px 64px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: 34px; line-height: 1; color: var(--deep); letter-spacing: -.01em; }
.head p { margin: 6px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-block; margin-bottom: 8px; font-size: 14px; color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--maroon); }

/* Buttons */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; background: var(--crimson); color: #fff; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--crimson-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); border-color: #dccbce; }
.btn-dark { background: var(--deep); }
.btn-dark:hover { background: #2a060b; }
.btn-danger { background: var(--panel); color: var(--bad); border-color: #efc7cd; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link { background: none; border: 0; padding: 0; color: var(--maroon); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Panels */

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 16px; font-weight: 600; }
.panel-body { padding: 18px; }
.panel-head a { font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stack { display: grid; gap: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 4px; text-decoration: none; color: inherit; transition: border-color .15s; }
a.tile:hover { border-color: #dcbfc4; }
.tile b { font-family: var(--display); font-size: 34px; line-height: 1; font-weight: 700; color: var(--deep); }
.tile span { color: var(--muted); font-size: 14px; }
.tile em { font-style: normal; font-size: 13px; color: var(--crimson-2); font-weight: 600; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed a { color: var(--ink); text-decoration: none; font-weight: 600; }
.feed a:hover { color: var(--crimson-2); }
.feed small { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.feed .when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }

.bar-track { height: 8px; border-radius: 999px; background: var(--blush); overflow: hidden; }
.bar-fill { height: 100%; background: var(--crimson); border-radius: 999px; }

/* Tables */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1 1 260px; }
.toolbar input, .toolbar select { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button[aria-pressed="true"] { background: var(--deep); color: #fff; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fcfafa; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #fdf8f8; }
tbody tr.active { background: var(--blush); }
td small { display: block; color: var(--muted); font-size: 13px; }
td .thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; background: var(--blush); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; white-space: nowrap; background: #eee; color: #444; }
.pill-new, .pill-draft, .pill-upcoming { background: var(--info-bg); color: var(--info); }
.pill-shortlisted, .pill-published, .pill-open, .pill-replied { background: var(--ok-bg); color: var(--ok); }
.pill-reserve, .pill-closed, .pill-scheduled { background: var(--warn-bg); color: var(--warn); }
.pill-rejected, .pill-hidden { background: var(--bad-bg); color: var(--bad); }
.pill-read, .pill-past, .pill-archived { background: #eeeaea; color: #5d4d50; }
.pill-admin { background: var(--deep); color: #fff; }
.pill-editor { background: var(--blush-2); color: var(--maroon); }

/* Split views */

.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.split.open { grid-template-columns: minmax(0, 1fr) 440px; }
.split.open .hide-sm { display: none; }
.detail { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.detail .panel-body { display: grid; gap: 16px; }
.detail h2 { font-size: 20px; font-weight: 700; }
.detail .sub { color: var(--muted); font-weight: 600; font-size: 14px; }
dl.facts { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.box { background: var(--bg); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; text-transform: capitalize; }
.seg button[aria-pressed="true"] { background: var(--deep); border-color: var(--deep); color: #fff; }
.saved { color: var(--ok); font-weight: 600; min-height: 1.4em; margin: 0; font-size: 14px; }

/* Forms */

.form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.field { display: grid; gap: 6px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field label, .label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 13px; margin: 0; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"], .field input[type="datetime-local"], .field input[type="url"], .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid #e2d4d6; border-radius: 8px; background: #fff;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--crimson); box-shadow: 0 0 0 3px rgba(215, 25, 47, .12); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--crimson); }
.form-error { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.sticky-actions { position: sticky; bottom: 0; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 14px 18px; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); }

/* Editor */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.editor-title { width: 100%; border: 0; background: transparent; font-family: var(--display); font-weight: 700; text-transform: uppercase; font-size: 38px; line-height: 1.05; color: var(--deep); padding: 4px 0; }
.editor-title:focus { outline: none; }
.editor-title::placeholder { color: #cdbcbf; }
.md-tools { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); background: #fcfafa; border-radius: var(--r) var(--r) 0 0; }
.md-tools button { min-width: 34px; height: 32px; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; font-weight: 700; color: var(--ink); padding: 0 8px; }
.md-tools button:hover { background: var(--panel); border-color: var(--line); }
.md-tools .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.md-tools .grow { flex: 1; }
.md-tools .tabs { padding: 2px; }
.md-tools .tabs button { height: 28px; font-weight: 600; color: var(--muted); }
.md-tools .tabs button[aria-pressed="true"] { background: var(--deep); color: #fff; border-color: var(--deep); }
.md-body { width: 100%; min-height: 460px; border: 0; padding: 18px; font-size: 16px; line-height: 1.7; resize: vertical; border-radius: 0 0 var(--r) var(--r); }
.md-body:focus { outline: none; }
.preview { padding: 22px 26px; min-height: 460px; }
.preview h2 { font-family: var(--display); text-transform: uppercase; font-size: 28px; margin: 1.2em 0 .4em; color: var(--deep); }
.preview h3 { font-size: 20px; margin: 1.2em 0 .4em; }
.preview p, .preview li { font-size: 16px; line-height: 1.7; }
.preview blockquote { margin: 1em 0; padding: 4px 0 4px 18px; border-left: 4px solid var(--crimson); font-size: 18px; }
.preview img { border-radius: 6px; margin: 1em 0; }
.cover-drop { display: grid; place-items: center; aspect-ratio: 16 / 9; border: 2px dashed #e2cfd2; border-radius: 10px; background: #fcf8f8; color: var(--muted); cursor: pointer; text-align: center; padding: 12px; overflow: hidden; }
.cover-drop img { width: 100%; height: 100%; object-fit: cover; }
.cover-drop.has { border-style: solid; padding: 0; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-grid button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; cursor: pointer; background: var(--bg); aspect-ratio: 4 / 3; }
.media-grid button:hover { border-color: var(--crimson); }
.media-grid img { width: 100%; height: 100%; object-fit: cover; }

/* Messages */

.inbox { display: grid; grid-template-columns: 380px minmax(0, 1fr); min-height: 560px; }
.inbox-list { border-right: 1px solid var(--line); overflow: auto; max-height: calc(100vh - 220px); }
.inbox-item { display: grid; gap: 2px; padding: 14px 18px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 3px solid transparent; width: 100%; text-align: left; border-top: 0; border-right: 0; }
.inbox-item:hover { background: #fdf8f8; }
.inbox-item.active { background: var(--blush); border-left-color: var(--crimson); }
.inbox-item .top { display: flex; justify-content: space-between; gap: 10px; }
.inbox-item b { font-weight: 600; }
.inbox-item.unread b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--crimson); margin-right: 8px; vertical-align: 2px; }
.inbox-item .subj { font-size: 14px; color: var(--maroon); font-weight: 600; }
.inbox-item .snip { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.inbox-item .when { font-size: 12px; color: var(--muted); white-space: nowrap; }
.reader { padding: 24px 28px; display: grid; gap: 16px; align-content: start; }
.reader h2 { font-size: 22px; }
.reader .msg { font-size: 16px; line-height: 1.7; white-space: pre-wrap; background: var(--bg); border-radius: 10px; padding: 18px 20px; margin: 0; }

/* Modal and toast */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(31, 10, 13, .45); }
.modal-card { width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: 0 24px 60px rgba(31, 10, 13, .3); }
.modal-card.sm { width: min(440px, 100%); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 60; background: var(--deep); color: #fff; padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 12px 30px rgba(31, 10, 13, .3); transform: translateY(20px); opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }
.toast.bad { background: var(--bad); }

.topbar { display: none; }

@media (max-width: 1100px) {
  .split.open { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .editor { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .topbar img { width: 140px; height: auto; }
  .topbar button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; font-weight: 600; }
  .main { padding: 20px 16px 56px; }
  .form-grid { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-list { max-height: 320px; border-right: 0; border-bottom: 1px solid var(--line); }
  .hide-sm { display: none; }
  .head h1 { font-size: 28px; }
}

.muted { color: var(--muted); }
.m0 { margin: 0; }
.mb { margin-bottom: 14px; }
.cap { text-transform: capitalize; }
.opt { font-weight: 400; color: var(--muted); }
.self-start { justify-self: start; }
.narrow { max-width: 560px; }
.field textarea.short { min-height: 80px; }
.w-bar { min-width: 160px; }
.w-thumb { width: 72px; }
.inline-row { display: flex; align-items: center; gap: 6px; }
.pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.cover-square { width: 160px; aspect-ratio: 1; }

/* Application filters */

.filters { padding: 14px; margin-bottom: 14px; display: grid; gap: 12px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-row input[type="search"] { flex: 1 1 320px; }
.filter-row select { flex: 0 1 220px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 12px; }
.filter-grid label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filters input, .filters select { width: 100%; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: 14px; color: var(--ink); text-transform: none; letter-spacing: 0; font-weight: 400; }
.filter-row input, .filter-row select { width: auto; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--crimson); }
.filter-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.th-sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
.th-sort:hover, .th-sort.on { color: var(--deep); }
.th-sort:focus-visible { outline: 2px solid var(--crimson); outline-offset: 2px; border-radius: 3px; }
.th-sort .arrow { font-size: 13px; min-width: 10px; }
.btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }

@media (max-width: 720px) {
  .filter-row select, .filter-row input[type="search"] { flex: 1 1 100%; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}
