/* PVN Voice portal.
 *
 * Palette, typography and radii are taken from pvnvoice.com so the billing
 * portal reads as part of the same product rather than a bolted-on tool.
 *
 * Two shells share this sheet:
 *   body.portal — customer-facing and login. Branded.
 *   body.admin  — the operator's console. Deliberately plainer and denser;
 *                 legibility of numbers beats decoration when someone is
 *                 reconciling a disputed invoice.
 *
 * Fonts are self-hosted. The app sends a strict CSP whose style-src is
 * 'self' only, so a <link> to fonts.googleapis.com would be blocked outright.
 */

/* ---- fonts --------------------------------------------------------------
   Variable fonts: one file per family covers every weight used. */

@font-face {
  font-family: 'Inter';
  src: url('/static/fonts/inter-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'Montserrat';
  src: url('/static/fonts/montserrat-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
  /* Brand ramp, sampled from pvnvoice.com */
  --navy-900: #1e365c;
  --navy-800: #21406f;
  --navy-700: #254b88;
  --brand:    #2e5eaa;
  --brand-600:#4177c3;
  --brand-400:#6595d5;
  --brand-200:#c1d4ef;
  --brand-100:#dde7f5;
  --brand-50: #f0f5fc;

  --bg: var(--brand-50);
  --panel: #ffffff;
  --ink: #16233a;
  --muted: #5b6b82;
  --line: #dde7f5;
  --accent: var(--brand);

  --ok: #1a7a52;
  --ok-bg: #e6f7ef;
  --ok-line: #c3ebd7;
  --warn: #8a5a00;
  --warn-bg: #fdf3e2;
  --bad: #b3261e;
  --bad-bg: #fdeceb;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(30, 54, 92, .06), 0 6px 20px rgba(30, 54, 92, .05);

  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'Montserrat', 'Inter', system-ui, sans-serif;
}

/* The console keeps the type and the brand blue, but drops the tint, the
   shadows and the generous spacing. */
body.admin {
  --bg: #f6f7f9;
  --line: #dde1e6;
  --radius: 8px;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* Tabular figures everywhere money or duration appears, so columns line up
   and a misplaced digit is visible at a glance. */
.num, td.num, th.num, .money, .big {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--navy-700); }

/* ---- chrome ---- */

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
body.portal .topbar { box-shadow: 0 1px 3px rgba(30, 54, 92, .06); }

.brand {
  display: flex; align-items: center;
  font-family: var(--font-head);
  font-weight: 700; text-decoration: none; color: var(--navy-900);
  padding: 12px 0; letter-spacing: -.01em;
}
.brand img { display: block; height: 34px; width: auto; }
/* The console shows the wordmark small; the customer shell shows it full size. */
body.admin .brand img { height: 26px; }

.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 16px 13px; text-decoration: none; color: var(--muted);
  border-bottom: 2px solid transparent; font-weight: 500;
  transition: color .12s ease, border-color .12s ease;
}
.topbar nav a:hover { color: var(--navy-800); }
.topbar nav a.on { color: var(--navy-800); border-bottom-color: var(--brand); font-weight: 600; }

.logout { display: flex; align-items: center; gap: 12px; }
.logout .who { color: var(--muted); font-size: 13px; }
.logout button {
  background: none; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 12px; cursor: pointer; color: var(--muted); font: inherit; font-size: 13px;
}
.logout button:hover { border-color: var(--brand-400); color: var(--navy-800); }

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
body.admin main { padding: 24px 20px 64px; }

.foot {
  max-width: 1200px; margin: 0 auto; padding: 0 24px 36px;
  display: flex; justify-content: space-between; gap: 16px;
  color: var(--muted); font-size: 13px; flex-wrap: wrap;
}

h1 {
  font-family: var(--font-head);
  font-size: 25px; font-weight: 700; margin: 0 0 6px;
  letter-spacing: -.015em; color: var(--navy-900);
}
h2 {
  font-family: var(--font-head);
  font-size: 16px; font-weight: 700; margin: 30px 0 12px; color: var(--navy-800);
}
body.admin h1 { font-size: 22px; }
.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ---- panels & cards ---- */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card .label {
  color: var(--muted); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.card .big {
  font-family: var(--font-head);
  font-size: 27px; font-weight: 700; margin-top: 8px; text-align: left;
  color: var(--navy-900); letter-spacing: -.02em;
}
.card .note { color: var(--muted); font-size: 12px; margin-top: 5px; }

.big.ok  { color: var(--ok); }
.big.bad { color: var(--bad); }

/* The balance card leads the customer dashboard, so it carries the brand. */
body.portal .cards .card:first-child {
  background: linear-gradient(135deg, var(--navy-800), var(--brand));
  border-color: transparent;
}
body.portal .cards .card:first-child .label { color: var(--brand-200); }
body.portal .cards .card:first-child .big { color: #fff; }
body.portal .cards .card:first-child .note { color: var(--brand-200); }
body.portal .cards .card:first-child .big.ok,
body.portal .cards .card:first-child .big.bad { color: #fff; }

/* ---- tables ---- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
body.admin th, body.admin td { padding: 8px 10px; }
th {
  color: var(--muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em;
  background: var(--brand-50);
}
body.admin th { background: transparent; }
tbody tr:hover { background: var(--brand-50); }
td.mono, th.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.empty { color: var(--muted); padding: 28px; text-align: center; }

/* ---- badges ---- */

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 600;
}
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad); }
.badge-mute { background: var(--brand-100); color: var(--muted); }

/* ---- forms ---- */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(46, 94, 170, .15);
}
.field { margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 140px; margin-bottom: 0; }

