:root {
  color-scheme: dark;
  --background: #0f1217;
  --surface: #191e26;
  --surface-2: #222934;
  --surface-3: #11161d;
  --sidebar: #151b24;
  --border: #313a48;
  --border-strong: #445064;
  --text: #f1f5fb;
  --muted: #9ba8ba;
  --accent: #5190f6;
  --accent-hover: #70a5f8;
  --success: #49b675;
  --danger: #e45d5d;
  --warning: #f0b54a;
  --shadow: 0 24px 80px rgba(0,0,0,.38);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 10%, rgba(81,144,246,.10), transparent 34rem),
    radial-gradient(circle at 85% 85%, rgba(73,182,117,.06), transparent 30rem),
    var(--background);
  color: var(--text);
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: #9fc0fa; }
.hidden { display: none !important; }
.muted, .panel-note, .small-muted { color: var(--muted); }
.small-muted { font-size: .84rem; }
.success-text { color: var(--success) !important; }

/* Account-portal-matched sign-in */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; }
.login-card {
  width: min(720px, 100%);
  background: rgba(25,30,38,.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand-lockup, .sidebar-brand { display: flex; align-items: center; }
.account-style-brand { gap: 18px; }
.brand-logo { display: block; object-fit: contain; filter: drop-shadow(0 8px 22px rgba(0,0,0,.35)); }
.login-logo { width: 72px; height: 72px; border-radius: 16px; flex: 0 0 72px; }
.account-eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .16em;
}
.portal-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.08;
  font-weight: 750;
  letter-spacing: -.02em;
}
.login-lead { color: #c9d3e0; line-height: 1.65; margin: 28px 0 24px; max-width: 620px; }
.login-card form { display: grid; gap: 10px; }
.login-card label, .stack-form label, .licence-form-grid label {
  font-size: .78rem; color: var(--muted); font-weight: 700; letter-spacing: .03em;
}
input, select {
  width: 100%; min-height: 44px; border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 10px 13px; color: var(--text); background: var(--surface-3); outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(81,144,246,.18); }
input:disabled { opacity: .5; }
.form-error { color: #ffd0d0; background: rgba(228,93,93,.12); border: 1px solid rgba(228,93,93,.35); padding: 11px 13px; border-radius: 9px; }
.login-links { margin-top: 22px; display: flex; gap: 10px; justify-content: center; color: var(--muted); font-size: .88rem; }

/* Application shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0,1fr); transition: grid-template-columns .2s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: 78px minmax(0,1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: rgba(21,27,36,.97); border-right: 1px solid #273345;
  padding: 22px 16px 18px; display: flex; flex-direction: column; overflow: hidden;
}
.sidebar-top { display: grid; gap: 20px; }
.collapse-btn { justify-self: end; }
.icon-btn { border: 0; color: var(--muted); background: transparent; width: 38px; height: 38px; border-radius: 9px; cursor: pointer; font-size: 1.1rem; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.sidebar-brand { min-width: 0; gap: 13px; padding: 0 4px 18px; border-bottom: 1px solid var(--border); }
.sidebar-logo { width: 48px; height: 48px; border-radius: 12px; flex: 0 0 48px; }
.brand-copy { min-width: 0; }
.sidebar-brand-name {
  color: var(--text); font-size: .83rem; font-weight: 750; letter-spacing: .12em; white-space: nowrap;
}
.brand-subtitle { color: var(--accent); font-size: .72rem; font-weight: 750; margin-top: 4px; letter-spacing: .08em; }
.nav-list { margin-top: 22px; display: grid; gap: 7px; }
.nav-item {
  border: 0; background: transparent; color: #b7c5d7; display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 0 14px; border-radius: 9px; cursor: pointer; text-align: left; font-weight: 650; white-space: nowrap;
}
.nav-item:hover { background: #1d2632; color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); }
.nav-icon { width: 24px; text-align: center; color: #91b8fb; font-size: 1rem; }
.sidebar-footer { margin-top: auto; padding: 18px 4px 4px; }
.session-caption { color: #8ea7c8; font-size: .68rem; font-weight: 800; letter-spacing: .08em; }
.session-email { color: var(--success); font-size: .79rem; overflow: hidden; text-overflow: ellipsis; margin: 10px 0 18px; }
.signout-short { display: none; }
.app-shell.sidebar-collapsed .brand-copy, .app-shell.sidebar-collapsed .nav-text { display: none; }
.app-shell.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app-shell.sidebar-collapsed .nav-icon { width: auto; }
.app-shell.sidebar-collapsed .sidebar-footer { text-align: center; }
.app-shell.sidebar-collapsed .signout-short { display: inline; }

.main-content { min-width: 0; width: 100%; padding: clamp(24px, 3vw, 48px); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; margin-bottom: 28px; }
.eyebrow { color: var(--accent); font-size: .72rem; letter-spacing: .14em; font-weight: 800; text-transform: uppercase; }
.topbar h1 { margin: 4px 0 5px; font-size: clamp(2rem, 2.5vw, 2.6rem); line-height: 1.1; letter-spacing: -.02em; }
.topbar p { margin: 0; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.status-pill { border-radius: 999px; padding: 8px 12px; font-size: .75rem; font-weight: 800; border: 1px solid var(--border); background: var(--surface); }
.status-pill.success { color: var(--success); }
.status-pill.error { color: #ff9292; }

.view { display: none; }
.view.active-view { display: block; }
.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(150px,1fr)); gap: 14px; margin-bottom: 18px; }
.stats-grid.compact { grid-template-columns: repeat(7, minmax(120px,1fr)); }
.stat-card, .panel { background: rgba(25,30,38,.96); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.10); }
.stat-card { min-height: 112px; padding: 18px 20px; display: grid; align-content: center; gap: 9px; }
.stat-label, .panel-label { color: #91a8c4; font-size: .72rem; font-weight: 800; letter-spacing: .05em; }
.stat-value { font-size: 1.75rem; font-weight: 800; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel-value { margin-top: 15px; font-size: 1.3rem; font-weight: 800; }
.panel-note { margin-top: 9px; line-height: 1.55; }
.two-column-grid, .licensing-forms-grid, .release-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.action-row { display: flex; gap: 10px; align-items: center; }
.action-row.wrap { flex-wrap: wrap; margin-top: 16px; }
.btn {
  min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 9px; color: white;
  cursor: pointer; font-weight: 700; display: inline-flex; justify-content: center; align-items: center; text-decoration: none;
  transition: filter .15s ease, transform .04s ease; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--accent); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-success { background: var(--success); color: #07140d; }
.btn-warning { background: var(--warning); color: #211500; }
.btn-danger { background: var(--danger); }
.btn-block { width: 100%; }

.stack-form { margin-top: 15px; }
.inline-input-action { margin-top: 7px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.licence-form-grid { margin-top: 15px; display: grid; grid-template-columns: 1.35fr 1.2fr .72fr; gap: 12px; align-items: end; }
.expiry-field { grid-column: 1 / span 2; display: grid; grid-template-columns: auto minmax(180px,240px); gap: 12px; align-items: center; }
.check-label { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; }
.check-label input { width: auto; min-height: auto; }
.licence-create-button { grid-column: 3; grid-row: 2; }
.licence-create-button .btn { width: 100%; }
.table-panel { padding: 0; overflow: hidden; }
.section-heading-row { padding: 18px 20px; display: flex; justify-content: space-between; gap: 18px; align-items: center; border-bottom: 1px solid var(--border); }
.compact-actions { flex-wrap: wrap; justify-content: flex-end; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th { background: var(--surface-2); color: #d8e2ef; text-align: left; font-size: .77rem; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
td { color: #c8d4e4; font-size: .87rem; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #1b2a3e; }
tbody tr.selected { background: #285caa; }
.status-active { color: var(--success); }
.status-suspended { color: var(--warning); }
.status-revoked { color: #ff8e8e; }
.status-available { color: #91b9ff; }
.workflow-list { color: #c8d4e4; line-height: 1.75; padding-left: 22px; }

.toast-host { position: fixed; z-index: 1000; right: 20px; top: 20px; display: grid; gap: 10px; width: min(420px,calc(100vw - 40px)); }
.toast { background: var(--surface); border: 1px solid #42536a; border-left: 4px solid var(--accent); box-shadow: var(--shadow); padding: 14px 16px; border-radius: 9px; animation: toast-in .18s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity:0; transform:translateY(-8px); } }
.confirm-dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 13px; width: min(500px,calc(100vw - 32px)); padding: 0; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(0,0,0,.62); }
.confirm-dialog form { padding: 24px; }
.confirm-dialog h2 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width:1500px) {
  .stats-grid { grid-template-columns: repeat(3,minmax(150px,1fr)); }
  .stats-grid.compact { grid-template-columns: repeat(4,minmax(130px,1fr)); }
  .licence-form-grid { grid-template-columns: 1fr 1fr; }
  .licence-create-button { grid-column: 2; grid-row: auto; }
  .expiry-field { grid-column: 1; }
}
@media (max-width:1120px) {
  .app-shell { grid-template-columns: 78px minmax(0,1fr); }
  .sidebar .brand-copy, .sidebar .nav-text { display:none; }
  .sidebar .sidebar-brand, .sidebar .nav-item { justify-content:center; }
  .sidebar .nav-item { padding-inline:0; }
  .sidebar .signout-short { display:inline; }
  .two-column-grid, .licensing-forms-grid, .release-grid { grid-template-columns:1fr; }
  .stats-grid, .stats-grid.compact { grid-template-columns:repeat(3,minmax(120px,1fr)); }
}
@media (max-width:760px) {
  .main-content { padding:18px; }
  .topbar { flex-direction:column; }
  .stats-grid, .stats-grid.compact { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .licence-form-grid { grid-template-columns:1fr; }
  .expiry-field, .licence-create-button { grid-column:1; }
  .section-heading-row { align-items:flex-start; flex-direction:column; }
  .compact-actions { justify-content:flex-start; }
  .inline-input-action { grid-template-columns:1fr; }
}
@media (max-width:480px) {
  .stats-grid, .stats-grid.compact { grid-template-columns:1fr; }
  .sidebar { display:none; }
  .app-shell, .app-shell.sidebar-collapsed { grid-template-columns:1fr; }
  .login-card { padding:24px 20px; }
  .login-logo { width:56px; height:56px; border-radius:13px; flex-basis:56px; }
  .portal-title { font-size:2rem; }
}
