:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #eef4ff;
  --text: #172033;
  --muted: #667085;
  --line: #d9e1ec;
  --primary: #5b2cff;
  --primary-dark: #4020c8;
  --accent: #00a7d8;
  --success: #147a43;
  --warning: #a15c00;
  --danger: #9d1c1c;
  --shadow: 0 16px 40px rgba(25, 35, 60, .08);
  font-family: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(91, 44, 255, .10), transparent 34rem),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 48%, #f2f6fb 100%);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(1.65rem, 3vw, 2.4rem); letter-spacing: 0; }
h2 { font-size: 1.05rem; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.6; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.full { grid-column: 1 / -1; }

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading h1 {
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.card {
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(217, 225, 236, .9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.card h2 {
  margin-bottom: 14px;
  color: #20304a;
}

.row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(160px, 210px);
  gap: 12px;
  margin-bottom: 12px;
  align-items: center;
}

label { font-size: .92rem; font-weight: 700; color: #344054; }

input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  font-size: .94rem;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

input:focus, select:focus {
  border-color: rgba(91, 44, 255, .65);
  box-shadow: 0 0 0 4px rgba(91, 44, 255, .10);
}

.input-shell {
  display: flex;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.input-shell:focus-within {
  border-color: rgba(91, 44, 255, .65);
  box-shadow: 0 0 0 4px rgba(91, 44, 255, .10);
}

.input-shell span {
  display: grid;
  place-items: center;
  min-width: 44px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: #48566d;
  border-right: 1px solid var(--line);
  font-size: .86rem;
  font-weight: 700;
  white-space: nowrap;
}

.input-shell.suffix span {
  border-right: 0;
  border-left: 1px solid var(--line);
  margin-left: auto;
}

.input-shell input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 16px;
}

.kpi {
  min-height: 86px;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f6ff 100%);
  border: 1px solid #dfe8f7;
  border-radius: 8px;
  padding: 14px;
}

.kpi .label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.kpi .value {
  color: #172b5f;
  font-size: clamp(1.05rem, 2vw, 1.45rem);
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid #e9eef5;
  text-align: left;
  vertical-align: middle;
  font-size: .9rem;
}

th {
  color: #5d6b82;
  font-weight: 800;
  background: #fbfcff;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.inline-actions { margin-top: 0; }

button, .primary-link, .secondary-link, .nav-cta {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}

button, .primary-link, .nav-cta {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 22px rgba(91, 44, 255, .20);
}

button:hover, .primary-link:hover, .nav-cta:hover {
  background: var(--primary-dark);
  color: #fff;
  transform: translateY(-1px);
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: var(--primary);
  border-color: var(--line);
}

.danger {
  background: #fff1f1;
  color: var(--danger);
  border-color: #f1caca;
  box-shadow: none;
}

.danger:hover {
  background: #ffe4e4;
  color: var(--danger);
}

.small {
  color: var(--muted);
  font-size: .83rem;
  line-height: 1.5;
}

.notice, .warn, .status {
  margin-top: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: .86rem;
}

.notice {
  display: none;
  color: #17406f;
  background: #eaf4ff;
  border: 1px solid #c9def7;
}

.warn {
  display: none;
  color: var(--warning);
  background: #fff5e8;
  border: 1px solid #ffd9a8;
}

.status {
  display: none;
  color: var(--success);
  background: #eaf8ef;
  border: 1px solid #bde6ca;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 250px);
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab-btn {
  background: #fff;
  color: #344054;
  border-color: var(--line);
  box-shadow: none;
}

.tab-btn.active {
  background: #172033;
  color: #fff;
  border-color: #172033;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.ghost-input { display: none; }

.sort-btn {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font: inherit;
  text-align: left;
}

.sort-btn:hover {
  background: transparent;
  color: var(--primary);
  box-shadow: none;
  transform: none;
}

.sort-btn.active::after {
  content: attr(data-sort-dir);
  margin-left: 3px;
  color: var(--primary);
}

.margin-low td { background: #fff5f5; }
.margin-mid td { background: #fffaeb; }
.margin-ok td { background: #f0fbf5; }
.margin-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-weight: 800;
}
.margin-low .margin-badge { color: var(--danger); background: #ffe0e0; }
.margin-mid .margin-badge { color: #9a6700; background: #ffefc2; }
.margin-ok .margin-badge { color: var(--success); background: #dff5e8; }

hr.sep-dash {
  border: 0;
  border-top: 1px dashed #cdd8e8;
  margin: 16px 0;
}

.home-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 16%, rgba(91, 44, 255, .16), transparent 26rem),
    radial-gradient(circle at 78% 10%, rgba(0, 167, 216, .16), transparent 24rem),
    #f7f9fc;
}

.home-header, .home-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.home-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 900;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}

.home-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 800;
}

.home-hero {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 170px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
  padding: 28px 0 56px;
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 16px;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy h1 {
  max-width: 680px;
  margin-bottom: 18px;
  font-size: clamp(2.1rem, 5.2vw, 4.6rem);
  line-height: .98;
}

.hero-copy p {
  max-width: 580px;
  font-size: clamp(1rem, 2vw, 1.18rem);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  max-width: 560px;
}

.hero-metrics span {
  min-height: 70px;
  padding: 12px;
  border: 1px solid rgba(217, 225, 236, .8);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  color: var(--muted);
  font-size: .86rem;
}

.hero-metrics strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
}

.hero-preview {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(217, 225, 236, .9);
  box-shadow: 0 28px 80px rgba(21, 32, 55, .16);
  background: #fff;
}

.hero-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.home-features {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 58px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.home-features article {
  padding: 22px;
  border: 1px solid rgba(217, 225, 236, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
}

.feature-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  border-radius: 8px;
  background: #edf4ff;
  color: var(--primary);
  font-weight: 900;
}

.home-plans {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 64px;
  scroll-margin-top: 24px;
}

.home-section-heading {
  max-width: 760px;
  margin-bottom: 22px;
}

.home-section-heading h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

.home-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  border-top: 1px solid rgba(217, 225, 236, .9);
}

form {
  display: grid;
  gap: 12px;
}

form + p { margin-top: 18px; }

.auth-container {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(100%, 440px);
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}

.plan-card {
  display: grid;
  align-content: start;
  gap: 12px;
}

.plan-card .primary-link {
  margin-top: auto;
  justify-content: center;
  text-align: center;
}

.plan-price {
  color: #172b5f;
  font-size: 2rem;
  font-weight: 900;
}

.benefit-list {
  margin: 0 0 8px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.panel-summary {
  margin: 20px 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.plans-overview {
  margin-bottom: 16px;
}

.mini-plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-plan {
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.mini-plan.active {
  border-color: rgba(91, 44, 255, .55);
  background: #f3f0ff;
}

.mini-plan span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.mini-plan strong {
  color: #172b5f;
  font-size: 1.05rem;
}

.mini-plan small {
  color: var(--muted);
  font-weight: 700;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-form select {
  width: auto;
  min-width: 130px;
}

@media (max-width: 920px) {
  .grid, .toolbar, .filters, .home-hero, .home-features, .plan-grid, .mini-plan-grid {
    grid-template-columns: 1fr;
  }
  .full { grid-column: auto; }
  .row { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  .home-hero { min-height: auto; padding-top: 18px; }
  .hero-copy h1 { line-height: 1.04; }
}

@media (max-width: 620px) {
  .container, .home-header, .home-footer, .home-hero, .home-features, .home-plans {
    width: min(100% - 24px, 1180px);
  }
  .home-header, .home-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 0;
  }
  .home-nav, .hero-actions {
    width: 100%;
  }
  .page-heading, .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .home-nav a, .hero-actions a {
    flex: 1;
    justify-content: center;
    text-align: center;
  }
  .hero-metrics {
    grid-template-columns: 1fr;
  }
  th, td {
    white-space: nowrap;
  }
}
