/* Quiet editor: navy header from the template, white working surfaces, one blue accent. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --sunken: #eef1f5;
  --ink: #0d1b33;
  --ink-2: #4a5874;
  --ink-3: #6f7b91;
  --line: #dde2ea;
  --line-strong: #c6cedb;
  --navy: #001b4e;
  --navy-2: #0a2a66;
  --teal: #00c99f;
  --accent: #0046eb;
  --accent-hover: #0039c2;
  --accent-soft: #e6edfe;
  --ok: #0a7f5e;
  --ok-soft: #e1f4ed;
  --warn: #9a5300;
  --warn-soft: #fcf0df;
  --bad: #c0142f;
  --bad-soft: #fce8eb;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(13, 27, 51, .06), 0 8px 24px -12px rgba(13, 27, 51, .18);
  --font: 'Readex Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
::selection { background: rgba(0, 70, 235, .18); }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { text-wrap: balance; margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; }
h3 { font-size: 14px; line-height: 1.35; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 56px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: baseline; gap: 8px; color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand small { color: var(--teal); font-weight: 400; font-size: 14px; }
.nav { display: flex; gap: 2px; }
.nav a {
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 7px;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.topbar-end { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.lang-toggle {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 7px;
  overflow: hidden;
}
.lang-toggle button {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, .72);
  font: inherit;
  font-size: 13px;
  padding: 4px 10px;
  cursor: pointer;
}
.lang-toggle button[aria-pressed="true"] { background: rgba(255, 255, 255, .16); color: #fff; }
.account-link {
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy-2);
  border: 1px solid rgba(255, 255, 255, .2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}

/* ---------- page frame ---------- */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px max(20px, env(safe-area-inset-right)) 64px max(20px, env(safe-area-inset-left));
  display: grid;
  gap: 20px;
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.page-head .sub { color: var(--ink-2); font-size: 14px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.panel > h2 + * { margin-top: 14px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- controls ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: 500 14px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn .spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .flip { transform: scaleX(-1); }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="time"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: 400 15px/1.4 var(--font);
  font-variant-numeric: tabular-nums;
}
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input[aria-invalid="true"] { border-color: var(--bad); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--accent-soft); color: var(--accent); }

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--sunken);
  color: var(--ink);
}
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.notice.ok { background: var(--ok-soft); }
.notice strong { font-weight: 600; }

/* ---------- toast ---------- */
.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 440px); }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: rise .25s cubic-bezier(.2, .8, .2, 1);
}
.toast.bad { background: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast, .btn .spinner { animation: none; } }

/* ---------- editor ---------- */
.editor-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.date-nav { display: inline-flex; align-items: center; gap: 4px; }
.date-nav input[type="date"] { width: auto; min-height: 38px; }
.date-title { display: grid; line-height: 1.25; }
.date-title strong { font-size: 18px; font-weight: 600; }
.date-title span { font-size: 13px; color: var(--ink-2); }
.editor-actions { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: 8px; }

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 20px;
  align-items: start;
}
.form-col { display: grid; gap: 16px; min-width: 0; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px 18px; }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.group-head span { color: var(--ink-3); font-size: 13px; }
.grid-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.vf { display: grid; gap: 5px; min-width: 0; }
.vf label { font-size: 12.5px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 6px; }
.vf label .alt { color: var(--ink-3); }
.vf input { direction: ltr; text-align: start; font-weight: 500; }
[dir="rtl"] .vf input { text-align: end; }
.vf input.rtl { direction: rtl; }
.vf.flag input { border-color: #e2a54d; background: #fffaf2; }
.vf .hint { font-size: 12px; color: var(--warn); }
.vf.active input { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.preview-col { position: sticky; top: 76px; display: grid; gap: 10px; }
.preview {
  background: var(--navy);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 1248 / 2551;
  height: min(calc(100vh - 170px), 900px);
  max-width: 100%;
  justify-self: center;
}
.preview iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-note { font-size: 12.5px; color: var(--ink-3); text-align: center; }
.downloads { display: flex; gap: 8px; justify-content: center; }

.schedule-line { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 13px; color: var(--ink-2); }

.deriv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.deriv-col { display: grid; gap: 10px; align-content: start; padding: 12px; border-radius: var(--radius); background: var(--sunken); }
.deriv-col h3 { font-size: 13.5px; font-weight: 600; }
@media (max-width: 720px) { .deriv-grid { grid-template-columns: 1fr; } }

/* send sheet (inline, not a modal) */
.send-sheet { border: 1px solid var(--accent); background: var(--surface); border-radius: var(--radius-lg); padding: 16px 18px; display: grid; gap: 12px; }
.send-sheet .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* ---------- archive ---------- */
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
.day {
  display: grid;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
}
.day .thumb { aspect-ratio: 1248 / 2551; border-radius: 6px; background: var(--navy); overflow: hidden; display: block; }
.day .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.day .thumb.empty { display: grid; place-items: center; color: rgba(255, 255, 255, .6); font-size: 13px; }
.day-meta { display: grid; gap: 2px; }
.day-meta strong { font-size: 14px; font-weight: 600; }
.day-meta span { font-size: 12.5px; color: var(--ink-3); }
.day-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.day-actions .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-2); display: grid; gap: 10px; justify-items: center; }

/* ---------- tables (team) ---------- */
.list { width: 100%; border-collapse: collapse; font-size: 14px; }
.list th { text-align: start; font-weight: 500; font-size: 12.5px; color: var(--ink-3); padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.list td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list .actions { text-align: end; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form .field { flex: 1 1 220px; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { font-size: 13px; }

/* ---------- forms pages ---------- */
.form-stack { display: grid; gap: 16px; max-width: 520px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; }
.form-row > * { flex: 1 1 160px; }
.days { display: flex; flex-wrap: wrap; gap: 8px; }
.days label { display: inline-flex; }
.days input { position: absolute; opacity: 0; pointer-events: none; }
.days span {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.days input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.days input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* ---------- auth pages ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}
.auth .topbar { position: static; }
.auth main { display: grid; place-items: center; padding: 32px 20px 80px; }
.auth-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: grid;
  gap: 18px;
  box-shadow: var(--shadow);
}
.auth-card .btn.primary { width: 100%; min-height: 42px; }
.auth-card p.muted { font-size: 14px; }
.auth-links { font-size: 14px; text-align: center; }

@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .preview-col { position: static; order: -1; }
  .preview { height: 70vh; }
}
@media (max-width: 720px) {
  .topbar-inner { gap: 12px; }
  .brand small { display: none; }
  .nav { overflow-x: auto; }
  .account-link .who { display: none; }
  .editor-actions { margin-inline-start: 0; width: 100%; }
  .editor-actions .btn { flex: 1 1 auto; }
}
