:root {
  --ink: #17223b;
  --muted: #69748c;
  --line: #e4e9f2;
  --surface: #ffffff;
  --background: #f3f6fb;
  --nav: #101a31;
  --blue: #3267ef;
  --green: #16a36f;
  --purple: #7a54df;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--nav);
  color: #dce4f8;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; color: white; text-decoration: none; margin: 0 10px 42px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  background: linear-gradient(145deg, #4b82ff, #8058eb);
  border-radius: 12px; font-weight: 800; letter-spacing: -.04em;
  box-shadow: 0 8px 24px #3158c54d;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { color: #8e9ab6; font-size: 11px; margin-top: 2px; }

nav { display: grid; gap: 8px; }
.nav-link {
  border: 0; color: #929fbb; background: transparent; padding: 12px 14px;
  border-radius: 10px; text-align: left; transition: .2s ease;
}
.nav-link span { display: inline-block; width: 26px; color: #697895; }
.nav-link:hover, .nav-link.active { color: white; background: #23304b; }
.nav-link.active span { color: #79a0ff; }

.stage {
  margin-top: auto; display: flex; gap: 10px; align-items: center;
  border: 1px solid #2c3955; background: #17233b; border-radius: 12px; padding: 14px;
}
.stage strong, .stage small { display: block; }
.stage strong { font-size: 12px; }
.stage small { color: #7f8ba6; font-size: 10px; margin-top: 3px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #2bd79a; box-shadow: 0 0 0 4px #2bd79a20; }

main { padding: 0 44px 60px; max-width: 1440px; width: 100%; margin: 0 auto; }
.topbar { height: 112px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { margin: 3px 0 0; font-size: 27px; letter-spacing: -.04em; }
.eyebrow { margin: 0; color: #8c97ad; font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.connection { display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); background: white; border: 1px solid var(--line); border-radius: 99px; padding: 9px 14px; }
.connection.offline .status-dot { background: #e34f5f; box-shadow: 0 0 0 4px #e34f5f20; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.logout-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 8px; }
.logout-button:hover { color: #c43d4d; }

.view { display: none; animation: enter .25s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

.hero {
  min-height: 260px; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 46px; color: white; border-radius: 22px; overflow: hidden;
  background:
    radial-gradient(circle at 75% 15%, #6d7bea88 0, transparent 27%),
    linear-gradient(125deg, #192a55 0%, #243f83 54%, #6453c6 100%);
  box-shadow: 0 20px 55px #263e7924;
}
.hero h2 { font-size: clamp(32px, 4vw, 49px); line-height: 1.03; letter-spacing: -.05em; margin: 10px 0 18px; }
.hero p:not(.eyebrow) { color: #c6d2ec; max-width: 550px; margin: 0; font-size: 14px; }

.primary {
  border: 0; background: var(--blue); color: white; font-weight: 700;
  padding: 13px 20px; border-radius: 10px; box-shadow: 0 8px 20px #3267ef33;
}
.primary:hover { background: #2459dc; transform: translateY(-1px); }
.primary:disabled { cursor: wait; opacity: .65; transform: none; }
.hero .primary { background: white; color: #2f4ba0; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 22px 0; }
.stat-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 23px; position: relative; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.accent-blue { --accent: var(--blue); }
.accent-purple { --accent: var(--purple); }
.accent-green { --accent: var(--green); }
.stat-card span, .stat-card small { color: var(--muted); display: block; }
.stat-card span { font-size: 12px; font-weight: 650; }
.stat-card strong { font-size: 37px; letter-spacing: -.05em; display: block; margin: 8px 0 2px; }
.stat-card small { font-size: 10px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 28px; }
.panel h2, .panel h3 { margin: 5px 0 22px; letter-spacing: -.035em; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.panel-heading h2, .panel-heading h3 { margin-bottom: 0; }
.count { display: grid; place-items: center; min-width: 35px; height: 35px; padding: 0 10px; border-radius: 10px; color: var(--blue); background: #edf3ff; font-weight: 800; font-size: 12px; }

.backup-panel { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.backup-panel h3 { margin: 5px 0 7px; }
.backup-panel p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.backup-panel .primary { white-space: nowrap; }
.backup-actions { display: flex; align-items: center; gap: 9px; }

.flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 24px; }
.flow div { display: grid; grid-template-columns: 38px 1fr; align-items: center; column-gap: 12px; }
.flow span { grid-row: span 2; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: #eef3ff; color: var(--blue); font-weight: 800; }
.flow strong { font-size: 13px; }
.flow small { color: var(--muted); font-size: 10px; margin-top: 3px; }
.flow b { color: #bdc6d8; }

.section-grid { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 22px; align-items: start; }
.form-panel { position: sticky; top: 24px; }
form { display: grid; gap: 17px; }
label { color: #526079; font-weight: 700; font-size: 12px; }
label small { font-weight: 500; color: #9aa4b7; }
input, select {
  width: 100%; margin-top: 7px; border: 1px solid #d9e0ec; background: #fbfcfe;
  color: var(--ink); border-radius: 9px; padding: 12px; outline: none;
}
input:focus, select:focus { border-color: #7096f5; box-shadow: 0 0 0 3px #3267ef15; background: white; }

.item-list { display: grid; gap: 10px; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px; border: 1px solid #e8edf4; border-radius: 11px; }
.list-item:hover { border-color: #cdd7e8; background: #fbfcff; }
.item-main { min-width: 0; }
.item-main strong, .item-main small { display: block; }
.item-main strong { font-size: 13px; }
.item-main small { color: var(--muted); font-size: 10px; margin-top: 4px; overflow-wrap: anywhere; }
.badge { flex: none; font-size: 10px; font-weight: 800; color: #4261a5; background: #edf3ff; padding: 6px 9px; border-radius: 7px; }
.badge.active { color: #147c58; background: #e8f8f1; }
.badge.suspended { color: #9a6812; background: #fff5d9; }
.badge.revoked { color: #a33a47; background: #fff0f2; }
.action-button.warning:hover { border-color: #e6c471; color: #93610a; background: #fffaf0; }
.item-actions { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.action-button, .icon-button, .secondary {
  border: 1px solid #dbe2ee; background: white; color: #526079;
  border-radius: 8px; padding: 7px 10px; font-size: 10px; font-weight: 750;
}
.action-button:hover, .secondary:hover { border-color: #9eafd0; color: var(--blue); }
.action-button.danger:hover { border-color: #efb7be; color: #c43d4d; background: #fff5f6; }
.action-button:disabled { opacity: .5; cursor: not-allowed; }
.empty { text-align: center; color: var(--muted); padding: 50px 15px; font-size: 12px; border: 1px dashed #d9e0ec; border-radius: 12px; }
.license-list .list-item { align-items: flex-start; }
.license-key { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: #4261a5 !important; }
.device-list { width: 100%; margin-top: 12px; display: grid; gap: 7px; }
.device-row { display: flex; align-items: center; gap: 10px; border-top: 1px solid #edf0f5; padding-top: 10px; }
.device-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: #edf3ff; color: var(--blue); font-size: 12px; }
.device-row .item-main { flex: 1; }
.license-card { display: block; }
.license-summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.notice { margin: -4px 0 18px; padding: 12px 16px; border-radius: 10px; background: #e9f8f2; color: #147451; font-size: 12px; border: 1px solid #ccefe1; }
.notice.error { color: #a33a47; background: #fff0f2; border-color: #f7d4d9; }

dialog { border: 0; border-radius: 17px; padding: 0; width: min(460px, calc(100% - 30px)); box-shadow: 0 28px 90px #0d173652; }
dialog::backdrop { background: #101a3175; backdrop-filter: blur(3px); }
dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { margin: 5px 0 22px; }
.icon-button { border: 0; font-size: 22px; padding: 0; width: 32px; height: 32px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 8px; }
.secondary { font-size: 12px; padding: 12px 18px; }
.dialog-help { color: var(--muted); font-size: 12px; line-height: 1.5; margin: -10px 0 4px; }

.audit-heading { margin-bottom: 12px; }
.audit-filters { display: grid; grid-template-columns: 220px 1fr; gap: 14px; margin-bottom: 22px; }
.audit-list { display: grid; }
.audit-row {
  display: grid; grid-template-columns: 125px 100px minmax(180px, 1fr) 150px;
  gap: 16px; align-items: center; padding: 14px 4px; border-top: 1px solid #edf0f5;
}
.audit-time strong, .audit-time small { display: block; }
.audit-time strong { font-size: 11px; }
.audit-time small, .audit-resource small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.audit-resource strong { display: block; font-size: 11px; overflow-wrap: anywhere; }
.audit-actor { color: #526079; font-size: 10px; overflow-wrap: anywhere; }
.method-badge {
  justify-self: start; font-size: 9px; font-weight: 850; letter-spacing: .05em;
  padding: 6px 8px; border-radius: 7px; color: #4261a5; background: #edf3ff;
}
.method-badge.put { color: #805d12; background: #fff5d9; }
.method-badge.delete { color: #a33a47; background: #fff0f2; }

@media (max-width: 750px) {
  .audit-filters { grid-template-columns: 1fr; }
  .audit-row { grid-template-columns: 1fr auto; }
  .audit-resource { grid-column: 1 / -1; }
}

@media (max-width: 850px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; padding: 16px; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { margin: 0 18px 0 0; min-width: 170px; }
  nav { display: flex; }
  .stage { display: none; }
  main { padding: 0 18px 40px; }
  .hero { padding: 30px; }
  .stats, .section-grid { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .flow { grid-template-columns: 1fr; }
  .flow b { transform: rotate(90deg); justify-self: center; }
}

@media (max-width: 560px) {
  .sidebar { display: block; }
  .brand { margin-bottom: 14px; }
  nav { overflow-x: auto; }
  .nav-link { white-space: nowrap; }
  .topbar { height: 90px; }
  .connection { display: none; }
  .hero { min-height: 330px; display: block; }
  .hero .primary { margin-top: 28px; }
  .backup-panel { align-items: stretch; flex-direction: column; }
  .backup-actions { align-items: stretch; flex-direction: column-reverse; }
  .stats { grid-template-columns: 1fr; }
}
