/* Shared look for the admin pages: Material-style layout in the old admin's
   Bootstrap colours (charcoal bar, Bootstrap blue, green/red states).
   Loaded after Bootstrap, so it restyles Bootstrap's own classes. */
:root {
  --bar: #212529;
  --primary: #0d6efd;
  --primary-soft: #e7f1ff;
  --primary-ink: #0a3d91;
  --ground: #f3f5f8;
  --surface: #ffffff;
  --ink: #212529;
  --muted: #6c757d;
  --line: #e3e7ed;
  --ok: #146c43; --ok-soft: #d1e7dd;
  --warn: #8a5a00; --warn-soft: #fff3cd;
  --bad: #dc3545; --bad-soft: #f8d7da;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .08), 0 2px 10px rgba(20, 30, 50, .06);
  --sans: "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body { background: var(--ground); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: var(--primary); }

/* ---- top bar ---------------------------------------------------------- */
.appbar { background: var(--bar); color: #fff; }
.appbar .inner { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 10px 20px; }
.appbar .brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-size: 17px; font-weight: 500; white-space: nowrap; }
.appbar .mark { background: var(--primary); color: #fff; font-weight: 700; font-size: 12px;
  letter-spacing: .08em; padding: 4px 8px; border-radius: 6px; }
.appbar .me { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13px; }
.appbar .me .who { color: #ced4da; }
.appbar .me a, .appbar .me .btn-link { color: #fff; font-size: 13px; text-decoration: none; padding: 0; }
.appbar .me a:hover, .appbar .me .btn-link:hover { text-decoration: underline; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #cfe2ff; color: var(--primary-ink);
  display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }

/* ---- side menu (Global Administrator pages) ---------------------------- */
.shell { display: flex; align-items: stretch; min-height: calc(100vh - 54px); }
.drawer { width: 260px; flex: none; background: var(--surface); border-right: 1px solid var(--line);
  padding: 12px 10px 20px; }
.drawer .nav-item-link { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-radius: 999px;
  color: #343a40; font-weight: 500; text-decoration: none; }
.drawer .nav-item-link:hover { background: #f1f3f5; }
.drawer .nav-item-link.on { background: var(--primary-soft); color: var(--primary-ink); }
.drawer .nav-item-link svg { width: 20px; height: 20px; flex: none; }
.drawer hr { border: 0; border-top: 1px solid var(--line); margin: 10px 6px; opacity: 1; }
.tree input[type=search] { border-radius: 999px; background: #f1f3f6; border-color: transparent; }
.tree input[type=search]:focus { background: #fff; border-color: var(--primary); }
.tree a { display: block; text-decoration: none; color: #343a40; border-radius: 999px; }
.tree a.co { padding: 10px 14px 2px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 500; }
.tree a.co:hover { color: var(--primary); }
.tree a.co.on { color: var(--primary-ink); }
.tree a.site { padding: 6px 14px 6px 24px; }
.tree a.site:hover { background: #f1f3f5; }
.tree a.site.on { background: var(--primary-soft); color: var(--primary-ink); font-weight: 500; }
.content { flex: 1; min-width: 0; padding: 20px 24px 32px; }
.menu-btn { display: none; align-items: center; gap: 6px; background: transparent; color: #fff;
  border: 1px solid rgba(255,255,255,.35); border-radius: 10px; padding: 5px 10px; font: inherit; font-size: 13px; }
@media (max-width: 860px) {
  .shell { display: block; }
  /* The side menu (and the company list) folds away behind the Menu button. */
  .menu-btn { display: inline-flex; }
  .drawer { display: none; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .drawer.open { display: block; }
  .content { padding: 16px; }
}

/* ---- phones ------------------------------------------------------------- */
.seat-side { width: 100%; }
@media (min-width: 992px) { .seat-side { width: 320px; } .seat-side-wide { width: 360px; } }
@media (max-width: 575px) {
  .hide-phone { display: none; }
  .appbar .inner { padding: 8px 12px; gap: 8px 12px; }
  .appbar .brand { font-size: 15px; }
  .appbar .me { gap: 10px; }
  .appbar .me .who { display: none; }
  .content { padding: 12px; }
  .box, .card-m { padding: 14px; }
  .page-title { font-size: 19px; }
  .tiles { grid-template-columns: 1fr; }
  /* Long tables keep the columns that matter on a small screen. */
  table.ph-logs tr > :nth-child(n+4),
  table.ph-audit tr > :nth-child(5), table.ph-audit tr > :nth-child(6),
  table.ph-seats tr > :nth-child(3),
  table.ph-seats-admin tr > :nth-child(3), table.ph-seats-admin tr > :nth-child(5),
  table.ph-customers tr > :nth-child(4) { display: none; }
  form.lc-filters { flex-direction: column; align-items: stretch; }
  form.lc-filters .form-control, form.lc-filters .form-select { width: 100%; max-width: 100%; min-width: 0 !important; }
  /* The three 24-hour counters sit side by side instead of filling a screen. */
  div.lc-day { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  div.lc-day .box { padding: 10px; }
  div.lc-day h4 { font-size: 12px; margin-bottom: 4px; }
  div.lc-day .stat { font-size: 22px; }
  /* Long emails wrap so the Access column stays on screen. */
  table.ph-seats td:first-child, table.ph-seats-admin td:first-child { max-width: 170px; overflow-wrap: anywhere; }
}
.lc-filters .form-select { max-width: 100%; }
/* Fingers need bigger targets than mouse pointers. */
@media (pointer: coarse) {
  .btn-sm { min-height: 36px; }
  table.sa th .sort-btn { padding: 6px 0; }
  .tabs-m a { padding: 9px 16px; }
}

/* ---- surfaces ---------------------------------------------------------- */
.box, .card-m { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; }
.box h4 { margin: 0 0 10px; font-size: 15px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--ink); }
.page-title { font-size: 22px; font-weight: 500; margin: 0; }
.page-sub { color: var(--muted); font-size: 13px; }
.stat { font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat small { font-size: 15px; color: var(--muted); font-weight: 400; }
.meter-m { height: 8px; background: #e3ebf7; border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter-m i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.meter-m.full i { background: var(--bad); }

/* ---- buttons: pill shapes, Bootstrap colours ---------------------------- */
.btn { border-radius: 999px; font-weight: 500; padding-inline: 16px; }
.btn-sm { padding-inline: 12px; }
.btn-light.border { background: var(--surface); border-color: #ced4da !important; color: #343a40; }
.btn-light.border:hover { background: #f1f3f5; }
.btn-light.border.text-danger { border-color: #f1aeb5 !important; }
.form-control, .form-select { border-radius: 10px; }
.input-group > .pw-eye { border-radius: 0 10px 10px 0; padding-inline: 12px; display: inline-flex; align-items: center; color: var(--muted); }
.input-group > .pw-eye:hover { color: var(--ink); }
.form-control-sm, .form-select-sm { border-radius: 8px; }
.alert { border-radius: 12px; border: 0; }
.modal-content { border-radius: 18px; border: 0; }

/* ---- tables: compact rows (sites can hold 70+ seats) -------------------- */
table.sa { margin: 0; }
table.sa th { font-size: 12px; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line);
  padding: 8px 10px; background: transparent; }
table.sa td { vertical-align: middle; padding: 3px 10px; border-color: #eef1f5; line-height: 1.25; }
table.sa tr.sel td { background: #f1f7ff; }
table.sa a.row-link { color: inherit; text-decoration: none; display: block; }
table.sa a.row-link b { font-weight: 500; }
table.sa a.row-link small { color: var(--muted); font-size: 12px; }
table.sa .pill { padding: 2px 9px; font-size: 11.5px; }

table.sa th .sort-btn { all: unset; cursor: pointer; font: inherit; color: inherit; }
table.sa th .sort-btn:hover { color: var(--primary); }
table.sa th .sort-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
table.sa th .sort-btn::after { content: " \2195"; opacity: .35; }
table.sa th .sort-btn[data-dir="asc"]::after { content: " \25B2"; opacity: 1; color: var(--primary); }
table.sa th .sort-btn[data-dir="desc"]::after { content: " \25BC"; opacity: 1; color: var(--primary); }

.mod-table tr.own td { background: #fff8e6; }
.mod-table .btn-group .btn { padding: 1px 10px; font-size: 12px; }

/* ---- status badges ---------------------------------------------------- */
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.rw { background: var(--ok-soft); color: var(--ok); }
.ro { background: #e9ecef; color: #495057; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); margin-left: 4px; }

/* ---- tabs as pills (customer pages) ------------------------------------ */
.tabs-m { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tabs-m a { padding: 7px 16px; border-radius: 999px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs-m a:hover { background: #e9ecef; }
.tabs-m a.on { background: var(--primary-soft); color: var(--primary-ink); }

/* ---- start page tiles ---------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
a.tile { display: flex; flex-direction: column; gap: 6px; background: var(--surface); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; text-decoration: none;
  border: 1px solid transparent; transition: border-color .12s, transform .12s; }
a.tile:hover, a.tile:focus-visible { border-color: var(--primary); transform: translateY(-1px); outline: 0; }
.tile .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft);
  color: var(--primary-ink); display: grid; place-items: center; }
.tile .ico svg { width: 22px; height: 22px; }
.tile h2 { font-size: 16px; font-weight: 500; margin: 6px 0 0; }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }
.tile .fig { margin-top: auto; padding-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.tile .fig b { font-weight: 500; }
.tile .fig .alert-fig { color: var(--bad); font-weight: 500; }
@media (prefers-reduced-motion: reduce) { a.tile { transition: none; } a.tile:hover { transform: none; } }

/* ---- log tables (licence checks, audit log) -------------------------------- */
.lc-info { background: var(--primary-soft); color: var(--primary-ink); }
.lc-warn { background: var(--warn-soft); color: var(--warn); }
.lc-bad { background: var(--bad-soft); color: #a52834; }
.lc-day { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lc-day a { text-decoration: none; color: inherit; }
.lc-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lc-filters .form-control, .lc-filters .form-select { width: auto; }
.lc-table td { font-size: 13px; }
.lc-when { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lc-dim { color: var(--muted); font-size: 12px; }
.lc-mono { font-family: Consolas, "Roboto Mono", monospace; font-size: 12px; }
@media (max-width: 640px) { .lc-day { grid-template-columns: 1fr; } }

/* ---- change feed --------------------------------------------------------- */
.feed > div { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start;
  padding: 8px 0; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.feed > div:last-child { border-bottom: 0; }
.feed .avatar { width: 34px; height: 34px; }
.feed .meta { color: var(--muted); font-size: 12px; display: block; }
.feed .det { color: var(--muted); }

@media print {
  .appbar, .drawer, .no-print { display: none !important; }
  .box { box-shadow: none; border: 1px solid #ccc; }
}
