/* MiniURL — "link workbench". A deep left rail carries the nav; the canvas is
   a cool, quiet lavender-gray; anything that IS a link (slugs, short URLs,
   destinations) is set in monospace so it reads as something you copy.
   --brand (rail, primary buttons) and --accent (focus, highlights, the short
   URL itself) are injected per tenant in the layout head. Keep the CSS
   variables and the @media print block. */

* { box-sizing: border-box; }

:root {
  --ink: #1d1b3a;
  --muted: #6b6a86;
  --line: #e1e0ee;
  --bg: #f4f4fa;
  --card: #ffffff;
  --soft: #f8f8fc;
  --danger: #b42318;
  --warn-bg: #fff7e6;
  --warn-ink: #8a5200;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rail-w: 212px;
  /* --brand / --accent are injected per tenant in the layout head. */
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: color-mix(in srgb, var(--accent, #0f9f8f) 78%, #000); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-size: 1.02rem; margin: 0 0 10px; }
h3 { font-size: .92rem; margin: 14px 0 4px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pageintro { margin: 0 0 18px; max-width: 70ch; }
code, .mono { font-family: var(--mono); font-size: .86em; }
code { background: #efeef8; padding: 1px 5px; border-radius: 4px; }

/* ---- Left rail ---- */
.has-rail { padding-left: var(--rail-w); }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w);
  background: var(--brand, #3b2f7f); color: #fff;
  display: flex; flex-direction: column; padding: 16px 12px; z-index: 20;
  background-image: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.12));
}
.rail-brand { display: flex; align-items: center; gap: 9px; color: #fff; font-weight: 700; font-size: 1.02rem; padding: 2px 6px; }
.rail-brand:hover { text-decoration: none; }
.rail-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent, #0f9f8f); color: #fff; font-size: 1rem;
}
.rail-logo { max-height: 30px; max-width: 120px; object-fit: contain; }
.rail-tenant { color: rgba(255,255,255,.62); font-size: .76rem; padding: 4px 6px 14px; }
.rail-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.rail-nav a {
  color: rgba(255,255,255,.8); padding: 7px 10px; border-radius: 7px; font-size: .88rem;
  border-left: 3px solid transparent;
}
.rail-nav a:hover { background: rgba(255,255,255,.09); color: #fff; text-decoration: none; }
.rail-nav a.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: var(--accent, #0f9f8f); }
.rail-foot { border-top: 1px solid rgba(255,255,255,.14); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.whoami { color: rgba(255,255,255,.85); font-size: .82rem; padding: 4px 10px; border-radius: 6px; }
a.whoami:hover, a.whoami.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.logout-form { margin: 0; }
.logout { color: rgba(255,255,255,.7); font: inherit; font-size: .8rem; background: none; border: 0; padding: 4px 10px; cursor: pointer; }
.logout:hover { color: #fff; text-decoration: underline; }
.mobilebar { display: none; }

@media (max-width: 820px) {
  .has-rail { padding-left: 0; }
  .rail { transform: translateX(-100%); transition: transform .18s ease; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .rail.open { transform: none; }
  .mobilebar {
    display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 12px;
    background: var(--brand, #3b2f7f); color: #fff; position: sticky; top: 0; z-index: 10;
  }
  .rail-toggle { background: none; border: 0; color: #fff; font-size: 1.2rem; cursor: pointer; }
  .mobile-title { color: #fff; font-weight: 700; }
}

/* ---- Layout ---- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 24px 36px; }
.auth-wrap { max-width: 400px; margin: 9vh auto 0; padding: 0 16px; }
.plain-wrap { max-width: none; margin: 0; padding: 0; }
.pagehead { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pagehead h1 { margin: 0; }
.pagehead .actions { margin-left: auto; display: flex; gap: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 16px;
  box-shadow: 0 1px 2px rgba(29, 27, 58, .04);
}
.card.stub { border-style: dashed; background: var(--soft); }
.stub-tag {
  display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--warn-ink); background: var(--warn-bg); border-radius: 4px; padding: 1px 6px; margin-bottom: 6px;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .n { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: .8rem; }

.app-footer { text-align: center; padding: 18px; color: var(--muted); font-size: .78rem; }
.app-footer a { color: inherit; }

.imp-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid #f3d9a4;
  padding: 8px 12px; border-radius: 10px; margin: 0 0 14px; font-size: .86rem;
}

/* ---- Auth card ---- */
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 26px; border-top: 5px solid var(--accent, #0f9f8f); }
.auth-logo { text-align: center; margin-bottom: 16px; }
.auth-logo .name { font-size: 1.3rem; font-weight: 750; color: var(--brand, #3b2f7f); }

/* ---- Forms ---- */
label { display: block; font-size: .82rem; font-weight: 600; margin: 12px 0 4px; }
label.check { font-weight: 400; display: inline-flex; align-items: center; gap: 5px; margin: 0; }
input:not([type=checkbox]):not([type=color]):not([type=radio]), select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent, #0f9f8f); outline-offset: 0; border-color: transparent; }
input.mono { font-family: var(--mono); }
.hint { font-size: .78rem; color: var(--muted); margin: 3px 0 0; }
.field-error { font-size: .8rem; color: var(--danger); margin: 3px 0 0; }
.form-narrow { max-width: 480px; }
.form-wide { max-width: 720px; }
.row2 { display: flex; gap: 14px; }
.row2 > div { flex: 1; min-width: 0; }
.prefix-input { display: flex; align-items: stretch; }
.prefix-input .prefix {
  display: flex; align-items: center; padding: 0 10px; background: var(--soft); border: 1px solid var(--line);
  border-right: 0; border-radius: 8px 0 0 8px; font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap;
}
.prefix-input input { border-radius: 0 8px 8px 0 !important; }
.slug-status { font-size: .8rem; margin-top: 3px; min-height: 1.2em; }
.slug-status.ok { color: #067647; }
.slug-status.bad { color: var(--danger); }

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
  line-height: 1.3;
}
.btn:hover { background: var(--soft); text-decoration: none; }
.btn.primary { background: var(--brand, #3b2f7f); border-color: var(--brand, #3b2f7f); color: #fff; }
.btn.primary:hover { opacity: .92; }
.btn.accent { background: var(--accent, #0f9f8f); border-color: var(--accent, #0f9f8f); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f1c0bb; }
.btn.danger:hover { background: #fef3f2; }
.btn.small { padding: 3px 9px; font-size: .78rem; }
.btn.block { display: flex; justify-content: center; width: 100%; margin-top: 16px; }
.inline-form { display: inline; margin: 0; }

/* ---- Flash messages ---- */
.flash { padding: 10px 13px; border-radius: 9px; margin: 0 0 14px; font-size: .87rem; }
.flash.info    { background: #eef0ff; color: #2e2a7a; }
.flash.success { background: #e9f8f3; color: #05603a; }
.flash.error   { background: #fef3f2; color: #912018; }
.flash.warn    { background: var(--warn-bg); color: var(--warn-ink); }

/* ---- Tables ---- */
table.list { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.list th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; }
table.list td { padding: 9px 8px; border-top: 1px solid var(--line); vertical-align: top; }
table.list tr.archived td { opacity: .6; }
.table-scroll { overflow-x: auto; }

.shorturl { font-family: var(--mono); font-size: .86rem; color: color-mix(in srgb, var(--accent, #0f9f8f) 75%, #000); word-break: break-all; }
.dest { font-family: var(--mono); font-size: .78rem; color: var(--muted); word-break: break-all; display: block; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 999px;
  background: #efeef8; color: #3f3c74; margin: 0 3px 3px 0;
}
.chip.folder { background: color-mix(in srgb, var(--accent, #0f9f8f) 14%, #fff); color: #0b5d55; }
.chip.archived { background: #f2f2f2; color: #666; }
.count { font-variant-numeric: tabular-nums; }

.filterbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; align-items: center; }
.filterbar input[type=search] { flex: 1 1 220px; width: auto; }
.filterbar select { width: auto; }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---- Links list: bulk QR download ---- */
.bulkbar { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin: 0 0 10px; font-size: .87rem; }
.bulkbar label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.bulkbar select { width: auto; }
.bulkbar .bulkhint { font-size: .8rem; }
table.list th.pick, table.list td.pick { width: 28px; padding-right: 0; }
table.list td.pick input, table.list th.pick input { width: auto; margin: 2px 0 0; }

.warn-box { background: var(--warn-bg); color: var(--warn-ink); border-radius: 9px; padding: 10px 12px; font-size: .86rem; margin: 8px 0; }

/* ---- Edit page: locked short link ---- */
.locked-link { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.locked-value { font-weight: 600; padding: 6px 10px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; overflow-wrap: anywhere; }
.locked-note { font-size: .8rem; }
.slug-change { margin: 8px 0 0; }
.slug-change > summary { list-style: none; display: inline-flex; cursor: pointer; }
.slug-change > summary::-webkit-details-marker { display: none; }
.slug-change[open] > summary { margin-bottom: 4px; }
.slug-warning ul { margin: 4px 0 6px; padding-left: 20px; }
.slug-warning p { margin: 4px 0; }
.confirm-line { margin: 10px 0 0; }
.danger-zone { border-color: #f1c0bb; }

/* ---- Glossary ---- */
.glossary dt { font-weight: 700; margin-top: 10px; }
.glossary dd { margin: 2px 0 0 0; color: var(--muted); }

/* ---- Users: status chips ---- */
.chip.on   { background: #e9f8f3; color: #05603a; }
.chip.off  { background: #f2f2f2; color: #666; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.op   { background: color-mix(in srgb, var(--brand, #3b2f7f) 14%, #fff); color: var(--brand, #3b2f7f); }
.chip.you  { background: color-mix(in srgb, var(--accent, #0f9f8f) 14%, #fff); color: #0b5d55; }

/* ---- Settings: domains card ---- */
.domain-list { list-style: none; padding: 0; margin: 0 0 12px; }
.domain-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.domain-list li:last-child { border-bottom: 0; }
.domain-list .mono { font-family: var(--mono); font-size: .86rem; margin-right: auto; }

/* ---- Print (STANDARDS §2.16) ----
   Pages needing a report add a Print button calling window.print(), mark
   chrome/filters/actions .no-print, and emit a print-only .print-title line
   (scope + printed-on timestamp + row count). The screen-hiding rules come
   first so the @media print block below can override them. */
.print-title, .print-only { display: none; }
@media print {
  .no-print, .rail, .mobilebar, .app-footer, .filterbar, .pager, .flash, .imp-banner { display: none !important; }
  .has-rail { padding-left: 0; }
  .print-title { display: block; font-weight: 700; margin: 0 0 10px; }
  .print-only { display: inline; }
  .wrap { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; box-shadow: none; }
  body { background: #fff; font-size: 11px; }
  a, .shorturl { color: inherit; text-decoration: none; }
  .dest { white-space: normal; max-width: none; }
  table.list td { padding: 4px 6px; }
  table.list tr { break-inside: avoid; }
  .chip { border: 1px solid #bbb; background: none !important; color: inherit !important; }
}
