/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; color: var(--text); }
.logo:hover { color: var(--text); }
.logo svg { width: 32px; height: 32px; flex: none; }
.logo .to { color: var(--accent); }
.logo-lg svg { width: 40px; height: 40px; }
.logo-lg { font-size: 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 10px 18px; border-radius: var(--r-md); border: 1px solid transparent;
  font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 600;
  background: var(--bg-elevated); color: var(--text); white-space: nowrap;
  transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease);
  text-decoration: none;
}
.btn:hover { color: var(--text); filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); }
.btn-secondary { background: var(--bg-elevated); border-color: var(--border); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elevated); }
.btn-danger { background: var(--danger-tint); color: var(--danger); border-color: transparent; }
.btn-danger:hover { color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }
.btn i.ik { font-size: 18px; line-height: 1; }
.btn-sm i.ik { font-size: 16px; }

/* ---------- Cards ---------- */
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-6); }
.card-sm { padding: var(--s-4); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-title h2, .card-title h3 { margin: 0; }
.card-icon { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--accent-tint); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: var(--s-4); }
.card-icon.violet { background: var(--accent-2-tint); color: var(--accent-2); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s-4); }
.field label, .field .label { font-size: var(--fs-label); line-height: var(--lh-label); font-weight: 500; }
.field .hint { color: var(--text-2); font-size: var(--fs-small); line-height: var(--lh-small); }
.field .error { color: var(--danger); font-size: var(--fs-small); }
.input, .select, .textarea {
  width: 100%; background: var(--bg-canvas); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px; font-size: var(--fs-body); line-height: 22px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.input::placeholder { color: var(--text-2); opacity: 0.8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 12px; background: var(--bg-elevated); border: 1px solid var(--border); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; color: var(--text-2); font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.input.mono { font-family: var(--font-mono); font-size: 14px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: var(--fs-body); }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); flex: none; }
.form-actions { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: center; margin-top: var(--s-6); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-pill); transition: background var(--ease); }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform var(--ease), background var(--ease); }
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--on-accent); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: var(--s-3) 0; border-top: 1px solid var(--border); }
.switch-row:first-of-type { border-top: 0; }
.switch-row .desc { color: var(--text-2); font-size: var(--fs-small); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); background: var(--bg-elevated); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--accent); }
.badge-warn { color: var(--warning); }
.badge-danger { color: var(--danger); }
.badge-info { color: var(--accent-2); }
.badge-plain::before { display: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); background: var(--bg-elevated); border: 1px solid var(--border); font-size: var(--fs-small); font-weight: 500; color: var(--text-2); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }

