:root{
  --card-max-w: 1200px;
  --card-min-h: 560px;
  --card-max-h: 860px;
  --radius: 2.4vh;
  --shadow: 0 2.5vh 6vh rgba(16,24,40,.12);
  --blue: #147bd1;
  --text: #2b2f36;
  --line: #e5e7eb;
  --bg: #eceff3;
  --btn: #3b3f44;
  --btn-h: #2f3337;
  --pad-v: 3vh;
  --pad-h: 3vw;
  --footer-h: 32px;
}

html, body{
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  overflow: auto;
  margin: 0;
  padding: 0;
}

body{
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji",
        "Segoe UI Emoji", "Noto Color Emoji";
}

#kc-header, #kc-page-title, #kc-container-wrapper, #kc-content, #kc-content-wrapper,
.login-pf-page, .card-pf, .pf-c-page, .pf-c-login, .pf-c-page__header { display: contents; }

.c-root{
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2vh;
  padding: var(--pad-v) var(--pad-h);
  padding-bottom: var(--pad-v);
}

.c-card{
  width: min(92vw, var(--card-max-w));
  height: clamp(
    var(--card-min-h),
    calc(100dvh - var(--pad-v)*2 - var(--footer-h)),
    var(--card-max-h)
  );
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 52% 48%;
  align-items: stretch;
  overflow: hidden;
}

