:root {
  --tf-bg: #f8fafc;
  --tf-surface: #ffffff;
  --tf-surface-muted: #f1f5f9;
  --tf-border: #e2e8f0;
  --tf-border-strong: #cbd5e1;
  --tf-text: #0f172a;
  --tf-muted: #64748b;
  --tf-primary: #111827;
  --tf-primary-deep: #020617;
  --tf-blue: #2563eb;
  --tf-blue-soft: #dbeafe;
  --tf-green: #16a34a;
  --tf-green-soft: #dcfce7;
  --tf-amber: #d97706;
  --tf-amber-soft: #fef3c7;
  --tf-red: #dc2626;
  --tf-red-soft: #fee2e2;
  --tf-radius-sm: 10px;
  --tf-radius: 14px;
  --tf-radius-lg: 20px;
  --tf-radius-xl: 24px;
  --tf-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
}

* { box-sizing: border-box; }

html { background: var(--tf-bg); }

body {
  min-height: 100vh !important;
  margin: 0 !important;
  padding: 0 !important;
  color: var(--tf-text) !important;
  font-family: "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif !important;
  background:
    radial-gradient(circle at 50% -10%, #e0f2fe 0, rgba(224, 242, 254, 0) 36rem),
    var(--tf-bg) !important;
}

a { color: var(--tf-blue); }

.shell,
.wrap {
  width: min(1480px, 100%) !important;
  margin: 0 auto !important;
  padding: 24px !important;
}

.halo { display: none !important; }

.card,
.panel,
.explain-card,
.router,
.tip {
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  background: var(--tf-surface) !important;
  box-shadow: var(--tf-shadow) !important;
  backdrop-filter: none !important;
}

.card { overflow: hidden; }
.inner { padding: 24px !important; }

.eyebrow {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: var(--tf-muted) !important;
  background: transparent !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: .13em !important;
  text-transform: uppercase !important;
}

.eyebrow::before { display: none !important; }

h1 {
  margin: 10px 0 8px !important;
  color: var(--tf-text) !important;
  font-size: clamp(28px, 4vw, 38px) !important;
  line-height: 1.05 !important;
  letter-spacing: -.045em !important;
  text-transform: uppercase;
}

h2, h3 { color: var(--tf-text); }

.lead,
.subtle,
.sub,
.foot,
.note,
.status {
  color: var(--tf-muted) !important;
}

.lead {
  max-width: 72ch !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
}

.auth,
.controls,
.login {
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-lg);
  background: var(--tf-surface-muted);
  padding: 16px;
}

.controls {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important;
  gap: 12px !important;
  align-items: end !important;
}

.controls.actions {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

.controls.actions .btn { flex: 0 0 auto; }

input[type="date"],
input[type="month"] { cursor: pointer; }

.label,
label {
  color: #475569 !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase !important;
}

input,
select,
textarea {
  min-height: 44px !important;
  padding: 11px 13px !important;
  border: 1px solid var(--tf-border-strong) !important;
  border-radius: var(--tf-radius) !important;
  color: var(--tf-text) !important;
  background: var(--tf-surface) !important;
  box-shadow: none !important;
  font: inherit !important;
}

input::placeholder,
textarea::placeholder { color: #94a3b8 !important; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--tf-blue) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13) !important;
}

.btn,
button,
.supportLink {
  min-height: 44px;
  border: 1px solid transparent !important;
  border-radius: var(--tf-radius) !important;
  color: #fff !important;
  background: var(--tf-primary) !important;
  box-shadow: none !important;
  font-weight: 800 !important;
  text-decoration: none;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

.btn:hover,
button:hover { transform: translateY(-1px); }

.btn-primary,
.btn.primary { background: var(--tf-blue) !important; }

.btn-soft,
.btn.secondary,
.btn2,
.tab:not(.active) {
  border-color: var(--tf-border) !important;
  color: #334155 !important;
  background: var(--tf-surface) !important;
}

.authLine,
.status,
.network-pulse {
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius) !important;
  color: var(--tf-muted) !important;
  background: var(--tf-surface-muted) !important;
}

.msg,
.message,
.error {
  border-radius: var(--tf-radius) !important;
  line-height: 1.5;
}

.msg.ok,
.message.ok {
  border: 1px solid #86efac !important;
  color: #166534 !important;
  background: var(--tf-green-soft) !important;
}

.msg.err,
.message.err,
.error.show {
  border: 1px solid #fecaca !important;
  color: #991b1b !important;
  background: var(--tf-red-soft) !important;
}

.summary,
.metrics {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)) !important;
  gap: 12px !important;
}

.metric {
  min-height: 112px !important;
  padding: 16px !important;
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  color: var(--tf-text) !important;
  background: var(--tf-surface) !important;
  box-shadow: none !important;
}

.metric::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  margin-bottom: 14px;
  border-radius: 50%;
  background: var(--tf-blue);
}

.metric:nth-child(3n+2)::before { background: var(--tf-green); }
.metric:nth-child(3n)::before { background: var(--tf-amber); }

.metric b {
  display: block !important;
  margin-bottom: 8px !important;
  color: var(--tf-muted) !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase !important;
}

