/*
 * assets/css/style.css - cloudtelephony.co.za (public pages + client portal).
 * CT CI v1.0 (portal/brand/CT_CI.md): light theme, CT Navy headings, CT Blue buttons,
 * CT Ice sections, Inter. Mobile first; tables scroll inside their own box so the page
 * never scrolls sideways. No inline styles anywhere (strict CSP).
 */
:root {
  --ct-navy: #0F2F5C;
  --ct-blue: #1E6FD9;
  --ct-sky: #4C9BFF;
  --ct-light-sky: #7FB6FF;
  --ct-ice: #E8F1FF;
  --ct-night: #151821;
  --text: #1F2330;
  --muted: #6B7080;
  --line: #D9E2F0;
  --bg: #F5F8FD;
  --white: #FFFFFF;
  --ok: #1E9E5A;
  --warn: #E0A100;
  --bad: #D93025;
  --radius: 10px;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--white); color: var(--text);
  font: 400 16px/1.55 Inter, "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}
body.portal { background: var(--bg); }
a { color: var(--ct-blue); }
a:hover { color: var(--ct-navy); }
h1, h2, h3 { color: var(--ct-navy); line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 1.25rem 0 1rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 .75rem; }
img { max-width: 100%; height: auto; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.wrap { overflow-wrap: anywhere; }
.inline { display: inline; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--white); padding: 6px 10px; z-index: 10; }
/* Honeypot: off-screen for people, still in the form for bots. */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Public header / footer ---------- */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.site-header-inner, .wrap-inner, .site-footer-inner { max-width: 1120px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.site-header-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px 20px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 44px; width: auto; display: block; }
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 18px; }
.site-nav a:not(.btn) { color: var(--ct-navy); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 0; border-bottom: 2px solid transparent; }
.site-nav a:not(.btn):hover, .site-nav a.active { border-bottom-color: var(--ct-blue); }
.site-footer { background: var(--ct-night); color: #C9D3E6; margin-top: 0; }
.site-footer-inner { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 18px; padding-top: 32px; padding-bottom: 20px; }
.site-footer img { height: 40px; width: auto; }
.muted-dark { color: #9AA6BD; font-size: .9rem; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 24px; }
.footer-nav a { color: #E6ECF7; text-decoration: none; font-size: .92rem; }
.footer-nav a:hover { color: var(--ct-light-sky); }
.site-footer-legal { border-top: 1px solid #2A3042; color: #8590A6; font-size: .8rem; padding: 12px var(--gutter); text-align: center; }

/* ---------- Public sections ---------- */
.hero { background: linear-gradient(180deg, var(--ct-ice) 0%, var(--white) 100%); }
.hero-inner { display: grid; grid-template-columns: 1fr; gap: 24px; padding-top: 40px; padding-bottom: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0 0 .75rem; letter-spacing: -.01em; }
.lead { font-size: 1.12rem; color: #3A4055; max-width: 40rem; }
.hero-art { display: none; text-align: center; }
.hero-art img { width: 260px; }
.section { padding: 40px 0; }
.section-ice { background: var(--ct-ice); }
.page-head { background: var(--ct-ice); padding: 28px 0 20px; }
.page-head h1 { margin-top: 0; }
.features { display: grid; grid-template-columns: 1fr; gap: 16px; }
.feature { background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--ct-blue); border-radius: var(--radius); padding: 18px; }
.feature h2 { font-size: 1.1rem; }
.feature p { margin: 0; }
.feature-list { display: grid; gap: 28px; }
.feature-row h2 { font-size: 1.3rem; }
.split { display: grid; grid-template-columns: 1fr; gap: 24px; align-items: start; }
.cta-box { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.cta-line { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.cta-line p { margin: 0; }
.ticks { list-style: none; padding: 0; margin: 0 0 1rem; }
.ticks li { position: relative; padding-left: 1.6rem; margin: .45rem 0; }
.ticks li::before { content: ""; position: absolute; left: .2rem; top: .45rem; width: .55rem; height: .3rem; border-left: 2px solid var(--ct-blue); border-bottom: 2px solid var(--ct-blue); transform: rotate(-45deg); }
.prose { max-width: 46rem; }
.prose h2 { margin-top: 1.6rem; }
.contact-aside { padding: 4px 0; }
@media (min-width: 760px) {
  .hero-inner { grid-template-columns: 3fr 2fr; padding-top: 64px; padding-bottom: 64px; }
  .hero-art { display: block; }
  .features { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr 1fr; }
  .split-form { grid-template-columns: 3fr 2fr; }
}
@media (min-width: 1000px) { .features { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Portal header ---------- */
.portal-header { background: var(--white); border-bottom: 1px solid var(--line); }
.portal-header-inner { padding: 10px var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.portal-header .brand img { height: 40px; }
.brand-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ct-blue); border: 1px solid var(--ct-sky); border-radius: 999px; padding: 2px 8px; }
.portal-user { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--muted); }
.portal-user-name { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-nav { padding: 0 calc(var(--gutter) - 10px); display: flex; gap: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.portal-nav a { color: var(--ct-navy); text-decoration: none; padding: 10px; font-size: .93rem; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.portal-nav a:hover { color: var(--ct-blue); }
.portal-nav a.active { color: var(--ct-blue); border-bottom-color: var(--ct-blue); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--gutter) 24px; }
.portal-footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-top: 12px; text-align: center; }

/* ---------- Cards, tiles ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card p:first-child { margin-top: 0; }
.card-narrow { max-width: 480px; }
.card-unavailable { border-left: 4px solid var(--warn); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--ct-blue); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
a.tile:hover { border-color: var(--ct-sky); }
.tile-label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile-value { font-size: 1.6rem; font-weight: 700; color: var(--ct-navy); }
.tile-value small { font-size: .9rem; color: var(--muted); font-weight: 600; }
.tile-sub { font-size: .82rem; color: var(--muted); }
.h-small { font-size: 1rem; margin: 18px 0 6px; }

/* ---------- Prepaid balance ---------- */
.balance-banner { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; background: var(--white); border: 1px solid var(--line); border-left: 6px solid var(--ok); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; }
.balance-banner > div:first-child { display: flex; flex-direction: column; }
.balance-value { font-size: 1.9rem; font-weight: 700; color: var(--ct-navy); }
.balance-note { font-size: .9rem; color: var(--muted); }
.balance-banner.is-low { border-left-color: var(--warn); }
.balance-banner.is-blocked { border-left-color: var(--bad); background: #FDECEA; }
.balance-banner.is-blocked .balance-value, .balance-value.is-blocked { color: var(--bad); }
.balance-banner.is-blocked .balance-note { color: #8C1D14; font-weight: 600; }
td.neg { color: var(--bad); }
td.pos { color: var(--ok); }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid var(--ct-ice); border-top-color: var(--ct-blue); border-radius: 50%; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.js [data-nojs] { display: none; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--ct-ice); color: var(--ct-navy); font-weight: 600; white-space: nowrap; }
tbody tr:nth-child(even) td { background: #FAFCFF; }
.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
table.kv th { width: 34%; color: var(--ct-navy); font-weight: 600; background: none; }
.actions-cell { min-width: 11rem; }
.state-cell { min-width: 8rem; }
.rings-to { min-width: 15rem; }
.route-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.route-form select { padding: 6px 8px; font-size: .88rem; max-width: 22rem; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: auto; max-height: 240px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: Inter, Arial, sans-serif; }
.chart .bar-in { fill: var(--ct-blue); }
.chart .bar-out { fill: var(--ct-sky); opacity: .75; }
.legend { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: 0; }
.key-in { background: var(--ct-blue); }
.key-out { background: var(--ct-sky); }

/* ---------- Forms and buttons ---------- */
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-weight: 600; font-size: .9rem; color: var(--ct-navy); margin-top: 6px; }
.form label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 9px 10px; border: 1px solid #B9C6DB; border-radius: 8px; background: var(--white); color: var(--text);
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--ct-sky); outline-offset: 1px; }
.form .btn { margin-top: 10px; align-self: flex-start; }
textarea { resize: vertical; }
select:disabled, input:disabled { background: var(--bg); color: var(--muted); }
.line-row { display: flex; flex-direction: column; gap: 4px; }
.line-row[hidden] { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; font-weight: 600; color: var(--ct-navy); gap: 3px; min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.filter-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--ct-blue); background: var(--white); color: var(--ct-blue); white-space: nowrap; }
.btn:hover { background: var(--ct-ice); color: var(--ct-blue); }
.btn-primary { background: var(--ct-blue); color: var(--white); }
.btn-primary:hover { background: var(--ct-navy); border-color: var(--ct-navy); color: var(--white); }
.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: #FDECEA; color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Messages and badges ---------- */
.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; border: 1px solid; }
.flash-ok { background: #E9F7EF; border-color: #A6DDBE; color: #14623A; }
.flash-error { background: #FDECEA; border-color: #F3B3AC; color: #8C1D14; }
.wrap-inner > .flash, .wrap-inner > .devnote { margin-top: 14px; }
.devnote { background: #FFF6DB; border: 1px dashed var(--warn); color: #6B4F00; padding: 6px 10px; border-radius: 8px; font-size: .85rem; margin: 12px 0 0; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: #E3F5EB; color: var(--ok); }
.badge-warn { background: #FFF4D6; color: #8A6400; }
.badge-bad { background: #FDE3E0; color: var(--bad); }
.badge-muted { background: #ECEFF4; color: var(--muted); }

/* ---------- Sign-in, 2FA ---------- */
.qr { padding: 12px; background: var(--white); display: inline-block; border: 1px solid var(--line); border-radius: 8px; min-height: 226px; min-width: 226px; }
.codes { columns: 2; font-size: 1.05rem; padding-left: 1.6em; }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 14px; counter-reset: st; }
.steps li { counter-increment: st; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 3px 10px; }
.steps li::before { content: counter(st) ". "; }
.steps li.current { background: var(--ct-ice); color: var(--ct-blue); }
.help-steps li { margin: .4rem 0; }

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .brand img, .portal-header .brand img { height: 36px; }
  .site-nav { gap: 4px 14px; justify-content: center; }
  .site-header-inner, .portal-header-inner { justify-content: center; }
  .portal-nav { flex-wrap: wrap; justify-content: center; overflow-x: visible; }
  .filters label { max-width: none; }
  .table-wrap th, .table-wrap td { white-space: nowrap; }
  .table-wrap td.wrap { white-space: normal; min-width: 10rem; }
  .rings-to { min-width: 12rem; }
  .route-form select { max-width: 11rem; }
  .tile-value { font-size: 1.35rem; }
}

/* ---------- Sign-up (spec section 5) ---------- */
.signup-form fieldset { border: 1px solid var(--line); margin: 0 0 16px; }
.signup-form legend { font-weight: 700; color: var(--ct-navy); padding: 0 6px; font-size: 1.05rem; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
.form-grid > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span-all { grid-column: 1 / -1; } }
.field-error { color: var(--bad); font-size: .85rem; margin: 2px 0 0; }
.number-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; }
.number-pick { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.ext-list { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
@media (min-width: 700px) { .ext-list { grid-template-columns: 1fr 1fr; } }
.ext-row { display: flex; flex-direction: column; gap: 4px; }

/* ---------- Manual set-up (spec section 6) ---------- */
.sip-secret { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.script-box { background: var(--ct-ice); padding: 10px 12px; border-radius: 6px; font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.sip-secret .secret { background: var(--ct-ice); padding: 3px 8px; border-radius: 6px; font-size: 1rem; overflow-wrap: anywhere; }

/* ---------- Signed-out portal pages (login, invite, 2FA, recovery): one centred block ---------- */
.auth-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 200px); }
.auth-center > * { width: 100%; max-width: 480px; }
.auth-center > h1 { text-align: center; }

/* ---------- Buy numbers (portal) ---------- */
.buy-pick { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 16px; padding: 12px; }
.buy-pick legend { font-weight: 700; color: var(--ct-navy); padding: 0 6px; }
