:root {
  --blue-900: #092b73;
  --blue-800: #0d3f9c;
  --blue-700: #1154c7;
  --blue-600: #0c75df;
  --blue-500: #0b9ff2;
  --blue-100: #eaf5ff;
  --ink: #17243a;
  --muted: #66758d;
  --line: #dce5f0;
  --surface: #ffffff;
  --page: #f4f7fb;
  --green: #14865d;
  --green-soft: #e7f7f0;
  --orange: #d56a16;
  --orange-soft: #fff2e5;
  --violet: #7557d5;
  --violet-soft: #f1edff;
  --danger: #c83c49;
  --danger-soft: #fff0f2;
  --shadow: 0 18px 45px rgba(22, 52, 92, .10);
  --radius: 18px;
  --gradient: linear-gradient(135deg, var(--blue-500), var(--blue-700) 58%, var(--blue-900));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: var(--page); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.75rem, 3vw, 2.55rem); line-height: 1.1; letter-spacing: -.035em; }
h2 { margin-bottom: 6px; font-size: 1.22rem; letter-spacing: -.015em; }
p { color: var(--muted); line-height: 1.6; }
small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.45; }
code { font-family: "SFMono-Regular", Consolas, monospace; }

.button {
  display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border: 1px solid transparent; border-radius: 11px; font-weight: 750;
  text-decoration: none; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--gradient); box-shadow: 0 9px 20px rgba(14, 95, 206, .24); }
.button-secondary { color: var(--blue-800); background: #fff; border-color: #cad8e9; }
.button-secondary:hover { border-color: var(--blue-500); }
.button-large { min-width: 190px; min-height: 50px; padding-inline: 22px; }
.button-block { width: 100%; }
.text-button { border: 0; padding: 5px; color: var(--blue-700); background: transparent; font-weight: 750; }
.text-button.danger { color: var(--danger); }
.mini-button { border: 1px solid #cbd8e8; border-radius: 8px; padding: 6px 10px; color: var(--blue-800); background: #fff; font-size: .77rem; font-weight: 750; white-space: nowrap; }
.mini-button:hover { border-color: var(--blue-500); background: var(--blue-100); }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--blue-800); font-weight: 800; }

