:root {
  color-scheme: dark;
  --bg: #090c11;
  --surface: #11161e;
  --surface-2: #171d27;
  --line: rgba(255,255,255,.09);
  --text: #f4f7fb;
  --muted: #929cab;
  --accent: #86f6c7;
  --accent-dark: #072d21;
  --danger: #ff8d8d;
  --danger-dark: #2d0d0d;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 15%, rgba(74, 222, 168, .09), transparent 28rem),
    radial-gradient(circle at 90% 80%, rgba(80, 120, 255, .08), transparent 30rem),
    var(--bg);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { width: min(920px, calc(100% - 32px)); min-height: 100vh; margin: auto; display: grid; place-items: center; padding: 32px 0; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; color: #07110d; background: var(--accent); border-radius: 9px; font-weight: 900; }

.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: rgba(17,22,30,.88); box-shadow: 0 30px 80px rgba(0,0,0,.35); backdrop-filter: blur(18px); }
.login-copy { margin: 48px 0 28px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(28px, 5vw, 40px); line-height: 1.03; letter-spacing: -.045em; }
label { display: block; margin: 16px 0 8px; color: #c8ced8; font-size: 13px; font-weight: 650; }
label:first-of-type { margin-top: 0; }
.password-label { margin-top: 16px; }
input, select { width: 100%; height: 48px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--text); background: #0c1118; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(134,246,199,.1); }
input:disabled, select:disabled { opacity: .45; cursor: not-allowed; }
.primary { width: 100%; height: 48px; margin-top: 16px; padding: 0 17px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; color: #06150f; background: var(--accent); font-weight: 800; }
.primary.compact { width: auto; height: 38px; margin-top: 0; padding: 0 14px; font-size: 13px; }
.primary:disabled { opacity: .6; cursor: wait; }
.error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.dashboard { width: 100%; align-self: start; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; gap: 10px; }
.ghost { padding: 8px 13px; border: 1px solid var(--line); border-radius: 9px; color: #cfd5df; background: transparent; height: 38px; }
.ghost:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.04); }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding: 44px 0 28px; }
.hero h1 { margin-bottom: 0; }
.count { color: var(--muted); font-size: 13px; }

.clients-list { display: grid; gap: 10px; padding-bottom: 48px; }
.client-row { min-width: 0; padding: 18px 20px; display: grid; grid-template-columns: minmax(0,1fr) 150px 220px 190px; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.client-main { min-width: 0; }
.client-name { font-weight: 750; margin-bottom: 3px; }
.client-notes { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-name { margin-top: 6px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 700; }
.copy-name:hover { border-color: var(--accent); color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-dark); white-space: nowrap; }
.badge.warn { color: var(--danger); background: var(--danger-dark); }
.expiry-cell { font-size: 13px; }
.expiry-cell.expired { color: var(--danger); font-weight: 700; }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-actions button { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface-2); font-size: 12px; font-weight: 700; }
.row-actions button:hover { border-color: var(--accent); color: var(--accent); }
.row-actions button.danger:hover { border-color: var(--danger); color: var(--danger); }
.empty { padding: 40px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; }

.loading { display: flex; gap: 7px; }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse .9s infinite alternate; }
.loading span:nth-child(2) { animation-delay: .2s; }
.loading span:nth-child(3) { animation-delay: .4s; }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 10px; opacity: 0; transform: translateY(8px); pointer-events: none; background: #202833; box-shadow: 0 12px 30px rgba(0,0,0,.3); transition: .2s; z-index: 20; }
.toast.show { opacity: 1; transform: translateY(0); }

.form-dialog { width: min(460px, calc(100% - 28px)); padding: 24px; border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: #11161e; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.form-dialog::backdrop { background: rgba(3,6,10,.78); backdrop-filter: blur(5px); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.dialog-close { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-2); font-size: 22px; line-height: 1; }
.dialog-close:hover { color: var(--text); }
fieldset { margin: 18px 0 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 4px; color: var(--text); font-weight: 600; }
.checkbox-row input { width: 18px; height: 18px; flex: none; }
.checkbox-row .protocol-tag { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.protocol-list { display: flex; flex-direction: column; max-height: 220px; overflow-y: auto; }
.protocol-list .empty { padding: 10px 4px; color: var(--muted); font-size: 13px; }
fieldset > *:last-child { margin-bottom: 0; }

@keyframes pulse { to { opacity: .25; transform: translateY(-4px); } }
@media (max-width: 720px) {
  .shell { width: min(100% - 24px, 920px); padding: 12px 0 28px; }
  .login-card { padding: 24px; border-radius: 19px; }
  .hero { flex-direction: column; align-items: start; gap: 8px; }
  .client-row { grid-template-columns: 1fr; }
  .row-actions { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
