:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65717b;
  --line: #dce3e8;
  --soft: #eef3f6;
  --accent: #256f86;
  --accent-dark: #1d596b;
  --danger: #b33a3a;
  --success: #277347;
  --warning: #8a651b;
  --shadow: 0 8px 22px rgba(24, 38, 49, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
code { font-family: "Cascadia Mono", Consolas, monospace; font-size: 0.88em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.25rem; font-size: 1.45rem; }
h2 { margin-bottom: 0.15rem; font-size: 1.25rem; }
h3 { margin-bottom: 0; font-size: 1rem; }
p { margin-bottom: 0; color: var(--muted); line-height: 1.35; }

.hidden { display: none !important; }
.app-shell { min-height: 100vh; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(390px, 100%);
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.brand-row.compact {
  margin-bottom: 0;
}

.brand-row.compact span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand-mark {
  width: 2.45rem;
  height: 2.45rem;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 7px;
  font-weight: 800;
  letter-spacing: 0;
}

.dashboard-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 205px 1fr;
}

.sidebar {
  padding: 0.8rem;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.nav {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
}

.nav-link {
  width: 100%;
  padding: 0.52rem 0.6rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  text-align: left;
}

.nav-link.active,
.nav-link:hover {
  color: var(--ink);
  background: var(--soft);
  border-color: var(--line);
}

.workspace {
  min-width: 0;
  padding: 0.8rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.65rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 620px);
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.admin-grid.wide {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.75rem;
}

.panel.narrow { max-width: 560px; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.panel-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.stack-form { display: grid; gap: 0.5rem; }
.license-form-horizontal {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 0.5rem;
  align-items: end;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
label { display: grid; gap: 0.25rem; }
label span { color: var(--muted); font-size: 0.8rem; }
.check-row {
  height: 2.15rem;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.45rem;
}
.check-row input {
  width: auto;
  height: auto;
}

.type-summary {
  min-height: 2.15rem;
  display: grid;
  gap: 0.12rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
}

.type-summary span {
  color: var(--muted);
  font-size: 0.82rem;
}

input,
select {
  width: 100%;
  height: 2.15rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.42rem 0.55rem;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(37, 111, 134, 0.16);
  border-color: rgba(37, 111, 134, 0.55);
}

.button {
  min-height: 2.15rem;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 0.42rem 0.7rem;
  font-weight: 700;
}

.button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.button.ghost:hover { background: var(--soft); }
.button.compact { padding: 0.45rem 0.6rem; font-size: 0.78rem; }
.button.full { width: 100%; }

.status-banner {
  margin-bottom: 0.65rem;
  padding: 0.52rem 0.65rem;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
}

.status-banner.error { color: var(--danger); border-color: rgba(179, 58, 58, 0.34); }
.status-banner.success { color: var(--success); border-color: rgba(39, 115, 71, 0.34); }

.section { display: none; }
.section.active { display: block; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

.data-table th,
.data-table td {
  padding: 0.48rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  background: #f8fafb;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.data-table tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); font-size: 0.84rem; }
.empty-cell { text-align: center; color: var(--muted); }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge.success { color: var(--success); background: rgba(39, 115, 71, 0.1); }
.badge.pending, .badge.info { color: var(--warning); background: rgba(138, 101, 27, 0.1); }
.badge.expired { color: var(--danger); background: rgba(179, 58, 58, 0.1); }

@media (max-width: 900px) {
  .dashboard-view { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .license-form-horizontal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .workspace { padding: 0.65rem; }
  .topbar, .panel-header { align-items: stretch; flex-direction: column; }
  .form-row, .nav, .license-form-horizontal { grid-template-columns: 1fr; }
}
