:root {
  --navy: #102d42;
  --navy-deep: #0b2334;
  --blue: #176b98;
  --blue-hover: #10557c;
  --cyan: #19a6bb;
  --ink: #203b50;
  --body: #314c5f;
  --muted: #526a7c;
  --line: #d5e0e9;
  --surface: #fff;
  --canvas: #eef3f7;
  --soft: #f6f9fb;
  --focus: #0570ae;
  --radius: 7px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--body);
  background: var(--canvas);
  font: 0.9375rem/1.45 "Segoe UI", Inter, Arial, sans-serif;
}
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { margin: 0 0 1rem; font-size: clamp(1.5rem, 3vw, 1.875rem); }
h2 { margin: 0 0 .75rem; font-size: 1.175rem; }
h3 { font-size: 1rem; }
a { color: var(--blue-hover); text-underline-offset: .15em; }
a:hover { color: var(--blue); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
summary { cursor: pointer; }

.central-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.skip-link {
  position: absolute;
  z-index: 3;
  top: .5rem;
  left: .5rem;
  padding: .5rem .75rem;
  background: var(--surface);
  border-radius: var(--radius);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
.topbar {
  color: #e9f4fa;
  background: var(--navy);
  border-bottom: 2px solid var(--cyan);
}
.topbar-inner, .central-nav-inner, .central-content, .central-footer {
  width: min(100% - clamp(1.5rem, 5vw, 5rem), 1420px);
  margin-inline: auto;
}
.topbar-inner, .brand, .account {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.topbar-inner {
  min-height: 67px;
  justify-content: space-between;
  padding-block: .5rem;
}
.brand { color: inherit; font-weight: 650; text-decoration: none; }
.brand:hover { color: #fff; }
.brand img { display: block; max-width: 100%; height: auto; }
.brand span { padding-left: .75rem; border-left: 1px solid #557185; }
.account { justify-content: flex-end; min-width: 0; }
.account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button {
  padding: .3rem .65rem;
  color: #e9f4fa;
  background: transparent;
  border-color: #6c8a9e;
}
.account button:hover { color: #fff; background: #24465c; border-color: #a0b4c2; }
.topbar :focus-visible { outline-color: #7ce2ee; }

.central-nav { position: relative; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--line); }
.central-nav-inner { display: flex; flex-wrap: wrap; gap: .1rem; }
.central-nav-inner > a, .nav-group > summary {
  display: block;
  min-height: 42px;
  padding: .65rem .75rem .55rem;
  color: var(--ink);
  border-bottom: 2px solid transparent;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.central-nav-inner > a:hover, .nav-group > summary:hover, .nav-group[open] > summary { background: var(--soft); }
.central-nav-inner > a[aria-current], .nav-group.is-current > summary {
  color: var(--blue-hover);
  border-bottom-color: var(--cyan);
}
.nav-group { position: relative; }
.nav-group > summary { list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::after {
  content: "";
  display: inline-block;
  width: .36rem;
  height: .36rem;
  margin: 0 .08rem .18rem .52rem;
  border: solid currentColor;
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.nav-group[open] > summary::after { transform: translateY(.14rem) rotate(225deg); }
.nav-group > ul {
  position: absolute;
  min-width: max-content;
  max-height: min(65vh, 24rem);
  margin: 0;
  padding: .3rem;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px #102d4222;
  list-style: none;
}
.nav-group li a {
  display: block;
  padding: .55rem .7rem;
  color: var(--ink);
  border-radius: 4px;
  text-decoration: none;
}
.nav-group li a:hover, .nav-group li a[aria-current] { color: var(--blue-hover); background: #e8f3fa; }
.nav-group li a:focus-visible { outline-offset: -2px; }
@media (min-width: 801px) {
  .nav-group:nth-last-child(-n+2) > ul { right: 0; }
}
@media (max-width: 800px) {
  .central-nav-inner { position: relative; }
  .nav-group { position: static; }
  .nav-group > ul { top: 100%; right: 0; left: 0; min-width: 0; }
  .central-nav-inner > a, .nav-group > summary { padding-inline: .55rem; }
}

.central-content { flex: 1; padding-block: 1.5rem 2rem; }
.central-footer { padding-block: .75rem 1rem; color: var(--muted); border-top: 1px solid var(--line); font-size: .8rem; }
.card, .scroll, .stat, .module, .empty {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card, .scroll { margin-bottom: 1rem; }
.card, .empty { padding: 1rem; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: .6rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { color: var(--ink); background: var(--soft); font-size: .81rem; }
tbody tr:nth-child(even) { background: #fafcfd; }
tbody tr:last-child td { border-bottom: 0; }
td ul { margin: 0; }
time { white-space: nowrap; }
ul { padding-left: 1.25rem; }
.row, .fields { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; }
.grid, .form-grid, .members, .split { display: grid; gap: .75rem; }
.grid, .form-grid, .members { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13.75rem), 1fr)); }
.split { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.full { grid-column: 1/-1; }
label { display: block; font-weight: 600; }
label > input:not([type=checkbox]):not([type=radio]), label > select { display: block; margin-top: .25rem; }
input, select, textarea, button, .button { font: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea, button, .button {
  max-width: 100%;
  padding: .43rem .63rem;
  border: 1px solid #9aaebb;
  border-radius: 5px;
}
input, select, textarea { color: var(--ink); background: var(--surface); }
input[type=checkbox], input[type=radio] { accent-color: var(--blue); vertical-align: middle; }
textarea { resize: vertical; }
button, .button {
  display: inline-block;
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { color: #fff; background: var(--blue-hover); border-color: var(--blue-hover); }
button.secondary, .button.secondary { color: var(--blue-hover); background: var(--surface); border-color: #9aaebb; }
button.secondary:hover, .button.secondary:hover { color: var(--blue-hover); background: #e8f3fa; }
button:disabled { cursor: not-allowed; opacity: .65; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 5px; }
legend { font-weight: 650; }
small, .muted, .note { color: var(--muted); }
.errorlist, .error, .alert { color: #8d222a; }
.status { padding: .55rem .75rem; background: var(--surface); border-left: 3px solid var(--cyan); }
.table-note { margin-top: 0; }
.checksum, .identifier { max-width: 24rem; overflow-wrap: anywhere; }
.central-content nav { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: .75rem; }

.stats, .modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.25rem), 1fr));
  gap: .75rem;
}
.dashboard h2 { margin: 1.4rem 0 .65rem; }
.stat, .module { padding: .85rem 1rem; }
.stat strong { display: block; margin-top: .25rem; color: var(--ink); font-size: 1.65rem; }
.module { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; }
.tag { display: inline-block; padding: .18rem .5rem; color: var(--ink); background: #edf4f8; border-radius: 1rem; font-size: .78rem; }
.severity, .contact-status { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; }
.severity::before, .contact-status::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: #527589; }
.severity.critical::before, .status-down::before { background: #a62229; }
.severity.warning::before, .status-waiting::before { background: #9b5c07; }
.status-ok::before { background: #17804d; }
.alert-history .filters, .grant-form { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; }
.company-roles { max-width: 1100px; }
.company-roles form { margin-block: .9rem; }
.company-roles fieldset label { font-weight: 400; }
.company-roles li { margin-block: .25rem; }
.device-pairing { max-width: 720px; }
.device-pairing select, .device-pairing input:not([type=hidden]):not([type=checkbox]) { width: 100%; }
.device-pairing label, .field label { margin-bottom: .25rem; }
.policy-queue select, .policy-queue input[type=text], .policy-queue textarea { width: 100%; }
.policy-queue textarea { font-family: monospace; }
.policy-queue pre { max-width: 50ch; max-height: 16rem; margin: .35rem 0 0; padding: .45rem; overflow: auto; background: var(--soft); border: 1px solid var(--line); }
.policy-queue details form { margin-top: .7rem; }
.device-choices { max-height: 12rem; overflow: auto; }
.device-choices label { display: flex; align-items: center; gap: .4rem; font-weight: 400; }
.restore-offers fieldset { padding: 0; border: 0; margin: 0 0 1rem; }
.restore-offers legend { margin-bottom: .5rem; }
.restore-offers fieldset > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.2rem), 1fr)); gap: .4rem; }
.quote { max-width: 1120px; }
.quote .grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.quote .card { align-self: start; }
.quote label { margin: .85rem 0 .25rem; }
.quote input:not([type=checkbox]), .quote select { width: 100%; }
.quote button, .quote .button { margin: .8rem .4rem 0 0; }
.quote #id_modules { max-height: 15rem; overflow-y: auto; padding: .65rem; background: var(--soft); }
.quote #id_modules label { margin: .25rem 0; font-weight: 400; }
.quote td:last-child, .quote dd { text-align: right; }
.quote dl { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.quote dd { margin: 0; }
.quote .total { color: var(--ink); font-size: 1.65rem; font-weight: 700; }
.quote .note { padding: .65rem; background: var(--soft); }
.quote .success { padding: .75rem; color: #20583f; background: #e2f1eb; border-radius: var(--radius); }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(.75rem, 4vw, 2rem);
  background: radial-gradient(ellipse at 20% 20%, #f9fbfd, var(--canvas) 70%);
}
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 55rem);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 44px #102d421c;
}
.login-brand, .login-form { padding: clamp(1.3rem, 5vw, 2.75rem); }
.login-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #e0edf5;
  background: linear-gradient(145deg, var(--navy), var(--navy-deep));
  border-top: 3px solid var(--cyan);
}
.login-brand img { display: block; max-width: 100%; height: auto; margin-bottom: 1.45rem; }
.login-brand p { margin: 0 0 .65rem; }
.login-brand .login-caption { color: #a7deea; font-size: .77rem; font-weight: 650; letter-spacing: .11em; text-transform: uppercase; }
.login-brand .login-lead { color: #fff; font-size: clamp(1.55rem, 4vw, 2.3rem); font-weight: 650; line-height: 1.13; }
.login-brand small { margin-top: 1.5rem; color: #c8dce8; }
.login-form { display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { margin-bottom: .6rem; }
.login-form form > p { margin: .9rem 0; }
.login-form label { margin-bottom: .3rem; }
.login-form input, .login-form button { width: 100%; min-height: 42px; }
.login-form button { margin-top: .45rem; }

@media (max-width: 660px) {
  .topbar-inner { min-height: 56px; gap: .5rem; }
  .brand { gap: .35rem; }
  .brand img { width: clamp(7rem, 28vw, 10.5rem); }
  .brand span { padding-left: .35rem; font-size: .8rem; }
  .account { gap: .4rem; font-size: .8rem; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand img { width: min(100%, 230px); margin-bottom: .9rem; }
  .login-brand small { margin-top: .5rem; }
}
