:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #dfe4eb;
  --text: #101828;
  --muted: #7a8494;
  --accent: #f97316;
  --accent-strong: #c2410c;
  --green: #38a169;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --amber-bg: #fef3c7;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1100px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.locked {
  min-width: 0;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #fff;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.sidebar-brand img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: #000;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand strong {
  font-size: 18px;
}

.sidebar-brand span {
  color: #aab3c2;
  font-size: 13px;
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: #d6dbe5;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: #273142;
  color: #fff;
}

.workspace {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 34px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand img {
  width: 70px;
  height: 70px;
  border-radius: 10px;
  background: #050505;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
}

main {
  padding: 36px 34px 48px;
}

.actions,
.toolbar,
menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button:hover {
  filter: brightness(0.98);
}

.button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.login-panel {
  display: grid;
  min-height: calc(100vh - 127px);
  place-items: center;
  padding: 36px;
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-box img {
  width: 96px;
  height: 96px;
  border-radius: 10px;
  background: #000;
}

.form-message {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.metric {
  min-height: 156px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric.highlight {
  border-color: #fed7aa;
}

.metric-label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-bottom: 6px;
  font-size: 42px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
  font-size: 17px;
}

.good {
  color: var(--green);
}

.bad {
  color: var(--red);
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.panel-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 17px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

select,
input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1980px;
  border-collapse: collapse;
}

.keyword-table {
  min-width: 980px;
}

.user-table {
  min-width: 980px;
}

th,
td {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #98a2b3;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

td {
  color: #7a8494;
  font-size: 21px;
}

.empty-state {
  color: var(--muted);
  font-size: 18px;
  text-align: center;
}

.client-name {
  color: #1f2937;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
}

.client-links {
  margin-top: 6px;
  color: var(--accent-strong);
  font-size: 16px;
}

.pill {
  display: inline-flex;
  min-width: 44px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 900;
}

.pill.good {
  background: var(--green-bg);
}

.pill.bad {
  background: var(--red-bg);
}

.pill.warn {
  background: var(--amber-bg);
  color: #ea580c;
}

.traffic strong {
  color: #1f2937;
}

.traffic span {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.info-panel {
  display: grid;
  gap: 18px;
  padding: 28px;
}

.info-panel p {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px;
}

.integration-grid article {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.integration-grid span {
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px 28px 0;
}

.admin-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.admin-card span {
  color: var(--muted);
}

.client-dashboard {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.client-sidebar {
  display: grid;
  align-content: start;
  gap: 20px;
  min-height: 720px;
  padding: 18px 14px;
  background: #111827;
  color: #fff;
}

.client-sidebar h2 {
  font-size: 18px;
}

.client-sidebar .eyebrow {
  color: #aab3c2;
}

.client-workspace {
  min-width: 0;
  background: #f8fafc;
}

.client-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.client-nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #d6dbe5;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.client-nav-item:hover,
.client-nav-item.active {
  background: #3b2a23;
  color: #fff;
}

.rank-chart,
.client-section,
.distribution-grid article,
.client-view:not([data-client-panel="rankings"]) {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.rank-chart {
  display: grid;
  gap: 16px;
  min-height: 220px;
  align-items: end;
  padding: 22px;
}

.chart-count {
  justify-self: end;
  font-size: 28px;
  font-weight: 900;
}

.bar-stack {
  display: flex;
  align-items: end;
  justify-content: end;
  gap: 4px;
  min-height: 145px;
  border-bottom: 1px solid var(--line);
}

.bar-stack span {
  width: 14px;
  border-radius: 3px 3px 0 0;
}

.rank-green {
  height: 110px;
  background: #2f7d3b;
}

.rank-light {
  height: 96px;
  background: #74d179;
}

.rank-yellow {
  height: 122px;
  background: #ffd65a;
}

.rank-red {
  height: 124px;
  background: #ef6358;
}

.client-section {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 22px;
}

.score-ring {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 8px solid #ea8a2f;
  border-radius: 999px;
  color: #ea8a2f;
  font-size: 28px;
  font-weight: 900;
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
}

.distribution-grid article {
  padding: 18px;
}

.distribution-grid strong,
.distribution-grid span {
  display: block;
}

.distribution-grid strong {
  font-size: 28px;
}

.distribution-grid span {
  margin-top: 6px;
  color: var(--muted);
}

.soft-good {
  background: #ecfdf3 !important;
  border-color: #bbf7d0 !important;
}

.soft-bad {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}

dialog {
  width: min(620px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

menu {
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

@media (max-width: 1300px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }
}
