:root {
  --navy-950: #071426;
  --navy-900: #0b1b32;
  --navy-800: #112744;
  --blue-600: #2563eb;
  --blue-500: #3975ef;
  --blue-100: #e8f0ff;
  --violet-600: #7c3aed;
  --amber-600: #d97706;
  --green-600: #059669;
  --ink: #142033;
  --muted: #6f7d91;
  --line: #e5eaf2;
  --surface: #ffffff;
  --canvas: #f4f7fb;
  --danger: #c7363f;
  --danger-soft: #fff0f1;
  --success: #087f5b;
  --success-soft: #eafaf4;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 18px 45px rgba(16, 38, 70, 0.08);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body { margin: 0; color: var(--ink); background: var(--canvas); }

button, input, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

button { cursor: pointer; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.5px;
}

.brand-light { color: #fff; }
.brand-dark { color: var(--navy-900); }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px 11px 11px 4px;
  color: #fff;
  background: linear-gradient(145deg, #63a1ff, #2563eb);
  font-family: Georgia, serif;
  font-size: 24px;
  font-style: italic;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
}

.eyebrow {
  display: inline-block;
  color: #8eb7ff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.65px;
}

.eyebrow-dark { color: var(--blue-600); }

.muted { color: var(--muted); }

label {
  display: block;
  color: #3c4a5d;
  font-size: 13px;
  font-weight: 650;
}

input, select {
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border: 1px solid #d9e0ea;
  border-radius: 11px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  padding: 0 14px;
  transition: border-color .18s, box-shadow .18s;
}

input:focus, select:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(57, 117, 239, .12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 45px;
  border: 0;
  border-radius: 11px;
  padding: 0 20px;
  font-weight: 750;
  transition: transform .15s, box-shadow .15s, opacity .15s;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-wide { width: 100%; }

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue-600), #397eef);
  box-shadow: 0 10px 24px rgba(37, 99, 235, .22);
}

.button-secondary { color: #33435a; background: #eef2f7; }

.icon-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  padding: 8px;
}

.form-message {
  margin: 14px 0;
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--success);
  background: var(--success-soft);
  font-size: 13px;
  line-height: 1.5;
}

.form-message.error { color: var(--danger); background: var(--danger-soft); }

/* Login */
.login-page { min-height: 100vh; background: var(--navy-950); }

.login-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(430px, .85fr); min-height: 100vh; }

.login-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  overflow: hidden;
  padding: clamp(36px, 6vw, 76px);
  color: #fff;
  background:
    radial-gradient(circle at 15% 15%, rgba(55, 126, 239, .23), transparent 31%),
    radial-gradient(circle at 88% 65%, rgba(48, 92, 169, .23), transparent 30%),
    linear-gradient(145deg, #08172a 0%, #0b203d 58%, #0a1729 100%);
}

.login-intro::after {
  content: "";
  position: absolute;
  right: -20%;
  bottom: -30%;
  width: 72%;
  aspect-ratio: 1;
  border: 1px solid rgba(128, 175, 255, .13);
  border-radius: 50%;
  box-shadow: 0 0 0 70px rgba(128, 175, 255, .035), 0 0 0 140px rgba(128, 175, 255, .025);
}

