:root {
  --navy: #1B3A6B;
  --navy-deep: #12294D;
  --magenta: #D32F7C;
  --magenta-soft: #F9E3EE;
  --bg: #F4F6FA;
  --card: #FFFFFF;
  --ink: #1E2430;
  --muted: #6B7686;
  --line: #E3E8F0;
  --ok: #1E8E5A;
  --warn: #C93B3B;
  --radius: 12px;
  --font-h: 'Playfair Display', Georgia, serif;
  --font-b: 'Inter', -apple-system, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-b); background: var(--bg); color: var(--ink); font-size: 14px; }
button { font-family: var(--font-b); cursor: pointer; }
input, select { font-family: var(--font-b); }

.btn {
  border: 0; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  background: var(--navy); color: #fff; transition: filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--magenta); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { background: #fff; }
.btn.danger { background: transparent; color: var(--warn); border: 1px solid #F0D2D2; }
.btn.danger:hover { background: #FBF0F0; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy-deep), var(--navy) 55%, #2B5AA0); }
.login-card { background: var(--card); border-radius: 16px; padding: 42px 38px; width: 360px; box-shadow: 0 24px 60px rgba(10, 25, 50, .35); }
.login-card .brand { font-family: var(--font-h); font-size: 26px; color: var(--navy); }
.login-card .brand em { color: var(--magenta); font-style: normal; }
.login-card .sub { color: var(--muted); font-size: 12.5px; margin: 6px 0 26px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }
.field input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.field input:focus { outline: 2px solid var(--magenta-soft); border-color: var(--magenta); }
.login-err { color: var(--warn); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }

/* ---------- shell ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-family: var(--font-h); font-size: 19px; color: var(--navy); white-space: nowrap; }
.topbar .brand em { color: var(--magenta); font-style: normal; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 12.5px; }

/* ---------- projects ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.page-title { font-family: var(--font-h); font-size: 24px; color: var(--navy); margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-family: var(--font-h); font-size: 17px; color: var(--ink); }
.card .client { color: var(--magenta); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 10px; }
.doc-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.doc-row .t { flex: 1; min-width: 0; }
.doc-row .t .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .t .meta { color: var(--muted); font-size: 11.5px; }
.card .actions { display: flex; gap: 8px; margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 45, .5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--card); border-radius: 14px; padding: 26px; width: 430px; max-width: 92vw; max-height: 86vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.modal h3 { font-family: var(--font-h); color: var(--navy); margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; line-height: 1.5; }
.modal .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.hidden { display: none !important; }

/* ---------- editor ---------- */
.editor-shell { display: grid; grid-template-columns: 230px 1fr 260px; height: calc(100vh - 56px); }
.panel { background: var(--card); overflow-y: auto; }
.panel.left { border-right: 1px solid var(--line); padding: 14px; }
.panel.right { border-left: 1px solid var(--line); padding: 16px; }
.panel h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 8px; }
.panel h4:first-child { margin-top: 0; }

.page-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.page-item:hover { background: var(--bg); }
.page-item .n { color: var(--muted); font-size: 11.5px; width: 18px; }
.page-item .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.badge.over { background: #FBEAEA; color: var(--warn); }
.badge.ok { background: #E7F5EE; color: var(--ok); }

.stage { background: #262B36; overflow-y: auto; display: flex; justify-content: center; padding: 26px 0; }
.stage iframe { border: 0; width: 430px; background: #fff; box-shadow: 0 10px 40px rgba(0,0,0,.5); border-radius: 4px; flex-shrink: 0; }

.swatch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.swatch-row input[type="color"] { width: 34px; height: 28px; border: 1px solid var(--line); border-radius: 6px; padding: 1px; background: #fff; cursor: pointer; }
.swatch-row .vn { font-size: 12.5px; font-family: monospace; color: var(--ink); flex: 1; }
.swatch-row .vv { font-size: 11px; color: var(--muted); font-family: monospace; }

.sel-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--muted); }
.sel-box .tag { font-weight: 700; color: var(--navy); }
.font-stepper { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.font-stepper button { width: 30px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 15px; font-weight: 700; color: var(--navy); }
.font-stepper span { font-size: 12.5px; }
.el-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.el-actions .btn { flex: 1; white-space: nowrap; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.55; }
.save-state { font-size: 12px; color: var(--muted); min-width: 90px; text-align: right; }
.save-state.dirty { color: var(--warn); font-weight: 600; }
.save-state.saved { color: var(--ok); }

.version-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.version-item .t { flex: 1; }
.version-item .meta { color: var(--muted); font-size: 11.5px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy-deep); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35); z-index: 200; opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }
