:root {
  --ink: #08252d;
  --ink-deep: #041b22;
  --sand: #dfa959;
  --sand-soft: #f4e6d1;
  --paper: #f6f4ef;
  --white: #fff;
  --muted: #6d7b7e;
  --line: #dcdedb;
  --danger: #ad3434;
  --success: #27745a;
  --shadow: 0 18px 55px rgba(4, 27, 34, 0.12);
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 100px 24px 45px;
  background:
    radial-gradient(circle at 14% 8%, rgba(223,169,89,.18), transparent 34%),
    linear-gradient(135deg, var(--ink-deep), var(--ink));
}
.auth-brand { position: absolute; top: 30px; left: 34px; display: flex; gap: 12px; align-items: center; color: #fff; text-decoration: none; }
.auth-brand > span:last-child, .app-brand > span:last-child { display: grid; }
.auth-brand small, .app-brand small { color: rgba(255,255,255,.58); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid currentColor; border-radius: 50%; color: var(--sand); font-family: Georgia, serif; font-size: 1.3rem; }
.auth-card { width: min(100%, 490px); padding: clamp(30px, 6vw, 58px); background: var(--white); box-shadow: 0 35px 100px rgba(0,0,0,.28); }
.auth-card h1 { margin: 7px 0 13px; font-family: "Manrope", sans-serif; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.06; letter-spacing: -.05em; }
.auth-card > p:not(.kicker) { margin: 0 0 28px; color: var(--muted); line-height: 1.6; }
.kicker { margin: 0; color: #a16f2a; font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: #425256; font-size: .78rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cfd5d4; border-radius: 2px; background: #fff; color: var(--ink); outline: none; transition: border 160ms, box-shadow 160ms; }
input, select { min-height: 46px; padding: 0 13px; }
textarea { min-height: 125px; padding: 12px 13px; line-height: 1.55; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #739198; box-shadow: 0 0 0 3px rgba(68,117,127,.13); }
form small { margin-top: -9px; color: var(--muted); line-height: 1.45; }
.primary, .secondary, .danger, .ghost, .small-action { min-height: 42px; padding: 0 18px; border: 0; cursor: pointer; font-weight: 700; }
.primary { background: var(--ink); color: #fff; }
.primary:hover { background: #123843; }
.secondary { border: 1px solid var(--ink); background: transparent; }
.danger { background: #f6e0df; color: var(--danger); }
.ghost { background: #edf0ef; }
.small-action { min-height: 34px; padding-inline: 12px; background: #edf0ef; font-size: .72rem; }
button:disabled { cursor: wait; opacity: .55; }
.form-message { min-height: 20px; margin: 0; color: var(--danger); font-size: .8rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; background: var(--ink-deep); color: #fff; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 28px; }
.app-brand { display: flex; gap: 11px; align-items: center; color: #fff; text-decoration: none; }
.app-brand .brand-mark { width: 36px; height: 36px; font-size: 1rem; }
.admin-nav { display: grid; gap: 4px; }
.admin-nav button { display: grid; grid-template-columns: 27px 1fr auto; align-items: center; min-height: 46px; padding: 0 13px; border: 0; border-radius: 4px; background: transparent; color: rgba(255,255,255,.64); cursor: pointer; text-align: left; }
.admin-nav button > span { color: var(--sand); font-size: 1.05rem; text-align: center; }
.admin-nav button:hover, .admin-nav button.is-active { background: rgba(255,255,255,.09); color: #fff; }
.admin-nav em { display: grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 20px; background: var(--sand); color: var(--ink); font-size: .68rem; font-style: normal; font-weight: 800; }
.sidebar-foot { display: grid; gap: 3px; margin-top: auto; padding-top: 25px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot a, .sidebar-foot button { padding: 9px 12px; border: 0; background: none; color: rgba(255,255,255,.55); cursor: pointer; font-size: .72rem; text-align: left; text-decoration: none; }
.sidebar-foot a:hover, .sidebar-foot button:hover { color: #fff; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 0; background: transparent; cursor: pointer; font-size: 1.2rem; }
.sidebar-close, .menu-open { display: none; }
.app-main { min-width: 0; }
.topbar { position: sticky; z-index: 10; top: 0; min-height: 88px; display: flex; align-items: center; gap: 18px; padding: 0 clamp(22px,4vw,58px); border-bottom: 1px solid var(--line); background: rgba(246,244,239,.92); backdrop-filter: blur(12px); }
.topbar > div:first-of-type { display: grid; }
.topbar p { margin: 0 0 3px; color: var(--muted); font-size: .62rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-family: "Manrope", sans-serif; font-size: 1.55rem; letter-spacing: -.04em; }
.user-menu { position: relative; margin-left: auto; }
.user-menu > button { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.user-menu > button > span:first-child { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; background: var(--sand); font-weight: 800; }
.user-menu > button > span:last-child { display: grid; }
.user-menu small { color: var(--muted); font-size: .65rem; text-transform: capitalize; }
.user-popover { position: absolute; top: 52px; right: 0; width: 190px; padding: 7px; background: #fff; box-shadow: var(--shadow); }
.user-popover button { width: 100%; padding: 10px; border: 0; background: none; cursor: pointer; text-align: left; }
.user-popover button:hover { background: var(--paper); }
.workspace { max-width: 1500px; min-height: calc(100vh - 88px); padding: clamp(26px,4vw,58px); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 27px; }
.page-head h2 { margin: 0 0 7px; font-family: "Manrope", sans-serif; font-size: clamp(1.7rem,3vw,2.35rem); letter-spacing: -.045em; }
.page-head p { max-width: 680px; margin: 0; color: var(--muted); line-height: 1.55; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 15px; margin-bottom: 34px; }
.stat { padding: 24px; border: 1px solid var(--line); background: #fff; }
.stat span { display: block; color: var(--muted); font-size: .72rem; }
.stat strong { display: block; margin-top: 13px; font-family: "Manrope", sans-serif; font-size: 2.55rem; letter-spacing: -.06em; }
.panel { margin-bottom: 22px; border: 1px solid var(--line); background: #fff; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 21px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-family: "Manrope", sans-serif; font-size: 1rem; }
.panel-body { padding: 21px; }
.empty { padding: 45px 22px; color: var(--muted); text-align: center; }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 18px; padding: 17px 21px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row h3, .list-row h4 { margin: 0 0 4px; font-size: .96rem; }
.list-row p { margin: 0; color: var(--muted); font-size: .79rem; line-height: 1.5; }
.row-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.admin-link-button { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.post-list-meta { display: flex; gap: 8px; margin-bottom: 7px; }
.post-list-meta span { color: #9a6721; font-size: .62rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.post-body-editor { min-height: 360px; font-family: Georgia, serif; font-size: 1rem; line-height: 1.7; }
.modal:has([data-post-form]) { width: min(900px,calc(100vw - 32px)); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 20px; background: #edf0ef; color: #526164; font-size: .65rem; font-weight: 700; }
.badge.unread, .badge.draft { background: #f8e9cc; color: #81591f; }
.badge.published, .badge.read, .badge.active { background: #dcefe7; color: #226048; }
.badge.cancelled, .badge.archived, .badge.inactive { background: #eee; color: #777; }
.content-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.content-card { display: grid; gap: 14px; padding: 21px; border: 1px solid var(--line); background: #fff; }
.content-card header { display: flex; justify-content: space-between; gap: 16px; }
.content-card h3 { margin: 0 0 4px; font-size: .97rem; }
.content-card p { margin: 0; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.content-card textarea { min-height: 150px; }
.content-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filters button { min-height: 36px; padding: 0 13px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.filters button.is-active { border-color: var(--ink); background: var(--ink); color: #fff; }
.message-list { display: grid; grid-template-columns: minmax(260px,.62fr) minmax(360px,1fr); min-height: 570px; border: 1px solid var(--line); background: #fff; }
.message-index { border-right: 1px solid var(--line); overflow: auto; }
.message-index button { width: 100%; display: grid; gap: 5px; padding: 17px 19px; border: 0; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; text-align: left; }
.message-index button:hover, .message-index button.is-active { background: #f4f0e9; }
.message-index button.is-unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--sand); }
.message-index span { color: var(--muted); font-size: .7rem; }
.message-detail { padding: clamp(22px,4vw,42px); }
.message-detail h2 { margin: 8px 0 17px; font-family: "Manrope", sans-serif; letter-spacing: -.04em; }
.message-meta { display: grid; gap: 5px; padding-bottom: 22px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.message-body { min-height: 150px; padding-block: 27px; white-space: pre-wrap; line-height: 1.75; }
.settings-groups { display: grid; gap: 20px; }
.settings-grid, .form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 17px; }
.settings-grid label:has(textarea), .form-grid .full { grid-column: 1 / -1; }
.check-label { display: flex; align-items: center; gap: 9px; }
.check-label input { width: 18px; min-height: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: .76rem; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .65rem; letter-spacing: .08em; text-transform: uppercase; }
td code { font-size: .7rem; }
.loading { display: grid; min-height: 380px; place-items: center; color: var(--muted); }
.loading::before { content: ""; width: 30px; height: 30px; border: 3px solid #d9dddc; border-top-color: var(--sand); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal { width: min(680px,calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; background: #fff; box-shadow: 0 30px 100px rgba(4,27,34,.33); }
.modal::backdrop { background: rgba(3,19,27,.72); backdrop-filter: blur(4px); }
.modal-close { position: absolute; z-index: 2; top: 17px; right: 17px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--paper); cursor: pointer; font-size: 1.4rem; }
.modal-inner { max-height: calc(100vh - 32px); overflow: auto; padding: clamp(28px,6vw,52px); }
.modal-inner h2 { margin: 6px 42px 22px 0; font-family: "Manrope", sans-serif; font-size: 1.8rem; letter-spacing: -.04em; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(390px,calc(100vw - 48px)); padding: 14px 18px; background: var(--ink-deep); color: #fff; box-shadow: var(--shadow); font-size: .82rem; }
.toast.is-error { background: var(--danger); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 225px minmax(0,1fr); }
  .stats { grid-template-columns: repeat(2,1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(300px,88vw); transform: translateX(-102%); transition: transform 180ms ease; box-shadow: 20px 0 60px rgba(0,0,0,.25); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close, .menu-open { display: grid; }
  .topbar { min-height: 76px; padding-inline: 15px; }
  .topbar > div:first-of-type { display: none; }
  .user-menu { margin-left: auto; }
  .user-menu > button > span:last-child { display: none; }
  .workspace { padding: 27px 17px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 18px; }
  .stat strong { font-size: 2rem; }
  .message-list { grid-template-columns: 1fr; }
  .message-index { max-height: 330px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-grid, .form-grid { grid-template-columns: 1fr; }
  .settings-grid label:has(textarea), .form-grid .full { grid-column: 1; }
}
@media (max-width: 470px) {
  .stats { grid-template-columns: 1fr; }
  .row-actions { align-items: stretch; flex-direction: column; }
  .list-row { grid-template-columns: 1fr; }
}
