* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: var(--radius-sm);
}

button {
  min-height: var(--control-height);
  border: 1px solid var(--action);
  background: var(--action);
  color: #ffffff;
  padding: 0 var(--space-4);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--action-strong);
  border-color: var(--action-strong);
}

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

.ghost-button:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent);
}

input,
select {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--line);
  background: var(--panel-subtle);
  color: var(--text);
  padding: 0 var(--space-3);
}

label {
  display: grid;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

[hidden] {
  display: none !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 2px solid var(--accent);
  border-top-color: var(--action);
  border-radius: 50%;
}

.brand-logo {
  display: none;
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.brand-logo[data-visible="true"] {
  display: block;
}

.has-brand-logo .brand-mark {
  display: none;
}

.brand-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  color: var(--title);
  font-size: 20px;
  line-height: 1.1;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-popover);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.login-brand {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
}

.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger), transparent 70%);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
}

.field-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.nav-list {
  display: grid;
  align-content: start;
  gap: var(--space-2);
}

.nav-item {
  display: block;
  min-height: 38px;
  padding: 9px var(--space-3);
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--line);
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: var(--space-4);
}

.workspace {
  min-width: 0;
  padding: var(--space-5);
  display: grid;
  align-content: start;
  gap: var(--space-5);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2,
.section-heading h3 {
  margin: 0;
  color: var(--title);
}

.topbar h2 {
  font-size: 28px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.user-box strong,
.user-box span {
  display: block;
  text-align: right;
}

.user-box span {
  color: var(--muted);
  font-size: 12px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: var(--space-3);
}

.status-strip.compact {
  margin-bottom: var(--space-3);
}

.metric,
.module-card,
.data-row {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-md);
}

.module-action {
  justify-self: start;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
}

.management-panel {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.checkbox-list {
  display: grid;
  gap: var(--space-2);
}

.inline-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  color: var(--text);
}

.inline-check input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.module-check {
  padding: var(--space-2);
  background: var(--panel-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.action-row,
.row-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.row-actions {
  justify-content: end;
}

.row-actions button {
  min-height: 34px;
  padding: 0 var(--space-3);
}

.compact-heading {
  margin-bottom: var(--space-2);
}

.compact-heading h3 {
  font-size: 16px;
}

.compact-table {
  display: grid;
  gap: var(--space-2);
}

.compact-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.compact-row strong {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.compact-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.metric {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: var(--space-1);
  padding: var(--space-4);
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  color: var(--title);
  font-size: 30px;
  line-height: 1;
}

.section-block {
  display: grid;
  gap: var(--space-3);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3);
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
}

.module-card {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
}

.module-card header {
  display: grid;
  gap: var(--space-2);
}

.module-card h4 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
}

.module-card code {
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  color: var(--muted);
  background: var(--neutral-soft);
  font-size: 12px;
  font-weight: 800;
}

.tag.ok {
  color: var(--success);
  background: var(--success-soft);
}

.tag.warn {
  color: var(--warning);
  background: var(--warning-soft);
}

.tag.info {
  color: var(--info);
  background: var(--info-soft);
}

.data-list {
  display: grid;
  gap: var(--space-2);
}

.data-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 2fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
}

.user-row {
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 2fr) auto auto;
}

.data-row strong {
  color: var(--text);
}

.data-row span,
.data-row code {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  min-height: 84px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--panel-subtle);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  font-weight: 700;
}

.compact-empty {
  min-height: 48px;
}

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .topbar,
  .user-box {
    align-items: stretch;
    flex-direction: column;
  }

  .user-box strong,
  .user-box span {
    text-align: left;
  }

  .data-row {
    grid-template-columns: 1fr;
  }

  .split-grid,
  .management-grid,
  .compact-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: start;
  }

  .compact-row span {
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar,
  .login-view {
    padding: var(--space-3);
  }

  .status-strip,
  .nav-list {
    grid-template-columns: 1fr;
  }
}
