:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #627184;
  --line: #d9e0e7;
  --accent: #116b5f;
  --accent-strong: #0a4f46;
  --warn: #a63f26;
  --ok: #1f7a4d;
  --shadow: 0 14px 35px rgba(22, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #14212b;
  color: #f5f8fb;
  padding: 22px 16px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #5d717f;
  background: #213442;
  font-weight: 800;
}

.brand span,
.topbar p,
.detail-heading p {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
}

.brand span {
  color: #aebdc8;
}

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

.nav-item {
  width: 100%;
  height: 40px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #c6d1db;
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
}

.nav-item.active {
  color: #ffffff;
  background: #213442;
  border-left-color: #53b7a8;
}

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

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

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.topbar-actions,
.toolbar,
.toolbar-group,
.toolbar-actions,
.switch-row,
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.login-layout {
  min-height: calc(100vh - 130px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 22px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 107, 95, 0.12);
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  padding: 0 14px;
}

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

.ghost-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
}

.danger-button {
  border: 1px solid rgba(166, 63, 38, 0.34);
  background: #ffffff;
  color: var(--warn);
  font-weight: 700;
  padding: 0 14px;
}

.danger-button:hover {
  background: #fff4f0;
}

.icon-button {
  width: 38px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-label {
  width: min(300px, 42vw);
}

.status-line,
.status-text,
.error-text {
  min-height: 20px;
  color: var(--muted);
}

.error-text {
  color: var(--warn);
  margin: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 18px;
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

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

.dashboard-audit table {
  min-width: 680px;
}

.table-panel {
  overflow: auto;
}

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

th,
td {
  height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  text-align: left;
  white-space: nowrap;
}

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

tr.user-row {
  cursor: pointer;
}

tr.user-row:hover,
tr.user-row.selected {
  background: #eef7f5;
}

.user-cell {
  display: grid;
  gap: 3px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 9px;
  color: var(--muted);
  background: #f8fafb;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  color: var(--ok);
  border-color: rgba(31, 122, 77, 0.28);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(166, 63, 38, 0.28);
}

.detail-panel {
  min-height: 410px;
  padding: 18px;
}

.detail-panel form {
  display: grid;
  gap: 16px;
}

.access-panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.access-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.access-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.check-list {
  display: grid;
  gap: 6px;
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #f9fbfc;
}

.check-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 32px;
  color: var(--ink);
  text-transform: none;
  font-size: 13px;
  font-weight: 600;
}

.check-item input {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.check-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}

.subscription-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

.subscription-row:last-child {
  border-bottom: 0;
}

.subscription-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-transform: none;
  font-size: 14px;
  font-weight: 600;
}

.switch-label input {
  width: 18px;
  height: 18px;
}

.empty-state {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.ops-panel {
  padding: 20px;
}

.endpoint-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.endpoint-list span,
.system-list dd {
  border: 1px solid var(--line);
  background: #f9fbfc;
  border-radius: 6px;
  padding: 10px;
}

.system-list {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 10px;
}

.system-list dt {
  color: var(--muted);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
  }

  .nav {
    grid-auto-flow: column;
    align-content: center;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .toolbar-group,
  .sidebar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-label {
    width: 100%;
  }

  .nav {
    grid-auto-flow: row;
  }
}