/* ---------- Terminal ---------- */
.terminal { background: var(--bg-canvas); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); text-align: left; }
.terminal-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--bg-surface); }
.terminal-bar span { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.terminal-bar span:nth-child(1) { background: var(--terminal-red); }
.terminal-bar span:nth-child(2) { background: var(--terminal-yellow); }
.terminal-bar span:nth-child(3) { background: var(--terminal-green); }
.terminal-bar .title { margin-left: auto; font-size: 12px; color: var(--text-2); font-family: var(--font-mono); width: auto; height: auto; border-radius: 0; background: none; }
.terminal pre { padding: 18px 20px; font-family: var(--font-mono); font-size: 14px; line-height: 24px; color: var(--text); overflow-x: auto; white-space: pre; }
.terminal .prompt { color: var(--text-2); }
.terminal .ok { color: var(--accent); }
.terminal .url { color: var(--accent-2); }
.terminal .cmt { color: var(--text-2); }
.terminal .cursor { display: inline-block; width: 8px; height: 16px; background: var(--accent); vertical-align: -3px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Code block with copy button */
.code { position: relative; background: var(--bg-canvas); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 48px 12px 14px; font-family: var(--font-mono); font-size: 14px; line-height: 22px; overflow-x: auto; }
.code pre { white-space: pre; }
.code .copy-btn { position: absolute; top: 8px; right: 8px; }
.copy-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-2); font-size: 16px; }
.copy-btn:hover { color: var(--text); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); min-width: 560px; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); background: var(--bg-elevated); }
.table tr:last-child td { border-bottom: 0; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .mono { font-size: 13px; }
.table-compare td:first-child { font-weight: 500; }
.table-compare .yes { color: var(--accent); font-weight: 600; }
.table-compare .no { color: var(--text-2); }
.table-wrap.fit .table { min-width: 0; }

/* ---------- Accordion ---------- */
.accordion { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg-surface); overflow: hidden; }
.accordion-item + .accordion-item { border-top: 1px solid var(--border); }
.accordion-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); padding: 18px 20px; background: none; border: 0; color: var(--text); text-align: left; font-size: 16px; font-weight: 600; }
.accordion-trigger i { transition: transform var(--ease); color: var(--text-2); font-size: 20px; }
.accordion-trigger[aria-expanded="true"] i { transform: rotate(180deg); }
.accordion-trigger:focus-visible { box-shadow: inset var(--focus); border-radius: 0; }
.accordion-panel { padding: 0 20px 18px; color: var(--text-2); }
.accordion-panel[hidden] { display: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: var(--gutter); }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal-dialog { position: relative; width: 100%; max-width: 480px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: var(--s-6); max-height: calc(100vh - 32px); overflow: auto; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.modal-header h2 { font-size: var(--fs-h3); line-height: var(--lh-h3); margin: 0; }
.modal-close { background: none; border: 0; color: var(--text-2); font-size: 22px; line-height: 1; padding: 4px; border-radius: var(--r-sm); }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--s-3); margin-top: var(--s-6); flex-wrap: wrap; }
body.modal-open { overflow: hidden; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--bg-elevated); font-size: var(--fs-small); line-height: var(--lh-small); }
.alert i { font-size: 18px; flex: none; }
.alert-ok { border-color: rgba(61,220,151,.4); background: var(--accent-tint); color: var(--text); }
.alert-ok i { color: var(--accent); }
.alert-warn { border-color: rgba(255,184,77,.4); background: var(--warning-tint); }
.alert-warn i { color: var(--warning); }
.alert-danger { border-color: rgba(255,92,108,.4); background: var(--danger-tint); }
.alert-danger i { color: var(--danger); }

/* ---------- Progress / usage bar ---------- */
.bar { height: 8px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-pill); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.bar.warn > span { background: var(--warning); }
.bar.danger > span { background: var(--danger); }

