:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #f0f3f6;
  --line: #dce1e7;
  --text: #111827;
  --muted: #667085;
  --muted-strong: #475467;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warning: #b54708;
  --warning-soft: #fef0c7;
  --success: #027a48;
  --success-soft: #dcfae6;
  --shadow: 0 16px 50px rgba(16, 24, 40, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(246, 247, 249, 0.92), rgba(246, 247, 249, 0.98)),
    var(--bg);
}

.auth-screen.hidden {
  display: none;
}

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

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

.auth-brand img,
.brand-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

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

.auth-brand span {
  color: var(--muted);
  margin-top: 2px;
}

.auth-card h1 {
  margin: 4px 0 0;
  font-size: 1.8rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.auth-card label:not(.remember-row) {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.auth-card input[type="email"],
.auth-card input[type="password"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #fcfcfd;
  color: var(--text);
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
}

.wide-button {
  width: 100%;
}

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

.sidebar {
  grid-row: 1 / 3;
  border-right: 1px solid var(--line);
  background: #fbfcfd;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

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

.brand span {
  color: var(--muted);
  font-size: 0.86rem;
  margin-top: 2px;
}

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

.nav-item {
  border: 0;
  width: 100%;
  border-radius: 8px;
  background: transparent;
  color: var(--muted-strong);
  padding: 11px 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
}

.nav-item span {
  width: 20px;
  text-align: center;
  color: var(--muted);
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--surface-strong);
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.sidebar-card strong,
.sidebar-card small {
  display: block;
}

.sidebar-card small {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.45;
}

.muted-label,
.metric-label,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.main-panel {
  min-width: 0;
  padding: 28px;
}

.signature {
  grid-column: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 28px 18px 0;
  color: rgba(17, 24, 39, 0.58);
  font-size: 0.82rem;
  font-weight: 800;
}

.signature img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  opacity: 0.86;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 5px 0 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(520px, 48vw);
  justify-content: flex-end;
}

.search-box {
  height: 42px;
  flex: 1;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search-box input {
  border: 0;
  outline: 0;
  width: 100%;
  min-width: 0;
  background: transparent;
  color: var(--text);
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border-radius: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.25);
  background: #effcf9;
}

.ghost-button {
  color: var(--muted-strong);
  border-color: var(--line);
  background: var(--surface);
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--muted-strong);
  border-color: var(--line);
  background: var(--surface);
  font-size: 1.25rem;
}

.account-menu {
  position: relative;
}

.account-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted-strong);
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.account-button span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.76rem;
}

.account-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px;
  display: none;
}

.account-popover.open {
  display: grid;
  gap: 8px;
}

.account-popover strong,
.account-popover small {
  display: block;
}

.account-popover small {
  color: var(--muted);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.25;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.compact-list,
.risk-list,
.activity-feed {
  display: grid;
  gap: 10px;
}

.compact-item,
.risk-list article,
.flow-list article,
.sync-item,
.activity-item,
.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fcfcfd;
}

.compact-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.compact-item strong,
.compact-item span,
.activity-item span,
.risk-list span {
  display: block;
}

.compact-item span,
.activity-item span,
.flow-list span,
.sync-item span,
.risk-list span,
.product-card p {
  color: var(--muted);
  margin-top: 3px;
}

.status-pill {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-active {
  color: var(--success);
  background: var(--success-soft);
}

.status-suspended {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-expired {
  color: var(--warning);
  background: var(--warning-soft);
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented-control button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 12px;
  background: transparent;
  color: var(--muted-strong);
  font-weight: 700;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  color: var(--text);
  background: var(--surface-strong);
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td {
  color: var(--muted-strong);
}

td strong {
  color: var(--text);
}

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

.tiny-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--muted-strong);
  font-weight: 700;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product-card h3 {
  margin: 0;
  font-size: 1rem;
}

.product-card p {
  margin-bottom: 14px;
}

.product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.product-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.product-meta span {
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted-strong);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.sync-grid,
.flow-list {
  display: grid;
  gap: 10px;
}

.sync-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.sync-item strong,
.sync-item span {
  display: block;
}

.sync-state {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
  color: var(--accent);
  background: #effcf9;
}

.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.activity-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.activity-time {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.settings-grid,
.form-grid {
  display: grid;
  gap: 14px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-row,
.toggle-row,
.form-grid label {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fcfcfd;
}

.field-row,
.form-grid label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.field-row input,
.field-row select,
.form-grid input,
.form-grid select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-weight: 700;
}

.toggle-row small {
  display: block;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
}

.toggle-row input {
  width: 42px;
  height: 22px;
  accent-color: var(--accent);
}

.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(780px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.5);
}

.modal-card {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.modal-header h2,
.modal-header p {
  margin: 0;
}

.modal-header p {
  margin-top: 5px;
  color: var(--muted);
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-actions {
  padding: 0;
  margin: 18px 0 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  border-radius: 8px;
  padding: 12px 14px;
  background: #101828;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-row: auto;
    position: sticky;
    top: 0;
    z-index: 10;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }

  .brand,
  .sidebar-card {
    display: none;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .signature {
    grid-column: 1;
  }

  .metric-grid,
  .split-layout,
  .product-grid,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .main-panel {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    min-width: 0;
  }

  .account-popover {
    left: 0;
    right: auto;
  }

  .metric-grid,
  .split-layout,
  .product-grid,
  .settings-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    overflow-x: auto;
  }
}