.app-header {
  position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  min-height: 72px; padding: 12px clamp(18px, 4vw, 52px); border-bottom: 1px solid rgba(206, 219, 235, .85);
  background: rgba(255, 255, 255, .94); box-shadow: 0 5px 22px rgba(23, 48, 82, .06); backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { flex: 0 0 auto; filter: drop-shadow(0 7px 10px rgba(17, 84, 199, .2)); }
.brand strong, .brand span { display: block; }
.brand strong { color: var(--blue-900); font-size: 1.02rem; }
.brand span { margin-top: 2px; color: var(--muted); font-size: .75rem; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.storage-badge { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 999px; color: #36604f; background: var(--green-soft); font-size: .76rem; font-weight: 700; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2ca878; box-shadow: 0 0 0 4px rgba(44,168,120,.12); }
.user-menu { display: flex; align-items: center; gap: 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.user-menu span, .user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: .8rem; }
.user-menu form { margin: 0; }

.app-main, .admin-main { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 52px; }
.intro-row { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-bottom: 24px; }
.intro-row > div:first-child { max-width: 760px; }
.intro-row p:last-child { margin-bottom: 0; }
.eyebrow { margin-bottom: 8px; color: var(--blue-700); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.eyebrow.light { color: #bfeaff; }
.stepper { display: flex; align-items: center; gap: 0; margin: 0; padding: 0; list-style: none; }
.stepper li { position: relative; display: flex; align-items: center; gap: 7px; color: #7b89a0; font-size: .78rem; font-weight: 750; white-space: nowrap; }
.stepper li:not(:last-child)::after { width: 42px; height: 1px; margin: 0 10px; background: #cfdbe9; content: ""; }
.stepper span { display: grid; width: 28px; height: 28px; place-items: center; border: 1px solid #cfdae8; border-radius: 50%; background: #fff; }
.stepper .active { color: var(--blue-700); }
.stepper .active span { color: #fff; border-color: transparent; background: var(--gradient); box-shadow: 0 6px 14px rgba(17, 84, 199, .23); }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 11px 35px rgba(33, 58, 91, .065); }
.search-card { padding: 24px; }
.section-heading, .results-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 19px; }
.section-heading p, .results-header p { margin-bottom: 0; font-size: .86rem; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.location-grid { grid-template-columns: .75fr .9fr minmax(280px, 1.7fr) .65fr; }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field > span { color: #34445d; font-size: .77rem; font-weight: 780; }
.field > span small { display: inline; margin-left: 4px; font-weight: 500; }
.field input, .field select, .field textarea, .search-filter input, .compact-field select, .password-reset-form input {
  width: 100%; min-width: 0; border: 1px solid #cdd9e7; border-radius: 10px; outline: none; color: var(--ink); background: #fbfdff;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.field input, .field select { min-height: 43px; padding: 9px 11px; }
.field textarea { resize: vertical; min-height: 94px; padding: 11px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .search-filter input:focus, .compact-field select:focus, .password-reset-form input:focus { border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 4px rgba(11,159,242,.11); }
.keyword-field { margin-top: 15px; }
.search-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e8eef5; }
.check-field { display: flex; align-items: flex-start; gap: 10px; }
.check-field input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--blue-600); }
.check-field strong, .check-field small { display: block; }
.check-field strong { font-size: .82rem; }
.progress-panel { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.7fr) 44px; align-items: center; gap: 18px; margin-top: 18px; padding: 14px 16px; border: 1px solid #cce8fb; border-radius: 12px; background: #f4fbff; }
.progress-copy strong, .progress-copy span { display: block; }
.progress-copy strong { color: var(--blue-900); font-size: .8rem; }
.progress-copy span { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: #dbe9f5; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gradient); transition: width .25s ease; }
.progress-panel > span { color: var(--blue-700); font-size: .76rem; font-weight: 800; text-align: right; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric-card { display: flex; align-items: center; gap: 13px; min-height: 92px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 8px 25px rgba(30,55,91,.05); }
.metric-icon { display: grid; flex: 0 0 auto; width: 43px; height: 43px; place-items: center; border-radius: 12px; font-size: 1rem; font-weight: 900; }
.metric-icon.blue { color: var(--blue-700); background: var(--blue-100); }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.violet { color: var(--violet); background: var(--violet-soft); }
.metric-icon.orange { color: var(--orange); background: var(--orange-soft); }
.metric-card div > span, .metric-card div > strong, .metric-card div > small { display: block; }
.metric-card div > span { color: var(--muted); font-size: .73rem; font-weight: 650; }
.metric-card div > strong { margin-top: 2px; color: var(--blue-900); font-size: 1.55rem; line-height: 1.05; }

.results-card { overflow: hidden; }
.results-header { align-items: center; padding: 20px 22px 17px; }
.export-actions { display: flex; gap: 9px; }
.filter-bar { display: grid; grid-template-columns: minmax(260px, 1fr) 130px 140px auto; align-items: end; gap: 11px; padding: 12px 22px; border-block: 1px solid #e7edf4; background: #f9fbfd; }
.search-filter input { min-height: 40px; padding: 8px 11px; }
.compact-field { display: grid; gap: 4px; color: var(--muted); font-size: .68rem; font-weight: 750; }
.compact-field select { min-height: 40px; padding: 7px 9px; color: var(--ink); }
.table-shell { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 13px; color: #6b7990; background: #fbfcfe; font-size: .68rem; letter-spacing: .045em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { max-width: 290px; padding: 13px; border-top: 1px solid #e8eef5; color: #34445b; font-size: .78rem; vertical-align: middle; }
td strong, td small { display: block; }
td strong { overflow: hidden; color: var(--ink); font-size: .79rem; text-overflow: ellipsis; }
td small { margin-top: 3px; }
td a { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.type-pill, .score-pill, .status-pill, .count-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-size: .69rem; font-weight: 800; }
.type-pill { max-width: 190px; padding: 6px 9px; color: #30557d; background: #eef5fc; line-height: 1.25; text-align: center; }
.score-pill { min-width: 35px; padding: 6px 8px; }
.score-pill.high { color: #096b4a; background: #dff6ec; }
.score-pill.good { color: #2b6a3f; background: #ebf7df; }
.score-pill.medium { color: #90610d; background: #fff3cc; }
.score-pill.low { color: #7b5e64; background: #f3edef; }
.scan-button { display: block; margin-top: 6px; }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state > span { display: grid; width: 50px; height: 50px; margin: 0 auto 12px; place-items: center; border-radius: 15px; color: var(--blue-700); background: var(--blue-100); font-size: 1.6rem; }
.empty-state strong { display: block; color: var(--blue-900); }
.empty-state p { margin: 5px 0 0; font-size: .84rem; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 13px 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .76rem; }
.pagination > div { display: flex; align-items: center; gap: 9px; }
.pagination > div span { min-width: 24px; text-align: center; font-weight: 800; }

.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px clamp(20px,4vw,52px); border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: .74rem; }
.app-footer a { font-weight: 800; }

dialog { width: min(570px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 18px; background: transparent; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(7, 23, 50, .55); backdrop-filter: blur(3px); }
.dialog-card { width: 100%; border-radius: 18px; background: #fff; overflow: hidden; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin-bottom: 0; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 9px; color: #607087; background: #eff3f8; font-size: 1.35rem; }
.dialog-body { padding: 20px 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }
.secret-field { display: grid; grid-template-columns: 1fr auto; }
.secret-field input { border-radius: 10px 0 0 10px; }
.secret-field button { min-width: 66px; border: 1px solid #cdd9e7; border-left: 0; border-radius: 0 10px 10px 0; color: var(--blue-700); background: #f2f7fc; font-size: .74rem; font-weight: 750; }
.info-box, .warning-box, .configured-key { margin-top: 14px; padding: 13px 15px; border: 1px solid #cfe6f7; border-radius: 11px; background: #f2faff; font-size: .78rem; }
.info-box strong, .info-box p { display: block; }
.info-box ul { margin: 8px 0; padding-left: 19px; color: #42536b; }
.info-box p { margin-bottom: 0; font-size: .75rem; }
.configured-key { margin: 0 0 14px; color: var(--green); border-color: #bfe8d5; background: var(--green-soft); font-weight: 750; }
.test-status { margin-top: 13px; padding: 10px 12px; border-radius: 9px; font-size: .77rem; }
.test-status.success { color: var(--green); background: var(--green-soft); }
.test-status.error { color: var(--danger); background: var(--danger-soft); }
.test-status.pending { color: var(--blue-700); background: var(--blue-100); }
.details-card { max-height: 85vh; overflow-y: auto; }
.details-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-item { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafcfe; }
.detail-item strong { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: .8rem; }
.detail-links { display: flex; grid-column: 1 / -1; gap: 9px; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 32px)); padding: 13px 17px; border-radius: 12px; color: #fff; background: #176b50; box-shadow: 0 14px 38px rgba(10,35,66,.28); font-size: .82rem; font-weight: 700; }
.toast.error { background: #a93642; }

.alert { margin-bottom: 15px; padding: 11px 13px; border-radius: 10px; font-size: .8rem; line-height: 1.5; }
.alert-error { color: #9e2e3a; border: 1px solid #f0c5ca; background: var(--danger-soft); }
.alert-success { color: #106a4a; border: 1px solid #bce6d2; background: var(--green-soft); }
.wide-alert { margin-bottom: 20px; }

.auth-page { display: grid; place-items: center; padding: 30px; background: radial-gradient(circle at 10% 10%, rgba(11,159,242,.18), transparent 30%), radial-gradient(circle at 90% 90%, rgba(18,73,201,.15), transparent 35%), #edf4fb; }
.auth-shell, .install-shell { display: grid; width: min(960px, 100%); grid-template-columns: .95fr 1.05fr; overflow: hidden; border: 1px solid rgba(255,255,255,.65); border-radius: 26px; box-shadow: 0 28px 75px rgba(14,48,91,.18); }
.install-shell { width: min(1050px, 100%); }
.auth-brand-panel { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 540px; padding: clamp(34px,6vw,70px); color: #fff; background: var(--gradient); overflow: hidden; }
.auth-brand-panel::after { position: absolute; right: -80px; bottom: -90px; width: 260px; height: 260px; border: 40px solid rgba(255,255,255,.08); border-radius: 50%; content: ""; }
.auth-brand-panel img { margin-bottom: 28px; border: 1px solid rgba(255,255,255,.28); border-radius: 16px; box-shadow: 0 15px 35px rgba(1,24,71,.2); }
.auth-brand-panel h1 { position: relative; z-index: 1; color: #fff; }
.auth-brand-panel p { position: relative; z-index: 1; color: #dceeff; }
.auth-brand-panel .eyebrow { color: #bfeaff; }
.security-note { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; margin-top: 25px; color: #ddf8ec; font-size: .78rem; font-weight: 750; }
.security-note span { color: #73efbd; }
.secure-list { position: relative; z-index: 1; margin: 18px 0 0; padding: 0; list-style: none; }
.secure-list li { margin: 10px 0; padding-left: 25px; color: #e6f5ff; font-size: .8rem; line-height: 1.45; }
.secure-list li::before { position: absolute; margin-left: -24px; color: #76efbd; content: "✓"; font-weight: 900; }
.auth-card { display: flex; flex-direction: column; justify-content: center; min-height: 540px; padding: clamp(32px,6vw,68px); background: #fff; }
.auth-card h2 { font-size: 1.65rem; }
.auth-card .muted { margin-bottom: 24px; font-size: .86rem; }
.stack-form { display: grid; gap: 14px; }
.auth-help { margin: 20px 0 0; font-size: .75rem; text-align: center; }
.compact-auth .auth-brand-panel, .compact-auth .auth-card { min-height: 500px; }
.licence-input { text-transform: uppercase; letter-spacing: .08em; }
.inline-logout { margin-top: 15px; text-align: center; }
.install-card { justify-content: flex-start; max-height: 90vh; overflow-y: auto; padding-block: 38px; }
.form-section-title { margin-top: 5px; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--blue-800); font-size: .72rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.success-mark { display: grid; width: 64px; height: 64px; margin-bottom: 20px; place-items: center; border-radius: 18px; color: #fff; background: linear-gradient(135deg,#27b47e,#0f7554); font-size: 1.8rem; box-shadow: 0 14px 30px rgba(20,134,93,.2); }
.warning-box { color: #8b5b12; border-color: #f0d09b; background: #fff8e9; line-height: 1.5; }

.admin-main { width: min(1500px, calc(100% - 40px)); }
.owner-badge { padding: 9px 13px; border: 1px solid #c9e2f7; border-radius: 999px; color: var(--blue-700); background: var(--blue-100); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.admin-form-card { padding: 22px; }
.new-key-card { margin-bottom: 18px; padding: 20px 22px; border: 1px solid #acdcca; border-radius: var(--radius); background: linear-gradient(135deg,#effbf6,#fff); box-shadow: 0 10px 28px rgba(20,134,93,.09); }
.new-key-card code { display: block; margin: 13px 0 8px; padding: 14px; border: 1px dashed #54b78f; border-radius: 11px; color: #07543c; background: #fff; font-size: clamp(.9rem,2vw,1.25rem); font-weight: 850; letter-spacing: .08em; overflow-wrap: anywhere; }
.new-key-card p:last-child { margin-bottom: 0; font-size: .8rem; }
.admin-table-card { margin-top: 18px; padding: 20px 20px 0; overflow: hidden; }
.count-pill { padding: 6px 10px; color: var(--blue-700); background: var(--blue-100); }
.status-pill { padding: 5px 9px; }
.status-pill.active { color: var(--green); background: var(--green-soft); }
.status-pill.suspended, .status-pill.revoked { color: var(--danger); background: var(--danger-soft); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.row-actions form { margin: 0; }
.password-reset-form { display: flex; gap: 5px; }
.password-reset-form input { width: 170px; min-height: 31px; padding: 5px 8px; font-size: .74rem; }
.empty-cell { padding: 35px; color: var(--muted); text-align: center; }

@media (max-width: 1100px) {
  .location-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .field-wide { grid-column: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .filter-bar { grid-template-columns: 1fr 120px 130px; }
  .filter-bar .danger { grid-column: 1 / -1; justify-self: end; }
  .storage-badge { display: none; }
}

@media (max-width: 780px) {
  .app-header { position: static; align-items: flex-start; padding: 12px 16px; }
  .header-actions { align-items: flex-end; flex-direction: column-reverse; gap: 7px; }
  .header-actions > .button { min-height: 36px; padding: 7px 10px; font-size: .72rem; }
  .user-menu { align-items: flex-end; flex-direction: column; gap: 1px; border-left: 0; }
  .user-menu > span { display: none; }
  .app-main, .admin-main { width: min(100% - 24px, 1480px); padding-top: 22px; }
  .intro-row { align-items: flex-start; flex-direction: column; }
  .stepper { width: 100%; justify-content: space-between; }
  .stepper li:not(:last-child)::after { width: clamp(18px, 7vw, 42px); margin-inline: 5px; }
  .search-actions, .results-header, .section-heading { align-items: stretch; flex-direction: column; }
  .button-large { width: 100%; }
  .progress-panel { grid-template-columns: 1fr 44px; }
  .progress-track { grid-column: 1 / -1; grid-row: 2; }
  .export-actions { width: 100%; }
  .export-actions .button { flex: 1; }
  .auth-page { padding: 15px; }
  .auth-shell, .install-shell { grid-template-columns: 1fr; }
  .auth-brand-panel { min-height: auto; padding: 32px; }
  .auth-brand-panel img { margin-bottom: 18px; }
  .auth-card { min-height: auto; padding: 32px; }
  .install-card { max-height: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .app-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  .brand span { display: none; }
  .brand strong { font-size: .88rem; }
  .location-grid, .field-grid.two { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 82px; padding: 12px; }
  .metric-icon { width: 36px; height: 36px; }
  .metric-card div > strong { font-size: 1.25rem; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-filter { grid-column: 1 / -1; }
  .search-card { padding: 17px; }
  .results-header { padding: 17px; }
  .details-body { grid-template-columns: 1fr; }
  .detail-links { grid-column: auto; flex-direction: column; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .stepper li { font-size: .68rem; }
  .stepper li:not(:last-child)::after { display: none; }
}
