/* Refresh warm-restore: avoid the empty pale screen when a saved Supabase session exists. */
html.taif-auth-warm-restore body.taif-auth-locked .shell{visibility:visible;opacity:1;pointer-events:none;user-select:none}
html.taif-auth-warm-restore body.taif-auth-ready .shell{pointer-events:auto;user-select:auto}
html.taif-auth-warm-restore body.taif-auth-locked .topbar:empty::before{content:'جارٍ فتح النظام...';display:inline-flex;align-items:center;justify-content:center;margin:8px 14px;padding:7px 14px;border-radius:999px;background:rgba(255,255,255,.76);border:1px solid rgba(71,119,222,.22);color:#1d3c7a;font-weight:800;font-size:13px;box-shadow:0 6px 18px rgba(30,77,160,.08)}
body.taif-auth-locked .shell{visibility:hidden;pointer-events:none;user-select:none}
body.taif-auth-ready .shell{visibility:visible}
.taif-auth-root[hidden],.taif-auth-toast[hidden]{display:none!important}
.taif-auth-root{position:fixed;inset:0;z-index:99999;display:flex;align-items:center;justify-content:center;padding:28px;background:radial-gradient(circle at 15% 20%,rgba(38,130,255,.12),transparent 28%),linear-gradient(135deg,#f7f9fc,#edf2f8);font-family:var(--taif-font-family,"Noto Naskh Arabic",system-ui,sans-serif);color:#101828;direction:rtl}
.taif-auth-shell{width:min(1050px,100%);display:grid;grid-template-columns:minmax(290px,.85fr) minmax(340px,1fr);gap:20px;align-items:stretch}
.taif-auth-shell--setup{grid-template-columns:minmax(300px,.8fr) minmax(420px,1fr)}
.taif-auth-hero,.taif-auth-card{border:1px solid rgba(16,24,40,.1);border-radius:28px;background:rgba(255,255,255,.86);box-shadow:0 24px 80px rgba(15,23,42,.14);backdrop-filter:blur(18px)}
.taif-auth-hero{padding:34px;display:flex;flex-direction:column;justify-content:center;gap:12px;overflow:hidden;position:relative}
.taif-auth-hero:after{content:"";position:absolute;inset:auto -80px -80px auto;width:220px;height:220px;border-radius:50%;background:rgba(16,185,129,.13)}
.taif-auth-logo{width:72px;height:72px;border-radius:22px;display:grid;place-items:center;background:#111827;color:#fff;font-weight:900;font-size:20px;letter-spacing:.03em;box-shadow:0 16px 35px rgba(17,24,39,.25)}
.taif-auth-logo--danger{background:#b42318}
.taif-auth-hero h1,.taif-auth-card h1,.taif-auth-card h2{margin:0;color:#0f172a;line-height:1.2}
.taif-auth-hero h1{font-size:32px}.taif-auth-card h1{font-size:26px}.taif-auth-card h2{font-size:24px}
.taif-auth-hero p,.taif-auth-card p,.taif-auth-note{margin:0;color:#526071;font-size:15px;line-height:1.8}
.taif-auth-hero ul{margin:10px 0 0;padding:0 20px 0 0;color:#344054;line-height:2;font-size:15px}
.taif-auth-card{padding:30px}.taif-auth-card--loading,.taif-auth-card--error{width:min(460px,100%);text-align:center;display:flex;align-items:center;flex-direction:column;gap:14px}
.taif-auth-form{display:flex;flex-direction:column;gap:16px}.taif-auth-field{display:flex;flex-direction:column;gap:7px;text-align:right}.taif-auth-field span{font-weight:800;color:#263142;font-size:14px}.taif-auth-field input,.taif-auth-field textarea,.taif-auth-field select{width:100%;box-sizing:border-box;border:1px solid #d0d5dd;border-radius:16px;background:#fff;padding:12px 14px;font:inherit;font-size:15px;outline:none;transition:border-color .18s,box-shadow .18s}.taif-auth-field input:focus,.taif-auth-field textarea:focus,.taif-auth-field select:focus{border-color:#1570ef;box-shadow:0 0 0 4px rgba(21,112,239,.12)}
.taif-auth-password-wrap{display:flex;align-items:center;gap:8px}.taif-auth-password-wrap input{flex:1}.taif-auth-password-wrap button{border:0;border-radius:13px;background:#eef2f6;color:#344054;font-weight:800;padding:11px 13px;cursor:pointer}
.taif-auth-remember{display:flex;align-items:center;gap:10px;border:1px solid #dbe4f0;background:#f8fbff;border-radius:14px;padding:10px 12px;color:#344054;font-size:14px;font-weight:800;cursor:pointer}.taif-auth-remember input{width:18px;height:18px;accent-color:#1570ef;cursor:pointer}.taif-auth-remember span{line-height:1.5}
.taif-auth-btn{border:0;border-radius:16px;padding:12px 18px;font:inherit;font-weight:900;cursor:pointer;transition:transform .16s,box-shadow .16s,opacity .16s}.taif-auth-btn:disabled{opacity:.65;cursor:not-allowed}.taif-auth-btn:not(:disabled):hover{transform:translateY(-1px)}.taif-auth-btn--primary{background:#111827;color:#fff;box-shadow:0 14px 28px rgba(17,24,39,.2)}.taif-auth-btn--ghost{background:#f2f4f7;color:#344054}.taif-auth-btn--danger{background:#b42318;color:#fff}.taif-auth-actions{display:flex;justify-content:center;gap:10px}.taif-auth-secondary-link{border:0;background:transparent;color:#175cd3;font:inherit;font-weight:900;cursor:pointer;padding:8px;text-decoration:none}.taif-auth-divider{display:flex;align-items:center;gap:10px;color:#98a2b3;font-size:13px;font-weight:800}.taif-auth-divider:before,.taif-auth-divider:after{content:"";height:1px;flex:1;background:#eaecf0}
.taif-auth-message{border-radius:14px;padding:11px 13px;font-weight:800;font-size:14px;line-height:1.6}.taif-auth-message--error{background:#fef3f2;color:#b42318;border:1px solid #fecdca}.taif-auth-message--info{background:#eff8ff;color:#175cd3;border:1px solid #b2ddff}.taif-auth-message--success{background:#ecfdf3;color:#067647;border:1px solid #abefc6}
.taif-auth-loader{width:38px;height:38px;border-radius:999px;border:4px solid #e4e7ec;border-top-color:#111827;animation:taifAuthSpin .82s linear infinite}@keyframes taifAuthSpin{to{transform:rotate(360deg)}}
.taif-topbar-auth{width:100%;height:100%;display:flex;align-items:center;justify-content:flex-end;gap:16px;padding:0 18px;box-sizing:border-box}.taif-topbar-auth--compact{justify-content:flex-end}.taif-topbar-user{display:flex;align-items:center;gap:10px;min-width:0}.taif-topbar-avatar{width:34px;height:34px;border-radius:13px;background:#111827;color:#fff;display:grid;place-items:center;font-weight:900}.taif-topbar-user-text{display:flex;flex-direction:column;gap:1px;min-width:0}.taif-topbar-user-text strong{font-size:14px;color:#101828;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.taif-topbar-user-text small{font-size:12px;color:#667085;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.taif-topbar-actions{display:flex;align-items:center;gap:8px}.taif-topbar-actions--compact{width:100%;justify-content:flex-end}.taif-topbar-name-chip{display:inline-flex;align-items:center;justify-content:center;min-height:30px;max-width:180px;padding:6px 11px;border-radius:999px;border:1px solid #d0d5dd;background:#fff;color:#344054;font-size:12px;font-weight:800;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;box-shadow:0 1px 2px rgba(16,24,40,.05);box-sizing:border-box}.taif-topbar-btn{border:1px solid #d0d5dd;background:#fff;border-radius:12px;padding:7px 12px;font:inherit;font-size:13px;font-weight:900;color:#344054;cursor:pointer}.taif-topbar-btn--danger{border-color:#fecdca;color:#b42318;background:#fff7f6}
.taif-auth-toast{position:fixed;z-index:100001;left:24px;bottom:24px;max-width:min(420px,calc(100vw - 48px));border-radius:18px;padding:13px 16px;font-family:var(--taif-font-family,"Noto Naskh Arabic",system-ui,sans-serif);font-weight:900;box-shadow:0 18px 50px rgba(15,23,42,.18);background:#111827;color:#fff}.taif-auth-toast--success{background:#067647}.taif-auth-toast--error{background:#b42318}.taif-auth-toast--info{background:#175cd3}
.taif-auth-modal-backdrop{position:fixed;inset:0;z-index:100000;background:rgba(15,23,42,.45);display:flex;align-items:center;justify-content:center;padding:20px;direction:rtl}.taif-auth-modal{width:min(460px,100%);background:#fff;border-radius:24px;box-shadow:0 28px 90px rgba(15,23,42,.28);padding:22px;display:flex;flex-direction:column;gap:14px}.taif-auth-modal__header{display:flex;align-items:center;justify-content:space-between;gap:12px}.taif-auth-modal__header h2{margin:0;font-size:22px}.taif-auth-modal__header button{width:36px;height:36px;border:0;border-radius:12px;background:#f2f4f7;font-size:22px;cursor:pointer}.taif-auth-modal__lead{margin:0;color:#475467;line-height:1.7}.taif-auth-modal__actions{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}
.panel__status--forbidden .panel__status-badge{background:#fff7ed;color:#c2410c}
@media (max-width:820px){.taif-auth-root{padding:16px;align-items:flex-start;overflow:auto}.taif-auth-shell,.taif-auth-shell--setup{grid-template-columns:1fr}.taif-auth-hero{padding:24px}.taif-auth-card{padding:22px}.taif-topbar-auth{padding:0 10px}.taif-topbar-user-text small{display:none}}

.taif-auth-modal--backup{max-width:640px}.taif-backup-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0}.taif-auth-field--full{display:flex;flex-direction:column;gap:7px;margin:14px 0}.taif-auth-field--full select{border:1px solid #d0d5dd;border-radius:12px;padding:10px 12px;font:inherit;background:#fff;color:#101828}.taif-auth-btn--danger{background:#fff1f0;color:#b42318;border-color:#fecdca}@media(max-width:640px){.taif-backup-grid{grid-template-columns:1fr}.taif-topbar-actions{gap:6px}.taif-topbar-btn{padding:6px 9px;font-size:12px}}
.taif-sync-status{display:inline-flex;align-items:center;justify-content:center;min-height:30px;padding:6px 11px;border-radius:999px;border:1px solid #d0d5dd;background:#fff;color:#344054;font-size:12px;font-weight:800;white-space:nowrap;box-shadow:0 1px 2px rgba(16,24,40,.05)}.taif-sync-status::before{content:"";width:7px;height:7px;border-radius:50%;margin-left:7px;background:#98a2b3}.taif-sync-status[data-state="ok"]{border-color:#abefc6;background:#ecfdf3;color:#067647}.taif-sync-status[data-state="ok"]::before{background:#17b26a}.taif-sync-status[data-state="syncing"]{border-color:#fedf89;background:#fffaeb;color:#b54708}.taif-sync-status[data-state="syncing"]::before{background:#f79009}.taif-sync-status[data-state="pending"]{border-color:#b2ddff;background:#eff8ff;color:#175cd3}.taif-sync-status[data-state="pending"]::before{background:#2e90fa}.taif-sync-status[data-state="offline"],.taif-sync-status[data-state="error"]{border-color:#fecdca;background:#fff1f3;color:#b42318}.taif-sync-status[data-state="offline"]::before,.taif-sync-status[data-state="error"]::before{background:#f04438}

/* Auth side-action modals use the same independent grand window shell as the Add Currency editor. */
.taif-auth-workspace-modal .taif-currency-management-modal__body{
  min-height:0;
}

.taif-auth-workspace-panel{
  min-height:0;
  height:100%;
  display:flex;
  flex-direction:column;
  position:relative;
}

.taif-auth-workspace-note{
  grid-column:1 / -1;
}

.taif-auth-workspace-field--full,
.taif-auth-workspace-message{
  grid-column:1 / -1;
}

.taif-auth-workspace-field > label,
.taif-auth-workspace-field > .currency-management-field__caption{
  text-align:center;
  justify-self:center;
}

.taif-auth-workspace-input{
  text-align:center;
}

.taif-auth-workspace-panel--backup .taif-auth-workspace-action-grid{
  grid-column:1 / -1;
  align-items:stretch;
}

.taif-auth-workspace-panel--backup .taif-auth-workspace-action-grid .currency-management-btn{
  min-height:39px;
  justify-content:center;
}

.taif-auth-workspace-panel--backup .taif-auth-workspace-action-grid .currency-management-btn:first-child{
  grid-column:1 / -1;
}

.taif-auth-workspace-message[hidden]{
  display:none !important;
}

.taif-auth-modal__lead--warning{
  color:#991b1b;
  border:1px solid #fecdca;
  background:#fef3f2;
  padding:10px 12px;
  border-radius:14px;
  font-weight:800;
}

@media(max-width:640px){
  .taif-auth-workspace-panel--backup .taif-auth-workspace-action-grid{
    grid-template-columns:1fr;
  }
}
