:root {
  color-scheme: dark;
  --page: #08111f;
  --page-raised: #0b1626;
  --surface: #101d30;
  --surface-raised: #14243a;
  --surface-subtle: #0d1929;
  --border: #283a51;
  --border-strong: #3b5069;
  --text: #e8eef7;
  --text-soft: #c3cfdd;
  --muted: #96a8bd;
  --accent: #58d7c2;
  --accent-strong: #79e5d3;
  --accent-ink: #05251f;
  --accent-subtle: rgba(88, 215, 194, 0.1);
  --danger: #f58b8b;
  --danger-strong: #ffaaaa;
  --danger-ink: #2b0808;
  --danger-subtle: rgba(245, 139, 139, 0.1);
  --warning: #e8bf72;
  --warning-subtle: rgba(232, 191, 114, 0.09);
  --focus: #73e5f2;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --radius: 0.85rem;
  --radius-small: 0.5rem;
  --content-width: 1440px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(39, 99, 117, 0.13), transparent 32rem),
    var(--page);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: var(--accent-strong);
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p,
dl,
dd {
  margin-top: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
}

h2 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.35rem, 2vw, 1.65rem);
}

h3 {
  margin-bottom: 0.4rem;
  font-size: 1.05rem;
}

h4 {
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.main-content:focus {
  outline: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
  text-decoration: none;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.4rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  line-height: 1.4;
  text-transform: uppercase;
}

.danger-text {
  color: var(--danger);
}

.button {
  position: relative;
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.button-primary:hover:not(:disabled) {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: #193047;
}

.button-quiet {
  border-color: var(--border);
  background: transparent;
  color: var(--text-soft);
}

.button-quiet:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--text);
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--danger-ink);
}

.button-danger:hover:not(:disabled) {
  border-color: var(--danger-strong);
  background: var(--danger-strong);
}

.button-small {
  min-height: 2.25rem;
  padding: 0.45rem 0.62rem;
  font-size: 0.78rem;
}

.button-full {
  width: 100%;
}

.button.is-busy::before {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 750ms linear infinite;
}