button.primary, .btn {
  background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-block; transition: background .12s ease;
}
button.primary:hover, .btn:hover { background: var(--navy-700); color: #fff; }
button.secondary {
  background: #fff; color: var(--navy-800); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 18px; font: inherit; font-weight: 500; cursor: pointer;
}
button.secondary:hover { border-color: var(--brand-400); }
button.danger { background: var(--bad); color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; }
button.link { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }

/* ---- messages ---- */

.flash { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; }
.flash-ok    { background: var(--ok-bg);  color: var(--ok);  border: 1px solid var(--ok-line); }
.flash-error { background: var(--bad-bg); color: var(--bad); border: 1px solid #f3c9c6; }
.notice { background: var(--warn-bg); border: 1px solid #f0dcb4; color: var(--warn); padding: 13px 15px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.notice.info { background: var(--brand-50); border-color: var(--brand-200); color: var(--navy-700); }

/* ---- auth ---- */
/*
 * Sign-in is the first thing a customer sees, so it carries the brand fully:
 * the wordmark above a single card on the navy gradient.
 */

body.auth-page {
  background: linear-gradient(160deg, var(--navy-900) 0%, var(--brand) 100%);
  min-height: 100vh;
}
body.auth-page main { padding-top: 0; }
.auth { max-width: 400px; margin: 7vh auto; }
.auth .authmark { text-align: center; margin-bottom: 22px; }
.auth .authmark img { height: 44px; width: auto; }
.auth .panel {
  padding: 28px;
  border: none;
  box-shadow: 0 10px 40px rgba(15, 30, 55, .25);
}
.auth h1 { margin-bottom: 20px; font-size: 21px; }
.auth .btn, .auth button.primary { width: 100%; text-align: center; }
.auth-foot { text-align: center; color: var(--brand-200); font-size: 12.5px; margin-top: 20px; }
.auth-foot a { color: #fff; }

/* ---- misc ---- */

.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 14px; }
.pager a { padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; background: #fff; }
.pager a:hover { border-color: var(--brand-400); }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.right { text-align: right; }
.secret {
  font-family: ui-monospace, Menlo, Consolas, monospace; background: #fff;
  border: 1px dashed var(--warn); padding: 12px; border-radius: var(--radius-sm);
  font-size: 15px; word-break: break-all;
}

@media (max-width: 640px) {
  .topbar { gap: 10px; padding: 0 16px; }
  .topbar nav a { padding: 12px 10px; }
  main { padding: 20px 16px 48px; }
  .logout .who { display: none; }
}
