:root {
  --bg: #f6f3ee; --card: #fff; --ink: #1d1a2b; --muted: #6b6780; --line: #e4dfd5;
  --gold: #b8860b; --gold-d: #8a6508; --navy: #14183a; --ok: #1d7a4d; --bad: #b3261e; --warn: #9a6700;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; }
a { color: var(--gold-d); }
.muted { color: var(--muted); } .err { color: var(--bad); min-height: 1.2em; margin: .25rem 0; } .ok { color: var(--ok); }

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1.25rem; letter-spacing: .02em; } .brand span { font-weight: 400; font-size: .85rem; color: #c9c5e6; }
#nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
#nav a { color: #dcd9f2; text-decoration: none; padding: .6rem .75rem; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
#nav a:hover { background: #ffffff14; } #nav a.on { background: var(--gold); color: #fff; }
.pill { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 .5rem; font-size: .75rem; }
.top { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--card); justify-content: flex-end; }
.menu { display: none; margin-right: auto; }
main { padding: 1.5rem 1.25rem 4rem; max-width: 1100px; width: 100%; outline: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat b { display: block; font-size: 1.7rem; } .stat span { color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.cols { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .8rem; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .6rem .7rem; font: inherit; color: inherit; background: #fff; border: 1px solid #cfc9bc; border-radius: 8px; font-weight: 400; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { min-height: 360px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.55; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .55rem .95rem; border-radius: 8px; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #fff; } .btn.primary:hover { background: var(--gold-d); }
.btn.danger { color: var(--bad); } .btn.ghost { background: transparent; color: inherit; border-color: #ffffff30; }
.top .btn.ghost { border-color: var(--line); } .btn.small { padding: .3rem .6rem; min-height: 32px; font-size: .85rem; }
.btn[disabled] { opacity: .6; cursor: wait; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.tag { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eee; }
.tag.paid, .tag.published { background: #dff3e7; color: var(--ok); } .tag.created, .tag.draft { background: #fdf0d2; color: var(--warn); }
.tag.failed, .tag.cancelled, .tag.expired { background: #fbe0de; color: var(--bad); }
.msg { white-space: pre-wrap; } .msg-card.unread { border-left: 4px solid var(--gold); }
.editor { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; } .preview { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; background: #fff; min-height: 360px; overflow: auto; margin-top: .25rem; font-weight: 400; }
.preview h2 { font-size: 1.3rem; margin-top: 1rem; } .preview img { max-width: 100%; } .toolbar { display: flex; gap: .35rem; flex-wrap: wrap; margin: .25rem 0; }
.linkbox { background: #fdf8e6; border: 1px dashed var(--gold); padding: .8rem; border-radius: 8px; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(150%); background: var(--navy); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; transition: transform .25s; z-index: 50; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); } .toast.bad { background: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--navy); }
.login-card { width: 100%; max-width: 380px; } .login-card h1 { color: var(--navy); }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; } .menu { display: inline-block; }
  .editor { grid-template-columns: 1fr; }
}

.brandprev { background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; border: 1px solid var(--line); border-radius: 8px; padding: .75rem; margin: .5rem 0; min-height: 70px; display: grid; place-items: center; }