.icon-button {
  display: inline-flex;
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.65rem;
  line-height: 1;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.spinner {
  width: 1.6rem;
  height: 1.6rem;
  flex: 0 0 auto;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.spinner-large {
  width: 2rem;
  height: 2rem;
  margin: 0 auto 1.25rem;
}

.refresh-glyph {
  display: inline-block;
  font-size: 1.15rem;
  line-height: 1;
}

.button.is-busy .refresh-glyph {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.boot-view,
.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
}

.boot-card,
.login-card {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 5vw, 2.35rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.boot-card {
  text-align: center;
}

.boot-card .button {
  margin-top: 0.75rem;
}

.login-heading {
  margin-bottom: 1.7rem;
}

.login-heading .muted {
  margin-bottom: 0;
}

.login-note {
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.8rem;
}

.form-stack {
  display: grid;
  gap: 1.1rem;
}

.field {
  display: grid;
  gap: 0.45rem;
}

.field label {
  color: var(--text-soft);
  font-size: 0.875rem;
  font-weight: 700;
}

.field input:not(.file-input) {
  width: 100%;
  min-height: 2.85rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
  color: var(--text);
  caret-color: var(--accent);
}

.field input:not(.file-input):hover {
  border-color: #526a84;
}

.field input:not(.file-input):focus {
  border-color: var(--focus);
}

.field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.field input:read-only {
  color: var(--muted);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.form-error {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(245, 139, 139, 0.45);
  border-radius: var(--radius-small);
  background: var(--danger-subtle);
  color: var(--danger-strong);
  font-size: 0.875rem;
}

.file-input {
  width: 100%;
  padding: 0.65rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.85rem;
}

.file-input::file-selector-button {
  min-height: 2.4rem;
  margin-right: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.4rem;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.file-input:hover,
.file-input::file-selector-button:hover {
  border-color: var(--accent);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 17, 31, 0.94);
}

.header-inner {
  display: flex;
  width: min(100%, var(--content-width));
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0 auto;
  padding: 1.15rem clamp(1rem, 3vw, 2rem);
}

.brand-block {
  flex: 0 0 auto;
}

.brand-block .eyebrow,
.brand {
  margin-bottom: 0;
}

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.025em;
}

.header-session {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.1rem;
}

.signed-in {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.signed-in strong {
  color: var(--text-soft);
  font-weight: 650;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.main-content {
  width: 100%;
}

.dashboard-view {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2rem);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.summary-card {
  position: relative;
  overflow: hidden;
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.summary-card::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: var(--accent);
  content: "";
  opacity: 0.8;
}

.summary-card dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.summary-card dd:not(.summary-note) {
  margin: 0.25rem 0 0;
  color: var(--text);
  font-size: 1.8rem;
  font-weight: 750;
  line-height: 1.2;
}

.summary-card .summary-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.clients-panel {
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.13);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin-bottom: 0.5rem;
}

.section-description {
  max-width: 47rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.refresh-meta {
  flex: 0 0 auto;
  text-align: right;
}

.refresh-meta p {
  margin-bottom: 0.2rem;
  font-size: 0.78rem;
}

.refresh-note {
  color: var(--muted);
}

.notice {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-size: 0.85rem;
}

.notice p {
  margin: 0.25rem 0 0;
  overflow-wrap: anywhere;
}

.notice-warning {
  border-color: rgba(232, 191, 114, 0.35);
  background: var(--warning-subtle);
  color: var(--warning);
}

.state-block {
  display: flex;
  min-height: 9rem;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
  text-align: left;
}

.state-block h3,
.state-block p {
  margin-bottom: 0.2rem;
}

.state-error {
  color: var(--danger-strong);
}

.state-error .button {
  flex: 0 0 auto;
}

.state-block.compact {
  min-height: 0;
  padding: 1.25rem 0.75rem;
  text-align: center;
}

.state-block.compact,
.qr-preview .state-error {
  flex-direction: column;
}

.client-group {
  padding-top: 1.5rem;
}

.client-group + .client-group {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.group-heading h3 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.group-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.count-badge {
  display: inline-flex;
  min-width: 1.55rem;
  min-height: 1.45rem;
  align-items: center;
  justify-content: center;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 700;
}

.empty-state {
  padding: 1.5rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
  text-align: center;
}

.empty-state p {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.empty-state .button {
  margin-top: 0.15rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.clients-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  background: var(--surface-subtle);
  font-size: 0.82rem;
}

.clients-table th,
.clients-table td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.clients-table th {
  background: var(--surface-raised);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.clients-table tbody tr:last-child td {
  border-bottom: 0;
}

.clients-table tbody tr {
  transition: background-color 150ms ease;
}

.clients-table tbody tr:hover {
  background: rgba(46, 74, 101, 0.16);
}

.revoked-group .clients-table tbody tr {
  background: rgba(8, 17, 31, 0.22);
}

.revoked-group .client-name {
  color: var(--text-soft);
}

.client-name {
  display: block;
  max-width: 14rem;
  color: var(--text);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.client-subline {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.ip-list {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ip-list code {
  color: var(--text-soft);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  overflow-wrap: anywhere;
}

.date-value {
  color: var(--text-soft);
  white-space: nowrap;
}

.config-badge,
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.config-badge.available,
.result-badge.success {
  border-color: rgba(88, 215, 194, 0.35);
  background: var(--accent-subtle);
  color: var(--accent-strong);
}

.config-badge.unavailable,
.result-badge.failure {
  border-color: rgba(245, 139, 139, 0.28);
  background: var(--danger-subtle);
  color: var(--danger-strong);
}

.table-actions {
  display: flex;
  min-width: 14rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.table-actions .button {
  flex: 0 0 auto;
}

.action-revoke {
  border-color: rgba(245, 139, 139, 0.35);
  color: var(--danger-strong);
}

.action-revoke:hover:not(:disabled) {
  border-color: var(--danger);
  background: var(--danger-subtle);
}

.dashboard-footer {
  padding: 1rem 0.25rem 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.dashboard-footer p {
  margin-bottom: 0;
}

.dialog {
  width: min(calc(100% - 2rem), 32rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: clamp(1.2rem, 3vw, 1.6rem);
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.dialog::backdrop {
  background: rgba(2, 8, 16, 0.78);
  backdrop-filter: blur(3px);
}

.dialog-small {
  width: min(calc(100% - 2rem), 29rem);
}

.dialog-wide {
  width: min(calc(100% - 2rem), 44rem);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}

.dialog-header h2,
.dialog-header .eyebrow {
  margin-bottom: 0;
}

.dialog-header .icon-button {
  margin-top: -0.45rem;
  margin-right: -0.45rem;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.danger-summary {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(245, 139, 139, 0.35);
  border-radius: var(--radius-small);
  background: var(--danger-subtle);
}

.danger-summary span {
  color: var(--danger-strong);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.danger-summary strong {
  overflow-wrap: anywhere;
}

.qr-client-name {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
}

.qr-client-name strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.qr-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) minmax(12rem, 0.8fr);
  align-items: center;
  gap: 1.25rem;
}

.qr-preview {
  display: grid;
  min-height: 19rem;
  place-items: center;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
}

.qr-image {
  width: min(100%, 280px);
  height: auto;
  padding: 0.5rem;
  border-radius: 0.35rem;
  background: #ffffff;
}

.download-panel h3 {
  margin-bottom: 0.5rem;
}

.download-panel p {
  color: var(--muted);
  font-size: 0.85rem;
}

.download-actions {
  display: grid;
  gap: 0.6rem;
}

.selected-files,
.import-results {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-subtle);
}

.selected-files h3,
.import-results h3 {
  font-size: 0.95rem;
}

.selected-files p,
.import-results > p {
  margin-bottom: 0.65rem;
  font-size: 0.8rem;
}

.selected-files ul,
.import-results-list {
  display: grid;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.selected-files li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.selected-files .file-name {
  overflow-wrap: anywhere;
}

.selected-files .file-size {
  flex: 0 0 auto;
  color: var(--muted);
}

.import-results {
  margin-top: 1.25rem;
}

.import-results-list {
  max-height: 16rem;
  overflow-y: auto;
}

.import-result {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
}

.import-result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.import-result-header strong {
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

.import-result p {
  margin: 0.45rem 0 0;
  color: var(--text-soft);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.import-result.failed {
  border-color: rgba(245, 139, 139, 0.3);
}

.toast-region {
  position: fixed;
  z-index: 1100;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  width: min(calc(100% - 2rem), 24rem);
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-small);
  background: #14243a;
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.info {
  border-left-color: var(--focus);
}

.toast-kind {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--accent-strong);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.toast.error .toast-kind {
  color: var(--danger-strong);
}

.toast.info .toast-kind {
  color: var(--focus);
}

.toast-message {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.toast .icon-button {
  width: 2rem;
  height: 2rem;
  margin: -0.35rem -0.45rem 0 0;
  font-size: 1.3rem;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.noscript-message {
  position: fixed;
  z-index: 1200;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  padding: 1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--danger-strong);
  text-align: center;
}

@media (max-width: 1100px) {
  .header-inner,
  .header-session {
    align-items: flex-start;
  }

  .header-session {
    flex-direction: column;
    gap: 0.5rem;
  }

  .signed-in {
    align-self: flex-end;
  }

  .panel-heading {
    gap: 1rem;
  }
}

@media (max-width: 800px) {
  .header-inner {
    flex-direction: column;
    gap: 1rem;
  }

  .header-session {
    width: 100%;
  }

  .signed-in {
    align-self: flex-start;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .panel-heading {
    flex-direction: column;
  }

  .refresh-meta {
    text-align: left;
  }

  .qr-layout {
    grid-template-columns: 1fr;
  }

  .download-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .summary-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 0.9rem 1rem;
  }

  .summary-card dt,
  .summary-card dd {
    grid-column: 1;
  }

  .summary-card dd:not(.summary-note) {
    grid-row: 1 / span 2;
    grid-column: 2;
    margin: 0;
    font-size: 1.55rem;
  }

  .summary-card .summary-note {
    margin-top: 0.2rem;
  }

  .clients-panel {
    padding: 1rem;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .clients-table,
  .clients-table tbody,
  .clients-table tr,
  .clients-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .clients-table {
    background: transparent;
  }

  .clients-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .clients-table tbody {
    display: grid;
    gap: 0.85rem;
  }

  .clients-table tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface-subtle);
  }

  .clients-table th,
  .clients-table td {
    padding: 0.7rem 0.85rem;
  }

  .clients-table td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 36%) minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
  }

  .clients-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .clients-table tbody tr:hover {
    background: var(--surface-subtle);
  }

  .client-name {
    max-width: none;
  }

  .date-value {
    white-space: normal;
  }

  .table-actions {
    min-width: 0;
  }

  .clients-table td.action-cell {
    display: block;
    background: rgba(20, 36, 58, 0.45);
  }

  .clients-table td.action-cell::before {
    display: block;
    margin-bottom: 0.65rem;
  }

  .state-block:not(.compact) {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 520px) {
  .header-actions {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-actions .button {
    width: 100%;
  }

  .dashboard-view {
    padding: 1rem 0.75rem;
  }

  .clients-panel {
    padding: 0.85rem;
  }

  .clients-table td {
    grid-template-columns: 6.6rem minmax(0, 1fr);
    gap: 0.5rem;
  }

  .table-actions .button {
    flex: 1 1 auto;
  }

  .dialog {
    width: calc(100% - 1rem);
    max-height: calc(100dvh - 1rem);
    padding: 1rem;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .dialog-actions .button {
    width: 100%;
  }

  .dialog-actions .button-primary,
  .dialog-actions .button-danger {
    grid-row: 1;
  }

  .download-actions {
    grid-template-columns: 1fr;
  }

  .qr-preview {
    min-height: 16rem;
  }

  .selected-files li {
    flex-direction: column;
    gap: 0.15rem;
  }

  .toast-region {
    right: 0.5rem;
    bottom: 0.5rem;
    width: calc(100% - 1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (forced-colors: active) {
  .summary-card::after {
    background: CanvasText;
  }

  .config-badge,
  .result-badge,
  .notice,
  .toast,
  .danger-summary,
  .form-error {
    border: 1px solid CanvasText;
  }
}
