:root {
  --ink: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f8fafc;
  --panel: #ffffff;
  --accent: #E51837;
  --success: #16a34a;
  --error: #dc2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }

.topbar { background: var(--ink); color: #fff; padding: 0 24px; display: flex; align-items: stretch; gap: 16px; border-bottom: 4px solid var(--accent); min-height: 56px; }
.bar-accent { width: 24px; background: var(--accent); align-self: stretch; }
.topbar .brand { color: #fff; text-decoration: none; font-weight: 600; align-self: center; }
.topnav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.topnav a { color: #d1d5db; text-decoration: none; font-size: 13px; }
.topnav a:hover { color: #fff; }
.topnav .who { color: #9ca3af; font-size: 13px; padding-left: 12px; border-left: 1px solid #374151; }
.topnav .who small { font-style: italic; }
.btn-link { background: none; border: none; color: #d1d5db; cursor: pointer; padding: 0; font: inherit; }
.btn-link:hover { color: #fff; }
.btn-link.danger { color: var(--error); }

.page { max-width: 1100px; margin: 24px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.error   { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 22px; }
.card + .card { margin-top: 18px; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.login-card { max-width: 380px; margin: 60px auto; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form-stack input, .form-stack select, .form-stack textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: 14px/1.5 inherit; background: #fff; color: var(--ink); }
.form-stack input[type="color"] { padding: 2px; height: 38px; }
.form-stack input:focus, .form-stack select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form-stack input:disabled { background: var(--bg); color: var(--muted); }
.form-stack fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px 6px; margin: 6px 0; }
.form-stack fieldset legend { padding: 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.form-stack h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 10px 0 0; }

.row { display: flex; gap: 8px; align-items: center; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.email-row { display: flex; }
.email-row input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.email-row .domain { background: var(--bg); border: 1px solid var(--border); border-left: 0; border-top-right-radius: 6px; border-bottom-right-radius: 6px; padding: 8px 10px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; }

.btn { background: var(--accent); color: #fff; border: none; padding: 9px 16px; border-radius: 6px; font: 14px inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(0.92); }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--error); }
.btn.danger:hover { filter: brightness(0.92); }
.btn .check { display: none; }
.btn.copied { background: var(--success) !important; }
.btn.copied .label { display: none; }
.btn.copied .check { display: inline; }

.inline-form { display: inline; }
.actions { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.signature-preview { background: #fff; border: 1px dashed var(--border); border-radius: 6px; padding: 14px; }
.raw { margin-top: 14px; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.raw pre { background: #0b1020; color: #e5e7eb; padding: 14px; border-radius: 6px; overflow: auto; max-height: 360px; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; word-break: break-all; margin-top: 6px; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table th { background: var(--bg); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.table tr:last-child td { border-bottom: none; }
.table code { font-family: ui-monospace, monospace; font-size: 12px; color: var(--ink); }
.table a { color: var(--accent); text-decoration: none; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.super_admin   { background: #fee2e2; color: #991b1b; }
.badge.company_admin { background: #fef3c7; color: #854d0e; }
.badge.user          { background: #e0e7ff; color: #3730a3; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; }

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 14px; }

.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 12px; }
.logo-card { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s; }
.logo-card:hover { border-color: var(--accent); box-shadow: 0 1px 0 rgba(0,0,0,0.04); }
.logo-card-img { background: #f8fafc; border: 1px dashed var(--border); border-radius: 6px; padding: 14px; display: flex; align-items: center; justify-content: center; min-height: 110px; }
.logo-card-img img { max-width: 100%; max-height: 90px; height: auto; }
.logo-card-meta { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.logo-card-meta .small { font-size: 11px; }
.logo-card-actions { font-size: 12px; }

.appfoot { max-width: 1100px; margin: 32px auto 24px; padding: 0 20px; color: var(--muted); font-size: 12px; text-align: center; }
.appfoot .sep { margin: 0 8px; opacity: 0.5; }

.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; padding: 4px 0; }
.checkbox-row input[type="checkbox"] { width: auto; }

/* Wrap tables so they scroll horizontally on narrow viewports instead of
   pushing the page wider than the screen. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; }
.table-wrap .table { min-width: 600px; border-radius: 0; }

/* ---------- mobile (<= 720px) ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px 10px; min-height: 0; gap: 8px; }
  .bar-accent { display: none; }
  .topbar .brand { font-size: 14px; }
  .topnav { margin-left: 0; width: 100%; gap: 10px 14px; flex-wrap: wrap; row-gap: 6px; }
  .topnav a { font-size: 13px; }
  .topnav .who { display: none; }

  .page { margin: 16px auto; padding: 0 12px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-head .btn, .page-head .btn-link { align-self: flex-start; }

  .card { padding: 16px; }
  .card.narrow, .login-card { margin-left: 0; margin-right: 0; max-width: none; }

  .row.two { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }

  /* form fieldsets/legends a bit tighter */
  .form-stack fieldset { padding: 10px 12px 4px; }

  /* buttons hit at least 40px tall via padding */
  .btn { padding: 11px 16px; }

  .logo-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .logo-card { padding: 10px; }

  .appfoot { padding: 0 12px; font-size: 11px; }
}

/* ---------- very narrow (<= 380px) ---------- */
@media (max-width: 380px) {
  .topnav { gap: 8px 12px; }
  .topnav a { font-size: 12px; }
}