.metric span,
.metric strong {
  color: var(--tf-text) !important;
  font-size: clamp(22px, 2.5vw, 28px) !important;
  font-weight: 800 !important;
  letter-spacing: -.035em !important;
}

.metric.feature,
.metric.agent-hero {
  border-color: #bfdbfe !important;
  background: linear-gradient(145deg, #fff, #eff6ff) !important;
}

.tabs {
  display: flex !important;
  gap: 8px !important;
  overflow-x: auto;
  padding: 5px !important;
  border: 1px solid var(--tf-border) !important;
  border-radius: 16px !important;
  background: var(--tf-surface-muted) !important;
  scrollbar-width: thin;
}

.tab {
  flex: 0 0 auto;
  min-height: 38px !important;
  padding: 9px 13px !important;
  border-radius: 11px !important;
  white-space: nowrap;
}

.tab.active {
  color: #fff !important;
  background: var(--tf-primary) !important;
}

.table-wrap {
  margin-top: 18px !important;
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  background: var(--tf-surface) !important;
  box-shadow: none !important;
  overflow: auto !important;
}

table { border-collapse: collapse !important; }

thead th {
  color: #475569 !important;
  background: var(--tf-surface-muted) !important;
  font-size: 10px !important;
  font-weight: 800 !important;
  letter-spacing: .075em !important;
  text-transform: uppercase !important;
}

th,
td {
  border-bottom: 1px solid var(--tf-border) !important;
}

tbody tr:hover { background: #f8fafc !important; }

.pill,
.tag,
.status.online,
.rank-badge {
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
  background: var(--tf-blue-soft) !important;
}

.pill.expired,
.pill.frozen,
.status.offline {
  border-color: #fecaca !important;
  color: #b91c1c !important;
  background: var(--tf-red-soft) !important;
}

.empty {
  padding: 34px 20px !important;
  color: var(--tf-muted) !important;
  background: var(--tf-surface) !important;
  text-align: center !important;
}

.section-head,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.explain-card {
  margin-top: 18px;
  padding: 18px !important;
}

.explain-item,
.formula-strip {
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius) !important;
  background: var(--tf-surface-muted) !important;
}

.router {
  position: relative;
  padding: 16px !important;
}

.router::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 20px 0 0 20px;
  background: var(--tf-green);
}

.router.attention::before { background: var(--tf-red); }

.dashboard-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.dashboard-back:hover { color: var(--tf-blue); }

body.dashboard-hub .shell { max-width: 1180px !important; }

body.dashboard-hub .hero {
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

body.dashboard-hub .hero::before,
body.dashboard-hub .hero::after { display: none !important; }

body.dashboard-hub .inner { padding: 12px 0 32px !important; }

body.dashboard-hub .nav {
  margin-bottom: 30px !important;
  padding: 12px 0;
  border-bottom: 1px solid var(--tf-border);
}

body.dashboard-hub .mark {
  width: 46px !important;
  height: 46px !important;
  border-radius: 15px !important;
  color: #fff !important;
  background: var(--tf-primary) !important;
  box-shadow: none !important;
}

body.dashboard-hub .brand-text span { color: var(--tf-muted) !important; }

body.dashboard-hub .auth-pill {
  min-height: 36px !important;
  padding: 8px 12px !important;
  border: 1px solid #bfdbfe !important;
  color: #1d4ed8 !important;
  background: var(--tf-blue-soft) !important;
  box-shadow: none !important;
}

body.dashboard-hub .auth-pill::before {
  background: var(--tf-blue) !important;
  box-shadow: none !important;
}

body.dashboard-hub .account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

body.dashboard-hub .logout-btn {
  min-height: 36px !important;
  padding: 8px 12px !important;
  border-color: #fecaca !important;
  color: #b91c1c !important;
  background: var(--tf-red-soft) !important;
}

body.dashboard-hub .logout-btn[hidden] { display: none !important; }

body.dashboard-hub h1 {
  max-width: 760px;
  margin-top: 12px !important;
  font-size: clamp(34px, 5vw, 54px) !important;
}

body.dashboard-hub .quick-actions { margin-top: 20px !important; }

body.dashboard-hub .network-pulse {
  grid-template-columns: 1.5fr repeat(3, minmax(110px, .65fr)) auto !important;
  margin-top: 24px !important;
  padding: 14px !important;
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  color: var(--tf-text) !important;
  background: var(--tf-surface) !important;
  box-shadow: var(--tf-shadow) !important;
}

body.dashboard-hub .pulse-intro,
body.dashboard-hub .pulse-stat {
  border: 1px solid var(--tf-border);
  color: var(--tf-text);
  background: var(--tf-surface-muted) !important;
}

body.dashboard-hub .pulse-intro span,
body.dashboard-hub .pulse-stat span { color: var(--tf-muted) !important; }

body.dashboard-hub .network-pulse .btn {
  color: #fff !important;
  background: var(--tf-blue) !important;
}

body.dashboard-hub .section-head {
  align-items: end;
  margin-top: 34px !important;
}

body.dashboard-hub .section-head h2 {
  font-size: clamp(22px, 3vw, 30px) !important;
  text-transform: uppercase;
}

body.dashboard-hub .grid {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 14px !important;
}

body.dashboard-hub .tile {
  min-height: 170px !important;
  padding: 18px !important;
  border: 1px solid var(--tf-border) !important;
  border-radius: var(--tf-radius-lg) !important;
  color: var(--tf-text) !important;
  background: var(--tf-surface) !important;
  box-shadow: none !important;
}

body.dashboard-hub .tile::before { display: none !important; }

body.dashboard-hub .tile:hover {
  border-color: #93c5fd !important;
  box-shadow: var(--tf-shadow) !important;
}

body.dashboard-hub .icon {
  width: 42px !important;
  height: 42px !important;
  border-radius: 14px !important;
  color: var(--tf-blue) !important;
  background: var(--tf-blue-soft) !important;
  box-shadow: none !important;
}

body.dashboard-hub .tile:nth-child(3n+2) .icon {
  color: var(--tf-green) !important;
  background: var(--tf-green-soft) !important;
}

body.dashboard-hub .tile:nth-child(3n) .icon {
  color: var(--tf-amber) !important;
  background: var(--tf-amber-soft) !important;
}

body.dashboard-hub .tag {
  border-color: var(--tf-border) !important;
  color: var(--tf-muted) !important;
  background: var(--tf-surface-muted) !important;
}

body.dashboard-hub .tile b {
  font-size: 21px !important;
  letter-spacing: -.025em !important;
}

body.dashboard-hub .tile span { color: var(--tf-muted) !important; }

body.dashboard-hub .arrow { background: var(--tf-surface-muted) !important; }
body.dashboard-hub .arrow::before {
  border-color: #475569 !important;
}

body.dashboard-hub .toast {
  border-radius: 12px !important;
  color: #fff !important;
  background: var(--tf-primary) !important;
}

.agent-dashboard-page .agent-loading-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.agent-dashboard-page .agent-loading-view.hidden { display: none !important; }

.agent-dashboard-page .agent-loading-view .card {
  width: min(460px, 100%);
}

.agent-dashboard-page .agent-loading-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 14px;
  color: #fff;
  background: var(--tf-primary);
  font-weight: 900;
}