/* ---------- Tabs / segmented ---------- */
.segment { display: inline-flex; padding: 4px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-pill); gap: 2px; }
.segment button { border: 0; background: none; color: var(--text-2); padding: 6px 16px; border-radius: var(--r-pill); font-weight: 600; font-size: var(--fs-label); }
.segment button[aria-pressed="true"] { background: var(--bg-surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.segment .save { font-size: 11px; color: var(--accent); margin-left: 4px; }

/* ---------- OTP ---------- */
.otp { display: flex; gap: 8px; justify-content: center; }
.otp input { width: 48px; height: 56px; text-align: center; font-family: var(--font-mono); font-size: 22px; font-weight: 600; background: var(--bg-canvas); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); padding: 0; }
.otp input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
@media (max-width: 400px) { .otp { gap: 6px; } .otp input { width: 44px; height: 52px; font-size: 20px; } }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; font-size: var(--fs-body); }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
@media (max-width: 480px) { .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; } }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-2-tint); color: var(--accent-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: none; }
.divider { border-top: 1px solid var(--border); margin: var(--s-6) 0; }
.or { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: var(--fs-small); margin: var(--s-4) 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.icon-list { list-style: none; padding: 0; margin: 0; }
.icon-list li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.icon-list i { color: var(--accent); font-size: 18px; flex: none; margin-top: 3px; }
.icon-list .off { color: var(--text-2); }
.icon-list .off i { color: var(--text-2); }
.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text-2); width: 36px; height: 36px; border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.theme-toggle:hover { color: var(--text); background: var(--bg-elevated); }
.theme-toggle .ik-sun { display: none; }
:root[data-theme="light"] .theme-toggle .ik-sun { display: inline; }
:root[data-theme="light"] .theme-toggle .ik-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .ik-sun { display: inline; }
  :root:not([data-theme="dark"]) .theme-toggle .ik-moon { display: none; }
}
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); padding: 10px 16px; border-radius: var(--r-md); box-shadow: var(--shadow); font-size: var(--fs-small); z-index: 90; max-width: calc(100vw - 32px); }
.recovery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-family: var(--font-mono); font-size: 14px; background: var(--bg-canvas); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; margin: 0; list-style: none; }
.qr-box { width: 180px; height: 180px; border-radius: var(--r-md); border: 1px solid var(--border); background: #fff; padding: 8px; }
.icon-btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---- integration fixes (Go templates) ---- */
[hidden] { display: none !important; }
.h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); }
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .table { min-width: 560px; }
.stack { display: flex; flex-direction: column; gap: var(--s-6); }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s-6); }
@media (max-width: 900px) { .grid-2-1 { grid-template-columns: minmax(0, 1fr); } }
.qr-box { background: #fff; border-radius: var(--r-md); padding: 8px; }
.empty { text-align: center; }
button[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---- language picker ---- */
.lang-picker { position: relative; }
.lang-picker summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: var(--r-md); color: var(--text-2); font-size: var(--fs-small); font-weight: 500; border: 1px solid transparent; }
.lang-picker summary::-webkit-details-marker { display: none; }
.lang-picker summary:hover, .lang-picker[open] summary { color: var(--text); background: var(--bg-elevated); border-color: var(--border); }
.lang-picker ul { position: absolute; z-index: 80; inset-inline-end: 0; top: calc(100% + 6px); list-style: none; margin: 0; padding: 6px; min-width: 200px; max-height: min(420px, 70vh); overflow: auto; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.lang-picker li a { display: block; padding: 6px 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: var(--fs-small); white-space: nowrap; }
.lang-picker li a:hover { background: var(--bg-elevated); color: var(--text); text-decoration: none; }
.lang-picker li a[aria-current] { color: var(--accent); font-weight: 600; }
.site-footer .lang-picker ul, .sidebar-lang .lang-picker ul { top: auto; bottom: calc(100% + 6px); inset-inline-end: auto; inset-inline-start: 0; }
.sidebar-lang { margin-top: var(--s-2); }
@media (max-width: 760px) { .site-nav .actions .lang-picker summary span { display: none; } .lang-picker ul { min-width: 180px; } }

/* ---- right-to-left (Arabic, Urdu) ---- */
[dir="rtl"] ul, [dir="rtl"] ol { padding-left: 0; padding-right: 20px; }
[dir="rtl"] .table th, [dir="rtl"] .table td, [dir="rtl"] .accordion-trigger { text-align: right; }
[dir="rtl"] .table td.actions { text-align: left; }
[dir="rtl"] .select { background-position: 18px 50%, 13px 50%; padding-right: 12px; padding-left: 36px; }
[dir="rtl"] .segment .save { margin-left: 0; margin-right: 4px; }
[dir="rtl"] .skip-link { left: auto; right: var(--s-4); }
[dir="rtl"] pre, [dir="rtl"] code, [dir="rtl"] .terminal, [dir="rtl"] .mono, [dir="rtl"] .code, [dir="rtl"] input[type="email"], [dir="rtl"] input[type="password"] { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .terminal, [dir="rtl"] .code pre { text-align: left; }
[dir="rtl"] .ik-arrow-right, [dir="rtl"] .ik-arrow-left { transform: scaleX(-1); display: inline-block; }
/* Long translated labels may wrap instead of overflowing on phones. */
.card .btn, .page-title .btn, .modal .btn { max-width: 100%; white-space: normal; text-align: center; }
