:root {
  /* Texas National Title brand */
  --brand: #00488d;        /* PMS 2146 primary blue */
  --brand-dark: #0f294b;   /* PMS 2767 deep navy */
  --brand-mid: #298dcc;    /* PMS 2143 */
  --brand-light: #77c1eb;  /* PMS 2141 */
  --brand-soft: #e8f1fa;
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #122339;
  --muted: #5a6b80;
  --line: #dfe7f0;
  --good: #1f9d57;
  --bad: #d23b3b;
  --shadow: 0 1px 3px rgba(0, 72, 141, 0.08), 0 8px 22px rgba(0, 72, 141, 0.08);
  --radius: 14px;
  --title-font: "Bebas Neue", "Arial Narrow", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; font-weight: 650; flex: 1; }
.topbar .back, .topbar .logout {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 15px;
  cursor: pointer;
}
.topbar .back:active, .topbar .logout:active { background: rgba(255,255,255,0.28); }
.topbar .who { font-size: 13px; opacity: 0.9; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Login */
.login-card {
  max-width: 380px;
  margin: 10vh auto 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.login-card h2 { font-size: 22px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
select, input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="tel"] {
  width: 100%;
  padding: 13px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--ink);
}
select:focus, input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 650;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
}
.btn:active { background: var(--brand-dark); }
.btn.secondary { background: #eef2f7; color: var(--ink); }
.btn.small { width: auto; padding: 10px 14px; font-size: 14px; margin-top: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }

.msg { margin-top: 14px; font-size: 14px; min-height: 20px; }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--good); }

/* Home menu */
.menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 8px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.05s ease;
}
.tile:active { transform: scale(0.99); }
.tile .icon { font-size: 26px; }
.tile .t-title { font-size: 18px; font-weight: 700; margin: 10px 0 4px; }
.tile .t-desc { font-size: 13.5px; color: var(--muted); }
.tile.admin { border-color: #d9c8a3; background: #fcf8ee; }

/* Report controls */
.controls {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.controls .row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.controls .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.controls .actions .btn { width: auto; margin-top: 0; }

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.kpi .k-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.kpi .k-value { font-size: 24px; font-weight: 750; margin-top: 4px; }

/* Results */
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.results-head .count { color: var(--muted); font-size: 14px; }
.export-buttons { display: flex; gap: 8px; }

.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data thead th {
  position: sticky; top: 0;
  background: #f1f5fa;
  text-align: left;
  padding: 11px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data tbody td { padding: 11px 12px; border-bottom: 1px solid #f0f3f7; white-space: nowrap; }
table.data tbody tr:nth-child(even) { background: #fafcfe; }
td.num, th.num { text-align: right; }

.spinner { text-align: center; color: var(--muted); padding: 30px; font-size: 15px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 11px 14px; font-size: 14px; cursor: pointer; color: var(--ink); }
.seg button.on { background: var(--brand); color: #fff; }

/* Admin roster */
.roster { width: 100%; border-collapse: collapse; font-size: 14px; }
.roster th, .roster td { padding: 10px 12px; border-bottom: 1px solid #f0f3f7; text-align: left; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.pill.on { background: #e3f6ea; color: var(--good); }
.pill.off { background: #f1f1f1; color: var(--muted); }
.pill.adm { background: #fcf2d9; color: #9a7a16; }

/* ===== Texas National Title brand layer ===== */
.topbar {
  background: linear-gradient(100deg, var(--brand) 0%, var(--brand-dark) 100%);
}
.topbar .logo { height: 30px; width: auto; display: block; }
.topbar h1 {
  font-family: var(--title-font);
  font-weight: 400;
  letter-spacing: 0.6px;
  font-size: 24px;
}

/* Login screen branding */
.login-card { text-align: center; padding-top: 34px; }
.login-logo { width: 220px; max-width: 80%; margin: 0 auto 10px; display: block; }
.login-tagline {
  color: var(--brand);
  font-style: italic;
  font-size: 13.5px;
  margin-bottom: 18px;
}
.login-card h2 { font-family: var(--title-font); font-weight: 400; letter-spacing: 0.5px; font-size: 26px; color: var(--brand-dark); }
.login-card label, .login-card .btn { text-align: left; }
.login-card .btn { background: var(--brand); }
.login-card .btn:active { background: var(--brand-dark); }
.login-foot { margin-top: 16px; font-size: 11px; color: var(--muted); letter-spacing: 0.3px; }

/* Section headings */
.home-section-title {
  font-family: var(--title-font);
  font-weight: 400;
  letter-spacing: 0.6px;
  font-size: 22px;
  color: var(--brand-dark);
  margin: 22px 2px 12px;
}

/* Dashboard */
.dash-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.kpi { border-top: 3px solid var(--brand); }
.kpi .k-label { color: var(--brand); }
.kpi .k-value { font-family: var(--title-font); font-weight: 400; letter-spacing: 0.5px; color: var(--brand-dark); font-size: 34px; line-height: 1.05; }
.kpi.accent { border-top-color: var(--brand-mid); }
.kpi.accent .k-label { color: var(--brand-mid); }

.dash-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--gap); margin-top: var(--gap); }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.chart-card h3 { font-family: var(--title-font); font-weight: 400; letter-spacing: 0.5px; font-size: 18px; color: var(--brand-dark); margin-bottom: 12px; }
.chart-card canvas { width: 100% !important; max-height: 300px; }

/* Report tiles, on-brand */
.tile { border-top: 3px solid var(--brand-light); }
.tile .icon { color: var(--brand); }
.tile .t-title { font-family: var(--title-font); font-weight: 400; letter-spacing: 0.4px; font-size: 19px; color: var(--brand-dark); }
.tile.admin { border-top-color: #d9c8a3; }

/* KPI value brand on report screens too */
#agent-kpis .k-value { font-family: var(--title-font); color: var(--brand-dark); }

/* Assigned-rep banner */
.rep-banner {
  background: var(--brand-soft);
  border-left: 4px solid var(--brand);
  color: var(--brand-dark);
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14.5px;
}

@media (max-width: 720px) {
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .topbar h1 { font-size: 19px; }
  .topbar .who { display: none; }
  .topbar .logo { height: 24px; }
  .kpi .k-value { font-size: 26px; }
}