.c-left{ position: relative; min-width: 0; min-height: 0; }
.c-left-img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.c-right{
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  padding: 0;
  display: grid;
  align-content: start;
  gap: 2.2vh;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.c-right::before,
.c-right::after{
  content: "";
  display: block;
  height: var(--pad-v);
  flex: 0 0 auto;
}

.c-right > *{
  padding-left: var(--pad-h);
  padding-right: var(--pad-h);
}

.c-right > *{ max-width: 48vw; }
@media (min-width: 1200px){
  .c-right > *{ max-width: 560px; }
}

.c-brand{ display:flex; justify-content:flex-start; }
.c-logo-link{ display:inline-flex; }
.c-brand img{ height: clamp(44px, 6vh, 60px); width:auto; }

.c-title{
  margin: 0;
  font-size: clamp(26px, 5vh, 40px);
  line-height: 1.12;
  font-weight: 800;
  color: #2a2f35;
}
.c-intro p{ margin: 0; }
.c-subtitle{
  color: var(--text);
  font-size: clamp(14px, 2.2vh, 18px);
  font-weight: 600;
}

.c-terms{
  color: #7a8696;
  font-size: clamp(12px, 1.8vh, 14px);
}
.c-terms a{ color: var(--blue); text-decoration: underline; font-weight: 600; }
.c-terms--inline{
  margin-top: 0.2em;
  padding-top: 0;
  border-top: none;
  text-align: left;
}

.c-msg{
  padding: 1.2vh 1.4vh;
  border-radius: 1.2vh;
  font-size: clamp(12px, 1.8vh, 14px);
  border: 1px solid #fecaca; background:#fee2e2; color:#991b1b;
  text-align: center;
  justify-self: center;
  width: 100%;
  max-width: 90%;
  box-sizing: border-box;
}
.c-msg.success{ border-color:#a7f3d0; background:#ecfdf5; color:#065f46; }

* { box-sizing: border-box; }

.c-field{ display:grid; gap: 0.8vh; margin: 0.6vh 0; }
.c-field span{
  font-size: clamp(12px, 1.9vh, 14px);
  font-weight: 600; color: #475569;
}
.c-field input{
  width: 100%;
  padding: 1.2vh 1.4vh;
  border-radius: 1.2vh;
  border: 1px solid #d1d5db;
  background:#fff;
  transition: border-color .2s, box-shadow .2s, transform .12s;
  font-size: clamp(14px, 2vh, 16px);
}
.c-field input:focus{
  outline: none; border-color: #9ac2f5;
  box-shadow: 0 0 0 0.6vh rgba(20,123,209,.15);
  transform: translateY(-0.2vh);
}

.c-field--password > span{ grid-row: 1; grid-column: 1; }
.c-field--password > input{ grid-row: 2; grid-column: 1; padding-right: 48px; }
.c-field--password > .c-field-help{ grid-row: 3; grid-column: 1; }
.c-eye{
  grid-row: 2; grid-column: 1;
  justify-self: end; align-self: center;
  z-index: 1; margin-right: 4px;
  width: 40px; height: 40px; display:grid; place-items:center;
  border: 0; background: transparent; color: #64748b; cursor: pointer;
}
.c-eye .ico-on{ display: none; }
.c-eye[aria-pressed="true"] .ico-off{ display: none; }
.c-eye[aria-pressed="true"] .ico-on{ display: block; }

.c-row{ display:flex; align-items:center; justify-content:space-between; flex-wrap: wrap; gap: 1.2vh; }
.c-link{ color: var(--blue); text-decoration:none; font-weight: 600; }
.c-link:hover{ text-decoration: underline; }

.c-submit{
  width: 100%;
  border: 0; border-radius: 1.2vh; cursor: pointer;
  background: var(--btn); color:#fff;
  padding: 1.4vh 1.6vh; margin-top: 1vh;
  font-weight: 800; font-size: clamp(14px, 2vh, 16px);
  box-shadow: 0 1.2vh 2.6vh rgba(59,63,68,.25);
  transition: transform .1s ease, background .2s ease, box-shadow .2s ease;
}
.c-submit:hover{ background: var(--btn-h); transform: translateY(-0.2vh); }

.c-help-bottom{
  margin-top: 2.2vh;
  padding-top: 1.4vh;
  border-top: 1px solid var(--line);
  text-align: center;
  color: #2a2f35;
  font-size: clamp(12px, 1.8vh, 14px);
  line-height: 1.4;
}

.c-page-footer{ display:none !important; }

@media (max-width: 900px){
  .c-card{
    width: 100vw;
    grid-template-columns: 1fr;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }

  .c-left{ display: none; }

  .c-root{
    background: url('../img/left-visual.jpg') center/cover no-repeat scroll;
    padding: 0;
    gap: 0;
  }

  .c-right{
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  .c-right > *{
    max-width: 100%;
    padding-left: 5vw;
    padding-right: 5vw;
  }
}

@media (max-height: 700px){
  :root{ --card-min-h: 400px; }
  .c-title{ font-size: clamp(22px, 4.2vh, 28px); }
  .c-subtitle{ font-size: clamp(12px, 1.8vh, 14px); }
  .c-right{ gap: 1.2vh; }
  .c-brand img{ height: clamp(32px, 5vh, 44px); }
  .c-devices{ max-height: 22vh; }
  .c-help-bottom{ margin-top: 1vh; padding-top: 1vh; }
}

@media (max-height: 500px){
  :root{ --card-min-h: 320px; --pad-v: 1vh; }
  .c-right{ gap: 0.8vh; }
  .c-right::before, .c-right::after{ height: 1vh; }
  .c-title{ font-size: clamp(18px, 3.5vh, 24px); }
  .c-subtitle{ font-size: clamp(11px, 1.6vh, 13px); }
  .c-devices{ max-height: 18vh; }
}

@media (max-width: 480px){
  .c-criteria{ grid-template-columns: 1fr; }
}

.c-right--compact{ gap: 1.4vh; }
.c-right--compact .c-title{ font-size: clamp(22px, 3.6vh, 32px); }
.c-right--compact .c-subtitle{ font-size: clamp(12px, 1.8vh, 16px); }

.c-right--compact .c-qr-box{
  border:1px solid var(--line); border-radius:1.2vh; padding:1.6vh;
  background:#fff;
}
.c-right--compact .c-qr-img{ max-width: 180px; height: auto; display:block; }
.c-right--compact .c-manual{ font-size: clamp(12px, 1.7vh, 14px); line-height:1.5; }

.c-right--compact .c-field input{ padding: 1vh 1.2vh; }
.c-right--compact .c-submit{ padding: 1.2vh 1.4vh; }

.c-sep{ margin-top: 2vh; padding-top: 1.4vh; border-top: 1px solid var(--line); }

/* ── Password criteria checklist ── */
.c-criteria{
  list-style: none;
  margin: 0.4vh 0 0.8vh;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4vh 1.2vh;
  font-size: clamp(11px, 1.6vh, 13px);
}
.c-cr{
  display: flex;
  align-items: center;
  gap: 0.5em;
  color: #94a3b8;
  transition: color .2s;
}
.c-cr-ico{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1.5px solid #cbd5e1;
  font-size: 11px;
  transition: all .2s;
  flex-shrink: 0;
}
.c-cr-ico::after{ content: ''; }
.c-cr--ok{ color: #059669; }
.c-cr--ok .c-cr-ico{
  border-color: #059669;
  background: #059669;
  color: #fff;
}
.c-cr--ok .c-cr-ico::after{ content: '\2713'; }
.c-cr--fail{ color: #dc2626; }
.c-cr--fail .c-cr-ico{
  border-color: #dc2626;
  background: #fee2e2;
  color: #dc2626;
}
.c-cr--fail .c-cr-ico::after{ content: '\2717'; font-size: 10px; }
.c-strength-weak{ color: #dc2626; font-weight: 600; font-size: clamp(11px, 1.6vh, 13px); }
.c-strength-medium{ color: #d97706; font-weight: 600; font-size: clamp(11px, 1.6vh, 13px); }
.c-strength-strong{ color: #059669; font-weight: 600; font-size: clamp(11px, 1.6vh, 13px); }
.c-match-success{ color: #059669; font-weight: 600; font-size: clamp(11px, 1.6vh, 13px); }
.c-match-error{ color: #dc2626; font-weight: 600; font-size: clamp(11px, 1.6vh, 13px); }

/* ── Modern OTP device selector ── */
.c-devices{
  display: flex;
  flex-direction: column;
  gap: 0.8vh;
  max-height: 28vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.c-device{
  display: flex;
  align-items: center;
  gap: 1em;
  padding: 1.2vh 1.4vh;
  border-radius: 1.2vh;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background .2s;
  position: relative;
}
.c-device:hover{
  border-color: #9ac2f5;
  background: #f0f7ff;
}
.c-device input[type="radio"]{
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
}
.c-device input[type="radio"]:checked + .c-device-radio{
  border-color: var(--blue);
  background: var(--blue);
}
.c-device input[type="radio"]:checked + .c-device-radio::after{
  opacity: 1;
  transform: scale(1);
}
.c-device input[type="radio"]:checked ~ .c-device-body{
  color: var(--text);
}
.c-device input[type="radio"]:focus-visible + .c-device-radio{
  box-shadow: 0 0 0 3px rgba(20,123,209,.3);
}
.c-device:has(input:checked),
.c-device.c-device--active{
  border-color: var(--blue);
  background: #f0f7ff;
  box-shadow: 0 0 0 1px var(--blue);
}
.c-device-radio{
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}
.c-device-radio::after{
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transform: scale(0);
  transition: all .15s;
}
.c-device-body{
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  min-width: 0;
}
.c-device-name{
  font-weight: 700;
  font-size: clamp(13px, 1.9vh, 15px);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.c-device-meta{
  font-size: clamp(11px, 1.5vh, 12px);
  color: #94a3b8;
}
.c-device-ico{
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.c-device-ico svg{ width: 20px; height: 20px; color: var(--blue); }

/* ── Checkbox (.c-check) ── */
.c-check{
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-size: clamp(12px, 1.8vh, 14px);
  color: #475569;
  cursor: pointer;
}
.c-check input[type="checkbox"]{
  width: 16px; height: 16px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ── Field help text ── */
.c-field-help{
  font-size: clamp(11px, 1.5vh, 13px);
  color: #94a3b8;
  line-height: 1.4;
}

/* ── OTP / TOTP Feedback ── */
.c-otp-feedback,
.c-totp-feedback{
  font-size: clamp(11px, 1.5vh, 13px);
  font-weight: 600;
  min-height: 1.4em;
}
.c-feedback-partial{ color: #d97706; }
.c-feedback-complete{ color: #059669; }
.c-feedback-error{ color: #dc2626; }

/* ── QR Section (TOTP setup) ── */
.c-qr-section{
  display: flex;
  justify-content: center;
}
.c-qr-security-notice{
  margin-top: 0.6vh;
  font-size: clamp(10px, 1.4vh, 12px);
  color: #dc2626;
  font-weight: 600;
  text-align: center;
}
.c-qr-fallback{
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2vh;
  border: 2px dashed var(--line);
  border-radius: 1.2vh;
  background: #f8fafc;
}

/* ── Secret key ── */
.c-secret-container{
  display: flex;
  align-items: center;
  gap: 0.8em;
  flex-wrap: wrap;
}
.c-secret{
  font-family: ui-monospace, "Cascadia Code", "Fira Code", Menlo, Consolas, monospace;
  font-size: clamp(12px, 1.7vh, 14px);
  letter-spacing: 0.05em;
  word-break: break-all;
  background: #f1f5f9;
  padding: 0.4em 0.6em;
  border-radius: 0.6vh;
  border: 1px solid var(--line);
}
.c-copy-btn{
  padding: 0.4em 0.8em;
  border: 1px solid var(--line);
  border-radius: 0.6vh;
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  font-size: clamp(11px, 1.5vh, 13px);
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.c-copy-btn:hover{
  background: #f0f7ff;
  border-color: var(--blue);
}
.c-secret-warning{
  margin-top: 0.4vh;
  font-size: clamp(10px, 1.4vh, 12px);
  color: #d97706;
  line-height: 1.4;
}

/* ── Password strength / match base ── */
.c-password-strength,
.c-password-match{
  font-size: clamp(11px, 1.6vh, 13px);
  min-height: 1.4em;
  transition: color .2s;
}

/* ── Fieldset / Legend ── */
.c-fieldset{
  border: none;
  margin: 0;
  padding: 0;
}
.c-legend{
  font-size: clamp(13px, 1.9vh, 15px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.6vh;
}

@media (max-height: 900px){
  .c-right{ gap: 1.4vh; }
  .c-title{ font-size: clamp(22px, 3.6vh, 32px); }
  .c-subtitle{ font-size: clamp(12px, 1.8vh, 16px); }
  .c-devices{ max-height: 26vh; }
}

/* ── Passkey / alt login buttons ── */
.c-submit--passkey{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  background: #e5a000;
  color: #fff;
  margin-top: 1.2vh;
  box-shadow: 0 1.2vh 2.6vh rgba(229,160,0,.25);
}
.c-submit--passkey:hover{
  background: #cc8e00;
  transform: translateY(-0.2vh);
}
.c-submit--passkey svg{
  flex-shrink: 0;
}
.c-submit--credentials{
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  margin-top: 1.2vh;
  box-shadow: none;
}
.c-submit--credentials:hover{
  background: #dde1e7;
  transform: translateY(-0.2vh);
}

/* ── Utility ── */
.c-hidden{ display: none !important; }