:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #eef4f2;
  --text: #16231f;
  --muted: #66736f;
  --line: #dce6e2;
  --primary: #128671;
  --primary-dark: #0d6657;
  --danger: #b3261e;
  --warning: #936100;
  --success: #0b704b;
  --sidebar: #10201d;
  --shadow: 0 14px 34px rgba(18, 43, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.1;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

p,
small {
  color: var(--muted);
}

a {
  color: inherit;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--sidebar);
  color: #f7fffd;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #2bc3a7;
  color: #06251f;
  font-weight: 900;
}

.brand small,
.sidebar small {
  display: block;
  margin-top: 2px;
  color: #a9c9c2;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

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

.nav-item.active,
.nav-item:hover {
  background: rgba(43, 195, 167, 0.15);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  border-color: #35504a;
  background: transparent;
  color: #cfe6e1;
}

.main {
  width: 100%;
  max-width: 1280px;
  padding: 30px;
}

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

.topbar p {
  margin-top: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eef4f2;
}

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

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

.login-brand {
  margin-bottom: 4px;
}

.login-brand strong {
  display: block;
  font-size: 20px;
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

body.auth-pending .sidebar,
body.auth-pending .main {
  visibility: hidden;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid,
.platform-grid,
.toggle-grid {
  display: grid;
  gap: 14px;
}

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

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

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.panel {
  margin-bottom: 18px;
  padding: 20px;
}

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

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

.platform-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.platform-card > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.platform-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 900;
}

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

.activity-list,
.history-list {
  display: grid;
  gap: 12px;
}

.activity-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

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

.activity-item time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.publish-panel {
  max-width: 960px;
}

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

.publish-steps div {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: #344540;
  font-weight: 800;
}

.publish-steps strong {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #41524e;
  font-size: 13px;
  font-weight: 800;
}

.field.compact {
  width: min(220px, 100%);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 11px 12px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(18, 134, 113, 0.12);
}

input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.span-2 {
  grid-column: span 2;
}

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

.toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  cursor: pointer;
}

.toggle-card input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

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

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #f2c5c0;
  color: var(--danger);
}

.button.full {
  width: 100%;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ok {
  background: #dff7ed;
  color: var(--success);
}

.badge.required {
  background: #fde7e5;
  color: var(--danger);
}

.badge.urgent {
  background: #fff0d1;
  color: var(--warning);
}

.badge.active {
  background: #dff7ed;
  color: var(--success);
}

.badge.inactive {
  background: #e8eceb;
  color: #596865;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.history-group {
  display: grid;
  gap: 10px;
}

.history-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.history-group-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.version-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.version-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  box-shadow: none;
}

.version-card-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

.version-card p {
  line-height: 1.5;
}

.version-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.version-card dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.version-card dd {
  margin: 2px 0 0;
}

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

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

.history-table {
  margin-top: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td:last-child {
  text-align: right;
  white-space: nowrap;
}

.row-title {
  display: grid;
  gap: 3px;
}

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

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: 420px;
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--sidebar);
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 160ms ease;
}

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

@media (max-width: 1100px) {
  .stats-grid,
  .platform-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    display: flex;
    gap: 8px;
    margin-top: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    padding: 0 14px;
  }

  .sidebar-footer {
    position: absolute;
    right: 14px;
    top: 14px;
    min-height: 36px;
    padding: 0 12px;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .panel-header,
  .version-card-main {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    justify-content: space-between;
  }

  .publish-steps,
  .form-grid,
  .toggle-grid,
  .version-cards,
  .version-card dl {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .field.compact {
    width: 100%;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .card-actions {
    justify-content: stretch;
  }

  .actions .button,
  .card-actions .button {
    flex: 1 1 auto;
  }
}

@media (max-width: 640px) {
  .stats-grid,
  .platform-grid {
    grid-template-columns: 1fr;
  }

  .brand strong {
    font-size: 15px;
  }

  .brand small {
    display: none;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .main {
    padding: 14px;
  }

  .panel {
    padding: 16px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .publish-steps div {
    min-height: 42px;
  }

  .activity-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-table {
    display: none;
  }

  .toast {
    right: 14px;
    bottom: 14px;
    left: 14px;
    max-width: none;
  }
}
