/*! PDF Toolkit admin & sign-in screens */
:root {
  --desk: #E4E9EE; --paper: #FFFFFF; --ink: #14202B; --muted: #5B6875; --line: #D1D8DF; --soft: #F1F4F7;
  --accent: #0A7C74; --accent-deep: #065C56; --accent-soft: #DDF1EE; --accent-light: #7FD3CA;
  --danger: #C4382A; --danger-soft: #FCE9E7; --warn-bg: #FFF4D6; --warn-ink: #8A5A00; --ok-bg: #E3F6EA; --ok-ink: #146C38;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --ui: "Figtree", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--ui); background: var(--desk); color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.45; }
a { color: var(--accent-deep); }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; }

/* Buttons & fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 10px 16px; font: 600 .93rem var(--ui); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s; color: var(--ink); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-deep); }
.btn-ghost { background: var(--soft); }
.btn-ghost:hover { background: var(--line); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #F8D3CF; }
.btn-sm { padding: 6px 11px; font-size: .84rem; border-radius: 8px; }
.btn-block { width: 100%; padding: 13px; font-size: 1rem; }
label.field { display: block; }
label.field > span, .field-label { display: block; font-size: .87rem; font-weight: 600; margin-bottom: 6px; }
label.field small, .hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 5px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-size: .95rem; color: var(--ink); }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 52px; height: 42px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.check { display: flex; align-items: center; gap: 9px; font-size: .92rem; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.error { color: var(--danger); font-size: .85rem; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Notices */
.flash { padding: 11px 14px; border-radius: 10px; font-size: .92rem; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.flash .ic { margin-top: 1px; }

/* Sign-in screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth > div { width: min(440px, 100%); }
.auth-card { width: 100%; background: var(--paper); border-radius: 20px; padding: 32px; box-shadow: 0 1px 2px rgba(20,32,43,.08), 0 24px 60px -24px rgba(20,32,43,.35); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand b { font-family: var(--display); font-weight: 800; font-size: 1.35rem; }
.mark { width: 28px; height: 36px; background: var(--accent); position: relative; clip-path: polygon(0 0, 70% 0, 100% 24%, 100% 100%, 0 100%); flex-shrink: 0; }
.mark::after { content: ""; position: absolute; right: 0; top: 0; width: 30%; height: 24%; background: var(--accent-light); }
.brand-logo { height: 36px; max-width: 180px; object-fit: contain; }
.auth h1 { font-size: 1.55rem; margin: 0 0 6px; font-weight: 800; }
.auth .sub { color: var(--muted); margin: 0 0 22px; }
.code-input { font-family: var(--mono) !important; font-size: 1.15rem !important; letter-spacing: .08em; text-transform: uppercase; text-align: center; padding: 14px !important; }
.auth .stack > * + * { margin-top: 14px; }
.auth-foot { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.auth-legal { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 16px; }

/* Admin layout */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #C9D2DA; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.side .side-brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 6px 10px 18px; text-decoration: none; }
.side .side-brand b { font-family: var(--display); font-size: 1.1rem; }
.side .side-brand small { display: block; color: #8B9AA7; font-size: .75rem; font-weight: 500; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 500; font-size: .94rem; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.on { background: var(--accent); color: #fff; }
.side .grow { flex: 1; }
.side form { margin: 0; }
.side .side-btn { width: 100%; justify-content: flex-start; background: none; color: inherit; padding: 10px 12px; font-weight: 500; }
.side .side-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.main { padding: 26px 30px 50px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 1.7rem; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.1rem; margin: 0 0 14px; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-2 > .card + .card { margin-top: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stat b { display: block; font-family: var(--display); font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat .live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #1EA672; margin-right: 6px; box-shadow: 0 0 0 3px rgba(30,166,114,.2); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #FAFBFC; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data a.row-link { color: var(--ink); text-decoration: none; font-weight: 600; }
table.data a.row-link:hover { color: var(--accent-deep); text-decoration: underline; }
.mono { font-family: var(--mono); font-size: .9em; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.empty-row { text-align: center; color: var(--muted); padding: 30px !important; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.active, .badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.expired, .badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.disabled { background: var(--soft); color: var(--muted); }
.badge.admin { background: #E8EEFB; color: #1F4FB0; }
.badge.online::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #1EA672; }

/* Toolbar */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .86rem; }
.seg a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20,32,43,.14); }

/* Code display */
.code-big { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; letter-spacing: .08em; background: var(--soft); border-radius: 12px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.codes-list { font-family: var(--mono); font-size: 1.05rem; line-height: 2; background: var(--soft); border-radius: 12px; padding: 12px 18px; margin: 0 0 14px; max-height: 50vh; overflow: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Activity */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; align-items: baseline; }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--muted); font-size: .8rem; white-space: nowrap; min-width: 92px; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; transform: translateY(-1px); }
.feed .dot.warn { background: #E0A000; }
.feed .dot.admin { background: #1F4FB0; }

/* Branding preview */
.preview-bar { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--desk); border-radius: 12px; }
.preview-bar b { font-family: var(--display); font-size: 1.25rem; font-weight: 800; }
.preview-bar span { color: var(--muted); font-size: .85rem; margin-left: auto; }
.logo-thumb { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--soft); border-radius: 10px; margin-bottom: 8px; }
.logo-thumb img { max-height: 40px; max-width: 160px; }

/* Pagination */
.pager { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 14px 0 0; font-size: .88rem; color: var(--muted); flex-wrap: wrap; }
.pager .links { display: flex; gap: 6px; }

@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side .side-brand { padding: 4px 8px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .grow { display: none; }
  .main { padding: 18px 16px 40px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}