.login-copy { position: relative; z-index: 1; max-width: 720px; margin: auto 0; padding: 70px 0; }
.login-copy h1 { max-width: 680px; margin: 18px 0 22px; font-size: clamp(42px, 5.2vw, 72px); line-height: 1.03; letter-spacing: -2.6px; }
.login-copy p { max-width: 600px; margin: 0; color: #b7c6dc; font-size: clamp(17px, 1.5vw, 21px); line-height: 1.7; }

.login-feature-grid { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 530px; border-top: 1px solid rgba(255,255,255,.1); padding-top: 28px; }
.login-feature-grid div { display: flex; flex-direction: column; gap: 5px; }
.login-feature-grid strong { font-size: 18px; }
.login-feature-grid span { color: #8fa1ba; font-size: 13px; }

.login-card { display: grid; place-items: center; min-height: 100vh; background: #fff; padding: 44px; }
.login-card-inner { width: min(100%, 420px); }
.login-card h2 { margin: 13px 0 8px; color: var(--navy-900); font-size: 31px; letter-spacing: -1px; }
.login-card p { line-height: 1.6; }
.login-card form { margin-top: 34px; }
.login-card form > label { margin-top: 20px; }
.login-card .button { margin-top: 24px; }
.password-field { position: relative; }
.password-field .icon-button { position: absolute; top: 14px; right: 7px; }
.password-field input { padding-right: 70px; }
.login-help { margin: 25px 0 0; text-align: center; color: #8793a5; font-size: 12px; }
.mobile-brand { display: none; margin-bottom: 40px; }

/* App shell */
.app-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 18px 20px;
  color: #d7e3f6;
  background: linear-gradient(180deg, var(--navy-900), #09172a);
  z-index: 40;
}

.sidebar-brand { margin: 0 10px 42px; font-size: 18px; }
.sidebar-brand .brand-mark { width: 31px; height: 31px; font-size: 21px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 7px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 11px;
  padding: 0 13px;
  color: #aebed5;
  background: transparent;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}

.nav-link:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-link.active { color: #fff; background: linear-gradient(135deg, rgba(52, 115, 225, .95), rgba(48, 103, 204, .9)); box-shadow: 0 10px 24px rgba(16, 54, 116, .28); }
.nav-icon { display: grid; place-items: center; width: 22px; font-size: 18px; }
.nav-button { font-family: inherit; cursor: pointer; }
.sidebar-footer { display: flex; flex-direction: column; gap: 4px; margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: 15px; }

.app-main { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
  padding: 15px clamp(20px, 4vw, 50px);
  background: rgba(255,255,255,.91);
  backdrop-filter: blur(18px);
}

.topbar h1 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.6px; }
.topbar-label { margin: 0; color: var(--blue-600); font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.user-chip { display: flex; align-items: center; gap: 11px; margin-left: auto; }
.user-chip > span:last-child { display: flex; flex-direction: column; gap: 3px; max-width: 230px; }
.user-chip strong, .user-chip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: 13px; }
.user-chip small { color: var(--muted); font-size: 11px; }
.user-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: linear-gradient(145deg, var(--blue-500), var(--blue-600)); font-size: 13px; font-weight: 800; }
.menu-button { display: none; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: #fff; font-size: 19px; }

.content { width: min(100%, 1560px); margin: 0 auto; padding: 30px clamp(20px, 4vw, 50px) 60px; }

.filter-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 17px 20px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(24, 43, 75, .035);
}

.filter-heading { display: flex; flex-direction: column; gap: 3px; min-width: 155px; }
.filter-heading strong { font-size: 14px; }
.filter-heading span { font-size: 11px; }
.filters { display: flex; align-items: end; justify-content: flex-end; gap: 12px; flex-wrap: wrap; width: 100%; }
.filters label { min-width: 150px; }
.filters select { min-width: 190px; }
.filters input, .filters select { min-height: 41px; margin-top: 5px; }
.filters .button { min-height: 41px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; margin-bottom: 20px; }
.metric-card { display: flex; align-items: center; gap: 15px; min-height: 132px; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; background: #fff; box-shadow: 0 9px 28px rgba(23, 44, 78, .045); }
.metric-card > div:last-child { display: flex; flex-direction: column; min-width: 0; }
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-card strong { margin: 5px 0 2px; color: var(--navy-900); font-size: clamp(27px, 2.5vw, 36px); line-height: 1; letter-spacing: -1.2px; }
.metric-card small { overflow: hidden; color: #9aa5b5; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.metric-icon { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border-radius: 15px; font-size: 21px; }
.metric-blue .metric-icon { color: var(--blue-600); background: var(--blue-100); }
.metric-violet .metric-icon { color: var(--violet-600); background: #f0eafe; }
.metric-amber .metric-icon { color: var(--amber-600); background: #fff3dd; }
.metric-green .metric-icon { color: var(--green-600); background: #e4f8f1; }

.panel-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .7fr); gap: 20px; margin-bottom: 20px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; box-shadow: 0 10px 30px rgba(20, 39, 70, .04); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 79px; border-bottom: 1px solid #edf0f5; padding: 17px 21px; }
.panel-heading h2 { margin: 4px 0 0; font-size: 17px; letter-spacing: -.35px; }
.legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-600); }
.badge { border-radius: 999px; color: #526178; background: #eef2f7; padding: 7px 11px; font-size: 11px; font-weight: 750; }

.trend-chart { position: relative; display: flex; align-items: flex-end; gap: clamp(3px, .7vw, 9px); min-height: 255px; overflow: hidden; padding: 30px 24px 33px; background: repeating-linear-gradient(to bottom, transparent 0, transparent 59px, #eef2f7 60px); }
.chart-bar-wrap { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; min-width: 4px; height: 205px; }
.chart-bar { position: relative; width: min(100%, 18px); min-height: 3px; border-radius: 7px 7px 3px 3px; background: linear-gradient(180deg, #4f8bf3, #2867da); box-shadow: 0 5px 12px rgba(37, 99, 235, .18); }
.chart-bar:hover::after { content: attr(data-value); position: absolute; left: 50%; bottom: calc(100% + 7px); z-index: 5; transform: translateX(-50%); border-radius: 6px; color: #fff; background: var(--navy-900); padding: 5px 7px; font-size: 10px; }
.chart-label { max-width: 34px; overflow: hidden; color: #8e99aa; font-size: 9px; text-overflow: clip; white-space: nowrap; }
.chart-empty { display: grid; place-items: center; width: 100%; height: 210px; color: var(--muted); font-size: 13px; }

.click-breakdown { display: grid; gap: 15px; padding: 22px; }
.click-row { display: grid; grid-template-columns: 105px minmax(0, 1fr) 42px; align-items: center; gap: 10px; }
.click-row span { color: #5c6a7c; font-size: 12px; }
.click-row strong { text-align: right; font-size: 12px; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #edf1f6; }
.progress i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, #3979ed, #7da7f5); }

.table-panel { margin-bottom: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { color: #7d8999; background: #fafbfd; font-size: 10px; font-weight: 800; letter-spacing: .55px; text-align: left; text-transform: uppercase; }
th, td { border-bottom: 1px solid #edf0f4; padding: 13px 18px; vertical-align: middle; white-space: nowrap; }
td { color: #526074; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
.number { text-align: right; }
.favorite-product { display: flex; align-items: center; gap: 11px; min-width: 280px; }
.favorite-product img, .product-placeholder { width: 44px; height: 51px; flex: 0 0 auto; border-radius: 8px; object-fit: cover; background: #eef2f6; }
.product-placeholder { display: grid; place-items: center; color: #a6b0be; font-size: 15px; }
.favorite-product span { display: flex; flex-direction: column; gap: 3px; }
.favorite-product strong { color: #253348; font-size: 12px; }
.favorite-product small { max-width: 290px; overflow: hidden; color: #8b96a6; text-overflow: ellipsis; }
.count-pill { display: inline-block; min-width: 33px; border-radius: 7px; padding: 5px 8px; text-align: center; font-weight: 800; }
.count-total { color: #a65f00; background: #fff1d8; }
.count-active { color: #047859; background: #e2f7ef; }
.empty-state { padding: 42px 22px; color: var(--muted); font-size: 13px; text-align: center; }

/* Accounts */
.account-layout { display: grid; grid-template-columns: minmax(320px, .72fr) minmax(520px, 1.45fr); gap: 20px; align-items: start; }
.account-form-panel form { padding: 7px 22px 24px; }
.account-form-panel form > label { margin-top: 17px; }
.account-form-panel small { display: block; margin-top: 7px; font-size: 11px; line-height: 1.5; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 23px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 68px; margin-top: 22px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.switch-row span { display: flex; flex-direction: column; gap: 3px; }
.switch-row small { margin: 0; color: var(--muted); }
.switch-row input { width: 42px; min-height: 22px; margin: 0; accent-color: var(--blue-600); }
.account-search { padding: 14px 20px; }
.account-search input { margin: 0; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 800; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { color: #047859; background: #e4f8f1; }
.status-passive { color: #a74b53; background: #fff0f1; }
.table-action { border: 0; border-radius: 8px; color: var(--blue-600); background: var(--blue-100); padding: 7px 10px; font-size: 11px; font-weight: 750; }

/* Modal */
.modal { width: min(92vw, 450px); border: 0; border-radius: 17px; padding: 0; color: var(--ink); box-shadow: 0 30px 90px rgba(5, 20, 42, .28); }
.modal::backdrop { background: rgba(4, 14, 30, .62); backdrop-filter: blur(3px); }
.modal form { padding: 23px; }
.modal form > label { margin-top: 16px; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; }
.modal-heading h2 { margin: 0; font-size: 20px; }
.modal-heading .icon-button { font-size: 25px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.sidebar-scrim { display: none; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
  .click-breakdown { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-layout { grid-template-columns: 1fr; }
}

@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { display: none; }
  .login-card { min-height: 100vh; padding: 28px; }
  .mobile-brand { display: inline-flex; }

  .app-layout { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-104%); width: 260px; transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(2, 12, 27, .52); }
  .sidebar-scrim.show { display: block; }
  .menu-button { display: grid; place-items: center; }
  .topbar { min-height: 78px; }
  .topbar h1 { font-size: 20px; }
  .user-chip > span:last-child { display: none; }
  .filter-card { align-items: flex-start; flex-direction: column; }
  .filters { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .login-card { padding: 22px; }
  .login-card h2 { font-size: 27px; }
  .content { padding: 20px 14px 45px; }
  .topbar { padding: 12px 14px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 11px; }
  .metric-card { align-items: flex-start; flex-direction: column; min-height: 160px; padding: 16px; }
  .metric-card strong { font-size: 29px; }
  .metric-icon { width: 42px; height: 42px; border-radius: 13px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .filters label { min-width: 0; }
  .filters .owner-only, .filters .button { grid-column: 1 / -1; }
  .filters select { min-width: 0; }
  .click-breakdown { grid-template-columns: 1fr; }
  .trend-chart { gap: 3px; padding-inline: 12px; }
  .chart-label { display: none; }
  .panel-heading { padding: 15px 16px; }
  th, td { padding: 12px 14px; }
  .favorite-product { min-width: 230px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