.agent-dashboard-page .agent-loading-bar {
  height: 7px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--tf-surface-muted);
}

.agent-dashboard-page .agent-loading-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--tf-blue);
  animation: agentLoading 1.1s ease-in-out infinite alternate;
}

.agent-dashboard-page #loginView { display: none !important; }

.agent-dashboard-page .topbar {
  margin-bottom: 18px;
  padding: 18px 20px;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-lg);
  background: var(--tf-surface);
  box-shadow: var(--tf-shadow);
}

.agent-dashboard-page .brand h1 {
  color: var(--tf-text);
  font-size: clamp(26px, 4vw, 38px);
  text-transform: uppercase;
}

.agent-dashboard-page .grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.agent-dashboard-page .filters {
  padding: 16px;
  border: 1px solid var(--tf-border);
  border-radius: var(--tf-radius-lg);
  background: var(--tf-surface-muted);
}

@keyframes agentLoading {
  from { transform: translateX(-15%); opacity: .65; }
  to { transform: translateX(145%); opacity: 1; }
}

@media (max-width: 760px) {
  .agent-dashboard-page .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-dashboard-page .topbar { align-items: stretch; }
  .agent-dashboard-page .topbar .btn { width: 100%; }
}

@media (max-width: 430px) {
  .agent-dashboard-page .grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell,
  .wrap { padding: 14px !important; }
  .inner { padding: 18px !important; }
  .auth,
  .controls,
  .login {
    grid-template-columns: 1fr !important;
    padding: 14px;
  }
  .span-2 { grid-column: auto !important; }
  .actions { display: grid !important; grid-template-columns: 1fr !important; }
  .actions .btn,
  .controls .btn,
  .auth .btn,
  .login .btn { width: 100%; }
  .section-head,
  .topbar { align-items: stretch; flex-direction: column; }
  .section-head input { width: 100% !important; }
  h1 { font-size: 28px !important; }
  body.dashboard-hub .grid { grid-template-columns: 1fr !important; }
  body.dashboard-hub .account-actions {
    align-items: stretch;
    flex-direction: column;
  }
  body.dashboard-hub .logout-btn { width: 100%; }
  body.dashboard-hub .network-pulse { grid-template-columns: 1fr 1fr !important; }
  body.dashboard-hub .pulse-intro,
  body.dashboard-hub .network-pulse .btn { grid-column: 1 / -1; }
}

@media (min-width: 761px) and (max-width: 1080px) {
  body.dashboard-hub .grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  body.dashboard-hub .network-pulse { grid-template-columns: repeat(3, 1fr) !important; }
  body.dashboard-hub .pulse-intro { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .summary,
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .metric { min-height: 104px !important; }
  .metric span,
  .metric strong { font-size: 21px !important; }
}

@media (max-width: 390px) {
  .summary,
  .metrics { grid-template-columns: 1fr !important; }
}
