:root {
  --ink: #1f2a44;
  --muted: #6b7488;
  --line: #e2e6ee;
  --accent: #2c4a7c;
  --accent-soft: #eef2f9;
  --bg: #f4f6fa;
  --paper: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.muted { color: var(--muted); }
.error { color: #b3261e; }
button { font: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card {
  background: var(--paper); width: 100%; max-width: 360px; padding: 2rem;
  border-radius: 14px; box-shadow: 0 10px 40px rgba(20,30,60,.12);
  display: flex; flex-direction: column; gap: .85rem;
}
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); }
.login-card input {
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; color: var(--ink);
}
.login-card button {
  margin-top: .3rem; padding: .65rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--paper);
  border-bottom: 1px solid var(--line); padding: .55rem .9rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { font-weight: 700; }
.topbar-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.save-state { font-size: .78rem; }
.save-state.dirty { color: #b06a00; }
.btn-ghost, .btn-primary { padding: .45rem .7rem; border-radius: 8px; font-size: .82rem; font-weight: 600; }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-primary { background: var(--accent); color: #fff; border: 0; }

/* ---------- Workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(420px, 1.15fr); gap: 0; align-items: start; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } }

.editor { padding: 1rem 1.1rem 4rem; max-height: calc(100vh - 52px); overflow-y: auto; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-bottom: 1.1rem; }
.field-grid .col2 { grid-column: 1 / -1; }
.field-grid label, .row label { display: flex; flex-direction: column; gap: .25rem; font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.editor input, .editor textarea {
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; font-size: .92rem; color: var(--ink);
  font-family: inherit; font-weight: 400; text-transform: none; letter-spacing: 0;
}
.editor textarea { resize: vertical; }
.editor select { padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; font-size: .92rem; color: var(--ink); font-family: inherit; background: #fff; text-transform: none; letter-spacing: 0; font-weight: 400; }
.hint-inline { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); font-size: .72rem; }

.section-block { border-top: 1px solid var(--line); padding-top: .9rem; margin-bottom: 1.1rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.section-head h2 { font-size: 1rem; margin: 0; }
.add { background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 7px; padding: .35rem .6rem; font-size: .8rem; font-weight: 600; }
.head-btns { display: flex; gap: .4rem; }
.add-lib { background: #fff; color: var(--accent); border: 1px solid var(--accent-soft); border-radius: 7px; padding: .35rem .6rem; font-size: .8rem; font-weight: 600; }
.issue-list li .li-sub { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }
.issue-list li .li-main { display: flex; flex-direction: column; }
.rows { display: flex; flex-direction: column; gap: .7rem; }
.row { background: #fbfcfe; border: 1px solid var(--line); border-radius: 9px; padding: .65rem; position: relative; display: grid; gap: .5rem; }
.row .row-grid { display: grid; gap: .5rem; grid-template-columns: 1fr 1fr; }
.row .row-grid .col2 { grid-column: 1 / -1; }
.row .del { position: absolute; top: .4rem; right: .45rem; background: transparent; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; }
.row .del:hover { color: #b3261e; }

/* ---------- Preview pane ---------- */
.preview-pane { background: #dfe3ec; padding: 1.3rem; min-height: calc(100vh - 52px); }
.paper {
  background: var(--paper); width: 100%; max-width: 8.5in; margin: 0 auto;
  padding: 0.7in 0.75in; box-shadow: 0 6px 30px rgba(20,30,60,.15); color: var(--ink);
  font-size: 11pt; line-height: 1.42;
}

/* ---------- Newsletter document ---------- */
.nl-banner { display: block; width: 100%; height: 150px; object-fit: cover; border-radius: 10px; margin-bottom: .6rem; }
.nl-masthead { text-align: center; background: var(--accent); color: #fff; border-radius: 10px; border-bottom: 5px solid var(--accent2, #b7892f); padding: .7rem .6rem .6rem; margin-bottom: .8rem; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.nl-title { font-size: 26pt; font-weight: 800; letter-spacing: .01em; color: #fff; margin: 0; line-height: 1.05; }
.nl-subtitle { font-size: 10.5pt; text-transform: uppercase; letter-spacing: .14em; color: #fff; opacity: .88; margin: .28rem 0 0; }
.nl-issueline { display: flex; justify-content: space-between; font-size: 9pt; color: #fff; opacity: .85; margin-top: .45rem; text-transform: uppercase; letter-spacing: .08em; }
.nl-intro { font-style: italic; color: #3a4257; margin: .6rem 0 .9rem; }

.nl-section { margin: .85rem 0; }
.nl-h { font-size: 12.5pt; font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; border-left: 5px solid var(--accent2, #b7892f); border-bottom: 2px solid var(--accent2, #b7892f); padding: .1rem 0 .2rem .45rem; margin: 0 0 .45rem; }

.nl-item { margin-bottom: .5rem; }
.nl-item.has-photo::after { content: ""; display: block; clear: both; }
.nl-item .it-photo { float: right; width: 120px; height: auto; border-radius: 6px; margin: 0 0 .3rem .6rem; }
.nl-item .it-top { display: flex; gap: .5rem; align-items: baseline; }
.nl-item .it-title { font-weight: 700; }
.nl-item .it-meta { color: var(--accent); font-weight: 700; font-size: 9.5pt; white-space: nowrap; }
.nl-item .it-sub { color: var(--muted); font-size: 9.5pt; }
.nl-item .it-body { margin: .1rem 0 0; }

.nl-dates { width: 100%; border-collapse: collapse; }
.nl-dates td { padding: .2rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 10pt; }
.nl-dates td.d { color: var(--accent); font-weight: 700; white-space: nowrap; width: 1%; padding-right: .9rem; }

.nl-cta { background: var(--accent-soft); border-left: 4px solid var(--accent2, #b7892f); padding: .6rem .8rem; border-radius: 0 8px 8px 0; margin: .9rem 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.nl-cta .cta-h { font-weight: 800; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; font-size: 10.5pt; margin-bottom: .25rem; }

.nl-contacts { margin-top: .5rem; }
.nl-contacts .cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .9rem; }
.nl-contact { font-size: 10pt; }
.nl-contact .c-name { font-weight: 700; }
.nl-contact .c-role { color: var(--muted); font-size: 9pt; }
.nl-contact .c-phone { color: var(--accent); }

.nl-foot { text-align: center; font-size: 8.5pt; color: var(--muted); border-top: 1px solid var(--line); margin-top: .9rem; padding-top: .4rem; }
.empty-hint { color: #b9c0cf; font-style: italic; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 1rem; }
.modal-card { background: #fff; border-radius: 12px; padding: 1.3rem; width: 100%; max-width: 440px; max-height: 80vh; overflow-y: auto; }
.modal-card h2 { margin-top: 0; }
.issue-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.issue-list li { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.issue-list button { background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 6px; padding: .3rem .6rem; font-weight: 600; }
.modal-actions { margin-top: 1rem; text-align: right; }

/* ---------- Print ---------- */
@page { size: letter; margin: 0.5in; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .workspace { display: block; }
  .preview-pane { background: #fff; padding: 0; min-height: 0; }
  .paper { box-shadow: none; max-width: none; width: auto; padding: 0; font-size: 10.5pt; }
  .nl-cta, .nl-masthead { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .nl-title, .nl-h, .nl-item .it-meta, .nl-contact .c-phone, .nl-banner { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
