/* SanXerife shared light/dark theme layer. Loaded after each page stylesheet. */

html[data-theme="light"]{color-scheme:light}
html[data-theme="dark"]{color-scheme:dark}

.sx-theme-toggle{
  appearance:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  min-height:38px;
  padding:8px 11px;
  border-radius:999px;
  border:1px solid rgba(148,163,184,.28);
  background:rgba(255,255,255,.08);
  color:inherit;
  font:inherit;
  font-size:12px;
  font-weight:850;
  line-height:1;
  cursor:pointer;
  white-space:nowrap;
  transition:background .16s ease,border-color .16s ease,transform .16s ease;
}
.sx-theme-toggle:hover{background:rgba(148,163,184,.16);border-color:rgba(148,163,184,.45)}
.sx-theme-toggle:active{transform:translateY(1px)}
.sx-theme-toggle:focus-visible{outline:3px solid rgba(214,169,77,.35);outline-offset:2px}
.sx-theme-icon{font-size:18px;line-height:1}
.sx-theme-floating{position:fixed;top:18px;right:18px;z-index:80;box-shadow:0 10px 30px rgba(15,23,42,.16)}
html[data-theme="light"] .sx-theme-floating{background:rgba(255,255,255,.92);color:#172033;border-color:#d8dee8}
html[data-theme="dark"] .sx-theme-floating{background:rgba(13,24,40,.94);color:#edf3fb;border-color:rgba(255,255,255,.12)}

/* MAIN APPLICATION: dark mode ------------------------------------------------ */
html[data-sx-page="app"][data-theme="dark"] body{
  --bg:#08111e;
  --panel:#0f1b2c;
  --text:#edf3fb;
  --muted:#9aaabe;
  --line:rgba(255,255,255,.10);
  --accent:#d6a94d;
  --accent2:#334155;
  --gold:#d6a94d;
  --gold-soft:#72551f;
  --soft:#101d30;
  --warn:#241e10;
  background:linear-gradient(180deg,#07101c 0%,#0a1423 42%,#08111e 100%);
  color:var(--text);
}
html[data-sx-page="app"][data-theme="dark"] .nav{background:rgba(8,17,30,.93);border-bottom-color:rgba(255,255,255,.08);box-shadow:0 10px 28px rgba(0,0,0,.22)}
html[data-sx-page="app"][data-theme="dark"] .nav button{color:#c5d0df}
html[data-sx-page="app"][data-theme="dark"] .nav button:hover,
html[data-sx-page="app"][data-theme="dark"] .nav button.active{background:linear-gradient(135deg,#d8b45d,#a87627);color:#09111e;box-shadow:0 8px 18px rgba(0,0,0,.24)}
html[data-sx-page="app"][data-theme="dark"] .card{background:rgba(13,24,40,.96);border-color:rgba(255,255,255,.09);box-shadow:0 12px 32px rgba(0,0,0,.18)}
html[data-sx-page="app"][data-theme="dark"] .metric span,
html[data-sx-page="app"][data-theme="dark"] .metric small,
html[data-sx-page="app"][data-theme="dark"] p,
html[data-sx-page="app"][data-theme="dark"] .note,
html[data-sx-page="app"][data-theme="dark"] .chart-legend,
html[data-sx-page="app"][data-theme="dark"] .day-values{color:#97a8bd}
html[data-sx-page="app"][data-theme="dark"] .form-grid label,
html[data-sx-page="app"][data-theme="dark"] .filter-grid label{color:#d8e2ee}
html[data-sx-page="app"][data-theme="dark"] input,
html[data-sx-page="app"][data-theme="dark"] select,
html[data-sx-page="app"][data-theme="dark"] textarea{background:#081321;color:#edf3fb;border-color:rgba(255,255,255,.12)}
html[data-sx-page="app"][data-theme="dark"] input:focus,
html[data-sx-page="app"][data-theme="dark"] select:focus,
html[data-sx-page="app"][data-theme="dark"] textarea:focus{border-color:rgba(240,212,134,.65);box-shadow:0 0 0 3px rgba(214,169,77,.10)}
html[data-sx-page="app"][data-theme="dark"] input::placeholder,
html[data-sx-page="app"][data-theme="dark"] textarea::placeholder{color:#718198}
html[data-sx-page="app"][data-theme="dark"] .secondary{background:#17253a;color:#e2e8f0;border:1px solid rgba(255,255,255,.09)}
html[data-sx-page="app"][data-theme="dark"] .secondary:hover{background:#203149}
html[data-sx-page="app"][data-theme="dark"] .qty-box,
html[data-sx-page="app"][data-theme="dark"] .info-box,
html[data-sx-page="app"][data-theme="dark"] .recipient-history,
html[data-sx-page="app"][data-theme="dark"] .consumption-config{background:#101d30;border-color:rgba(255,255,255,.10)}
html[data-sx-page="app"][data-theme="dark"] .total-box{background:#d5ad50;color:#0b1220}
html[data-sx-page="app"][data-theme="dark"] th{background:#101d30;color:#9fb0c6}
html[data-sx-page="app"][data-theme="dark"] th,
html[data-sx-page="app"][data-theme="dark"] td{border-bottom-color:rgba(255,255,255,.09)}
html[data-sx-page="app"][data-theme="dark"] .day-label,
html[data-sx-page="app"][data-theme="dark"] .rank-value{color:#cbd5e1}
html[data-sx-page="app"][data-theme="dark"] .rank-track,
html[data-sx-page="app"][data-theme="dark"] .insight-track{background:#17253a}
html[data-sx-page="app"][data-theme="dark"] .rank-fill,
html[data-sx-page="app"][data-theme="dark"] .day-bar.in{background:#d6a94d}
html[data-sx-page="app"][data-theme="dark"] .low-stock,
html[data-sx-page="app"][data-theme="dark"] .alert-metric{background:#2a2012}
html[data-sx-page="app"][data-theme="dark"] .risk-metric{background:linear-gradient(180deg,#2a2012,#0f1b2c);border-color:#694b1f}
html[data-sx-page="app"][data-theme="dark"] .rank-alert{background:#2a2012;border-color:#76501c}
html[data-sx-page="app"][data-theme="dark"] .rank-alert span{color:#f1c979}
html[data-sx-page="app"][data-theme="dark"] .recipient-history-title,
html[data-sx-page="app"][data-theme="dark"] .risk-title,
html[data-sx-page="app"][data-theme="dark"] .risk-card-title{color:#f1f5f9}
html[data-sx-page="app"][data-theme="dark"] .recipient-history-sub,
html[data-sx-page="app"][data-theme="dark"] .risk-subtitle,
html[data-sx-page="app"][data-theme="dark"] .risk-card-text,
html[data-sx-page="app"][data-theme="dark"] .consumption-config-head span,
html[data-sx-page="app"][data-theme="dark"] .config-help{color:#9aaabe}
html[data-sx-page="app"][data-theme="dark"] .recipient-history-item,
html[data-sx-page="app"][data-theme="dark"] .risk-card,
html[data-sx-page="app"][data-theme="dark"] .config-help{background:#0a1626;border-color:rgba(255,255,255,.09)}
html[data-sx-page="app"][data-theme="dark"] .recipient-history.warning-recent{background:#2b2413;border-color:#816523}
html[data-sx-page="app"][data-theme="dark"] .recipient-history.duplicate-risk{background:#2d1519;border-color:#8a343e}
html[data-sx-page="app"][data-theme="dark"] .recipient-history-item.same-material{background:#29171b;border-color:#74343d}
html[data-sx-page="app"][data-theme="dark"] .risk-panel{background:linear-gradient(180deg,#101d30,#0d1828);border-color:#2f425a}
html[data-sx-page="app"][data-theme="dark"] .risk-panel.is-safe{background:linear-gradient(180deg,#10241c,#0d1828);border-color:#24593e}
html[data-sx-page="app"][data-theme="dark"] .risk-panel.has-warning{background:linear-gradient(180deg,#2b2413,#0d1828);border-color:#806422}
html[data-sx-page="app"][data-theme="dark"] .risk-panel.has-danger{background:linear-gradient(180deg,#2d1519,#0d1828);border-color:#7b3039}
html[data-sx-page="app"][data-theme="dark"] .mini-chip{background:#17253a;color:#cbd5e1}
html[data-sx-page="app"][data-theme="dark"] .history-action,
html[data-sx-page="app"][data-theme="dark"] .table-action{background:#132238;color:#edf3fb;border-color:rgba(255,255,255,.12)}
html[data-sx-page="app"][data-theme="dark"] .history-action:hover,
html[data-sx-page="app"][data-theme="dark"] .table-action:hover{background:#1b2c45}
html[data-sx-page="app"][data-theme="dark"] .input-suffix span{background:#17253a;color:#aebdd0;border-color:rgba(255,255,255,.12)}
html[data-sx-page="app"][data-theme="dark"] .consumption-badge.off{background:#17253a;color:#aebdd0}
html[data-sx-page="app"][data-theme="dark"] .modal-card{background:#0d1929;color:#edf3fb;border-color:rgba(255,255,255,.12);box-shadow:0 30px 90px rgba(0,0,0,.5)}
html[data-sx-page="app"][data-theme="dark"] .modal-head,
html[data-sx-page="app"][data-theme="dark"] .modal-foot{border-color:rgba(255,255,255,.09)}
html[data-sx-page="app"][data-theme="dark"] .modal-eyebrow{color:#91a4bd}
html[data-sx-page="app"][data-theme="dark"] .icon-button{background:#152239;color:#fff;border-color:rgba(255,255,255,.12)}
html[data-sx-page="app"][data-theme="dark"] .icon-button:hover{background:#203149}
html[data-sx-page="app"][data-theme="dark"] .history-summary .summary-chip{background:#17253a;color:#b7c5d8}
html[data-sx-page="app"][data-theme="dark"] .summary-chip strong{color:#edf3fb}
html[data-sx-page="app"][data-theme="dark"] .history-table-wrap{border-color:rgba(255,255,255,.10)}
html[data-sx-page="app"][data-theme="dark"] .confirm-alert-item{background:#0f1b2c;border-color:rgba(255,255,255,.10)}
html[data-sx-page="app"][data-theme="dark"] .confirm-alert-item.danger{background:#2d1519;border-color:#74343d}
html[data-sx-page="app"][data-theme="dark"] .confirm-alert-item.warning{background:#2b2413;border-color:#816523}
html[data-sx-page="app"][data-theme="dark"] .confirm-note{background:#101d30;border-color:rgba(255,255,255,.09);color:#9fb0c6}
html[data-sx-page="app"][data-theme="dark"] .consumption-intelligence{background:linear-gradient(180deg,#0f1b2c,#0d1828);border-color:#26394f}
html[data-sx-page="app"][data-theme="dark"] .period-control{color:#9fb0c6}
html[data-sx-page="app"][data-theme="dark"] .period-control select{color:#edf3fb}
html[data-sx-page="app"][data-theme="dark"] .consumption-kpi,
html[data-sx-page="app"][data-theme="dark"] .insight-panel{background:#0a1626;border-color:rgba(255,255,255,.09)}
html[data-sx-page="app"][data-theme="dark"] .consumption-kpi.warning{background:#2b2413;border-color:#7a6023}
html[data-sx-page="app"][data-theme="dark"] .consumption-kpi.danger{background:#2d1519;border-color:#74343d}
html[data-sx-page="app"][data-theme="dark"] .consumption-kpi span,
html[data-sx-page="app"][data-theme="dark"] .consumption-kpi small,
html[data-sx-page="app"][data-theme="dark"] .insight-eyebrow,
html[data-sx-page="app"][data-theme="dark"] .insight-meta{color:#91a4bd}
html[data-sx-page="app"][data-theme="dark"] .insight-panel-head{border-color:rgba(255,255,255,.07)}
html[data-sx-page="app"][data-theme="dark"] .insight-panel-head h3{color:#edf3fb}
html[data-sx-page="app"][data-theme="dark"] .insight-row:hover{background:#101d30}
html[data-sx-page="app"][data-theme="dark"] .insight-rank,
html[data-sx-page="app"][data-theme="dark"] .insight-symbol{background:#17253a;color:#cbd5e1}
html[data-sx-page="app"][data-theme="dark"] .insight-value{color:#dbe5ef}
html[data-sx-page="app"][data-theme="dark"] .insight-action{background:#132238;color:#dbe5ef;border-color:rgba(255,255,255,.10)}
html[data-sx-page="app"][data-theme="dark"] .insight-action:hover{background:#1b2c45;border-color:#52677f}
html[data-sx-page="app"][data-theme="dark"] .insight-empty,
html[data-sx-page="app"][data-theme="dark"] .intelligence-note{background:#101d30;border-color:rgba(255,255,255,.09);color:#91a4bd}
html[data-sx-page="app"][data-theme="dark"] .intelligence-note strong{color:#dbe5ef}

/* LOGIN: light mode ---------------------------------------------------------- */
html[data-sx-page="login"][data-theme="light"] body{
  --text:#111827;
  --muted:#64748b;
  --line:#d9e0e8;
  --gold:#a97927;
  --gold2:#89651f;
  --danger:#b91c1c;
  background:radial-gradient(circle at 15% 20%,rgba(214,169,77,.16),transparent 30%),linear-gradient(135deg,#f3f6fa,#eef2f7 55%,#f8fafc);
  color:#111827;
}
html[data-sx-page="login"][data-theme="light"] .login-brand p{color:#475569}
html[data-sx-page="login"][data-theme="light"] .kicker,
html[data-sx-page="login"][data-theme="light"] .eyebrow{color:#8a651e}
html[data-sx-page="login"][data-theme="light"] .trust-row span{border-color:#dec680;background:#fff8e6;color:#76571c}
html[data-sx-page="login"][data-theme="light"] .login-card{background:rgba(255,255,255,.94);border-color:#d9e0e8;box-shadow:0 30px 80px rgba(15,23,42,.14)}
html[data-sx-page="login"][data-theme="light"] label{color:#334155}
html[data-sx-page="login"][data-theme="light"] input{background:#fff;color:#111827;border-color:#cfd8e3}
html[data-sx-page="login"][data-theme="light"] .ghost-button{background:#eef2f7;color:#334155;border-color:#d1d9e4}
html[data-sx-page="login"][data-theme="light"] .login-foot{color:#64748b;border-top-color:#e2e8f0}

/* ADMIN PAGES: light mode ---------------------------------------------------- */
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) body{
  --bg:#f3f6fa;
  --panel:#fff;
  --panel2:#f8fafc;
  --text:#111827;
  --muted:#64748b;
  --line:#dce3eb;
  --gold:#a97927;
  --gold2:#8a651e;
  --green:#15803d;
  --red:#b91c1c;
  --blue:#2563eb;
  background:linear-gradient(180deg,#f4f7fb,#eef2f7 45%,#f8fafc);
  color:#111827;
}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .topbar{background:rgba(255,255,255,.92);border-bottom-color:#dce3eb;box-shadow:0 8px 24px rgba(15,23,42,.06)}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .brand span,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .actor{color:#64748b}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .hero{background:radial-gradient(circle at 90% 10%,rgba(214,169,77,.16),transparent 25%),linear-gradient(135deg,#fff,#f5f7fb);border-color:#dec680;box-shadow:0 20px 45px rgba(15,23,42,.08)}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .hero p{color:#526277}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .kicker,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .eyebrow{color:#89651f}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .metrics article,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .panel{background:rgba(255,255,255,.96);border-color:#dce3eb;box-shadow:0 18px 42px rgba(15,23,42,.07)}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .form-grid{background:#f8fafc;border-color:#dce3eb}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .form-subtitle{color:#76571c;border-top-color:#dce3eb}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) label,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .permission-item{color:#334155}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) input,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) select,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) textarea{background:#fff;color:#111827;border-color:#cfd8e3}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .secondary{background:#eef2f7;color:#26364a;border-color:#d8e0e9}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .danger{background:#fff1f2;color:#b4232f;border-color:#fecdd3}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .table-wrap{border-color:#dce3eb}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) th{background:#f1f5f9;color:#64748b}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) th,
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) td{border-bottom-color:#e2e8f0}
html[data-theme="light"][data-sx-page="admin"] .company-row:hover td,
html[data-theme="light"][data-sx-page="admin"] .company-row.selected td{background:#fff8e8}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .user-card,
html[data-theme="light"][data-sx-page="company-admin"] .role-card{background:#f8fafc;border-color:#dce3eb}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .pill{background:#e9eef5;color:#526277}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .pill.active{background:#e7f8ed;color:#166534}
html[data-theme="light"]:is([data-sx-page="admin"],[data-sx-page="company-admin"]) .pill.blocked,
html[data-theme="light"][data-sx-page="admin"] .pill.suspended,
html[data-theme="light"][data-sx-page="admin"] .pill.expired,
html[data-theme="light"][data-sx-page="admin"] .pill.cancelled{background:#fff0f1;color:#a91f2b}
html[data-theme="light"][data-sx-page="company-admin"] .pill.system{background:#e9f2ff;color:#225eb4}
html[data-theme="light"][data-sx-page="company-admin"] .tab{background:#eef2f7;color:#475569;border-color:#dce3eb}
html[data-theme="light"][data-sx-page="company-admin"] .permission-group{background:#f8fafc;border-color:#dce3eb}
html[data-theme="light"][data-sx-page="company-admin"] .permission-group h3{color:#76571c}
html[data-theme="light"][data-sx-page="company-admin"] .permission-tag{background:#e9eef5;color:#526277}
html[data-theme="light"][data-sx-page="admin"] dialog{color:#111827}
html[data-theme="light"][data-sx-page="admin"] .dialog-card{background:#fff;border-color:#dce3eb;box-shadow:0 30px 90px rgba(15,23,42,.20)}
html[data-theme="light"][data-sx-page="admin"] .close{background:#eef2f7;color:#26364a;border-color:#d8e0e9}

/* PROFILE: the modal follows the active application theme ------------------- */
html[data-theme="light"] .sx-profile-card{background:linear-gradient(180deg,#fff,#f8fafc);color:#111827;border-color:#dce3eb;box-shadow:0 30px 90px rgba(15,23,42,.22)}
html[data-theme="light"] .sx-profile-close{background:#eef2f7;color:#26364a;border-color:#d8e0e9}
html[data-theme="light"] .sx-profile-summary{background:#f8fafc;border-color:#e2e8f0}
html[data-theme="light"] .sx-profile-summary span{color:#64748b}
html[data-theme="light"] .sx-profile-data>div{background:#f1f5f9;border-color:#e2e8f0}
html[data-theme="light"] .sx-profile-data span{color:#64748b}
html[data-theme="light"] .sx-profile-data strong{color:#1f2937}
html[data-theme="light"] .sx-password-form{background:#f8fafc;border-color:#e2e8f0}
html[data-theme="light"] .sx-password-form label{color:#334155}
html[data-theme="light"] .sx-password-form input{background:#fff;color:#111827;border-color:#cfd8e3}
html[data-theme="light"] .sx-password-form small{color:#64748b}
html[data-theme="light"] .sx-profile-secondary{background:#eef2f7;color:#26364a;border-color:#d8e0e9}
html[data-theme="light"] .sx-profile-section-title,
html[data-theme="light"] .sx-profile-kicker{color:#89651f}

/* Header toggle adapts to both families of pages. */
html[data-theme="light"] .topbar .sx-theme-toggle{background:#eef2f7;color:#334155;border-color:#d6dee8}
html[data-theme="dark"] .topbar .sx-theme-toggle{background:rgba(255,255,255,.08);color:#f8fafc;border-color:rgba(255,255,255,.14)}

@media(max-width:720px){
  .sx-theme-text{display:none}
  .sx-theme-toggle{min-width:38px;padding:7px}
  .sx-theme-floating{top:12px;right:12px}
}

@media print{
  .sx-theme-toggle{display:none!important}
  html[data-sx-page="app"][data-theme="dark"] body{background:#fff!important;color:#111827!important}
  html[data-sx-page="app"][data-theme="dark"] .card,
  html[data-sx-page="app"][data-theme="dark"] th,
  html[data-sx-page="app"][data-theme="dark"] td,
  html[data-sx-page="app"][data-theme="dark"] .report-summary-grid>*{background:#fff!important;color:#111827!important;border-color:#ddd!important}
  html[data-sx-page="app"][data-theme="dark"] p,
  html[data-sx-page="app"][data-theme="dark"] .note,
  html[data-sx-page="app"][data-theme="dark"] .metric span,
  html[data-sx-page="app"][data-theme="dark"] .metric small{color:#4b5563!important}
}
