/* Shared website and Desk tokens; real Frappe visual acceptance remains required. */
:root, [data-theme="light"], [data-theme="dark"] {
  --sa-space:#071426; --sa-surface:#10233d; --sa-raised:#17304f;
  --sa-text:#f4f8ff; --sa-muted:#b7c9df; --sa-blue:#3689ff; --sa-cyan:#45e4ed;
  --sa-border:#456281; --sa-danger:#ff9b9b; --sa-success:#70e3ba; --sa-warning:#ffd38a;
  --bg-color:var(--sa-space); --fg-color:var(--sa-surface); --card-bg:var(--sa-surface);
  --navbar-bg:var(--sa-space); --subtle-fg:var(--sa-raised); --control-bg:var(--sa-space);
  --text-color:var(--sa-text); --text-muted:var(--sa-muted); --heading-color:var(--sa-text);
  --border-color:var(--sa-border); --primary:var(--sa-cyan); --btn-primary:var(--sa-cyan);
  --text-on-blue:var(--sa-space); --link-color:var(--sa-cyan); --border-radius:8px;
}
body { background:var(--sa-space); color:var(--sa-text); font-family:system-ui,-apple-system,"Noto Sans","Noto Sans Thai","Noto Sans Myanmar","Noto Sans Lao",sans-serif; font-size:1rem; line-height:1.6; }
:focus-visible { outline:3px solid var(--sa-cyan); outline-offset:3px; }
a { color:var(--sa-cyan); }
.navbar { border-bottom:1px solid var(--sa-border); }
.page-card,.frappe-card,.form-layout,.widget,.modal-content { background:var(--sa-surface); border-color:var(--sa-border); border-radius:16px; }
.btn-primary { background:var(--sa-cyan); color:var(--sa-space); border-color:var(--sa-cyan); font-weight:650; }
.btn-primary:hover,.btn-primary:focus { background:#80f0f6; color:var(--sa-space); }
.form-control,.input-with-feedback { background:var(--sa-space); border-color:var(--sa-border); color:var(--sa-text); min-height:44px; }
.form-control:focus { background:var(--sa-space); color:var(--sa-text); border-color:var(--sa-cyan); }
.control-label { font-size:.875rem; color:var(--sa-muted); }
input::placeholder,textarea::placeholder { color:var(--sa-muted); opacity:1; }
.sa-original { border-left:3px solid var(--sa-border); padding:1rem; white-space:pre-wrap; overflow-wrap:anywhere; }
.sa-translation { border-left:3px solid var(--sa-cyan); padding:1rem; white-space:pre-wrap; overflow-wrap:anywhere; }

/* Desk's native template owns html[data-theme-mode]; website/login templates
   do not. Frappe 16 headings, breadcrumbs and its lazily loaded phone nav use
   Espresso ink/surface tokens, not just the legacy --text-color/--navbar-bg.
   Bind those semantic tokens on the Desk body so late root token bundles and
   the user's light/automatic theme cannot leave black text on our blue canvas. */
html[data-theme-mode] body {
  color-scheme:dark;
  /* Rebind the root alias here; inherited aliases resolve before body tokens. */
  --desk-sidebar-bg:var(--sa-surface);
  --dock-bg:var(--sa-surface);
  --dock-ink:var(--sa-muted);
  --dock-ink-hover:var(--sa-text);
  --dock-ink-active:var(--sa-cyan);
  --surface-base:var(--sa-space);
  --surface-sidebar:var(--sa-surface);
  --surface-elevation-1:var(--sa-surface);
  --surface-elevation-2:var(--sa-surface);
  --surface-elevation-3:var(--sa-raised);
  --surface-gray-1:var(--sa-space);
  --surface-gray-2:var(--sa-surface);
  --surface-gray-3:var(--sa-raised);
  --surface-gray-4:#203d5d;
  --surface-gray-5:#2b4c6c;
  --surface-gray-6:var(--sa-border);
  --surface-gray-7:var(--sa-blue);
  --surface-gray-8:#2bc8d2;
  --surface-gray-9:#80f0f6;
  --surface-gray-10:var(--sa-cyan);
  --ink-base:var(--sa-space);
  --ink-gray-1:#456281;
  --ink-gray-2:#6d8ba9;
  --ink-gray-3:#9cb5d0;
  --ink-gray-4:#9cb5d0;
  --ink-gray-5:var(--sa-muted);
  --ink-gray-6:var(--sa-muted);
  --ink-gray-7:#d8e6f5;
  --ink-gray-8:var(--sa-text);
  --ink-gray-9:var(--sa-text);
  --outline-gray-1:#304b68;
  --outline-gray-2:var(--sa-border);
  --outline-gray-3:var(--sa-cyan);
  --outline-gray-4:#9cb5d0;
  --outline-gray-5:var(--sa-muted);
  --outline-gray-6:#c7daee;
  --outline-gray-7:#d8e6f5;
  --outline-gray-8:var(--sa-text);
  --outline-gray-9:var(--sa-text);
  --outline-alpha-elevation-1:#45628166;
  --outline-alpha-elevation-2:#45628199;
  --bg-color:var(--sa-space);
  --fg-color:var(--sa-surface);
  --card-bg:var(--sa-surface);
  --navbar-bg:var(--sa-surface);
  --control-bg:var(--sa-space);
  --subtle-fg:var(--sa-raised);
  --text-color:var(--sa-text);
  --heading-color:var(--sa-text);
  --text-muted:var(--sa-muted);
  --text-light:var(--sa-muted);
  --text-neutral:var(--sa-text);
  --disabled-control-bg:var(--sa-raised);
  --disabled-text-color:var(--sa-muted);
  --border-color:var(--sa-border);
  --focus-outline-default:2px solid var(--sa-cyan);
  --icon-stroke:currentColor;
  background-color:var(--sa-space);
  color:var(--sa-text);
}

/* The native phone component renders light DOM and consumes these tokens.
   Preserve its own active/focus behavior, 56px hit areas and safe-area padding. */
html[data-theme-mode] body > frappe-mobile-nav.desk-mobile-nav {
  --surface-elevation-2:var(--sa-surface);
  --outline-gray-2:var(--sa-border);
  --outline-gray-3:var(--sa-cyan);
  --ink-gray-5:var(--sa-muted);
  --ink-gray-8:var(--sa-cyan);
  box-shadow:0 -10px 24px #0209123d;
}

/* Frappe 16 loads login.bundle.css AFTER web_include_css. Define its semantic
   tokens on the login body, below :root in the inheritance tree, so the later
   Espresso :root defaults cannot turn the page white. Keep other routes alone. */
body[data-path="login"] {
  color-scheme:dark;
  --bg-color:var(--sa-space);
  --surface-base:var(--sa-space);
  --surface-gray-1:var(--sa-space);
  --surface-gray-2:var(--sa-raised);
  --surface-gray-3:#203d5d;
  --surface-gray-4:#2b4c6c;
  --surface-elevation-1:var(--sa-surface);
  --ink-base:var(--sa-space);
  --ink-gray-3:#9cb5d0;
  --ink-gray-4:#9cb5d0;
  --ink-gray-5:var(--sa-muted);
  --ink-gray-6:var(--sa-muted);
  --ink-gray-7:var(--sa-text);
  --ink-gray-8:var(--sa-text);
  --ink-gray-9:var(--sa-text);
  --outline-gray-1:var(--sa-border);
  --outline-gray-2:var(--sa-border);
  --outline-gray-3:var(--sa-cyan);
  --surface-red-1:#351b2a;
  --surface-red-2:#472436;
  --ink-red-7:var(--sa-danger);
  --ink-red-8:var(--sa-danger);
  --outline-red-3:var(--sa-danger);
  --text-color:var(--sa-text);
  --heading-color:var(--sa-text);
  --text-muted:var(--sa-muted);
  --focus-outline-default:2px solid var(--sa-cyan);
  --focus-outline-red:2px solid var(--sa-danger);
  background:
    radial-gradient(ellipse at 16% 12%,#12456b 0,transparent 43%),
    radial-gradient(ellipse at 90% 85%,#102c59 0,transparent 42%),
    var(--sa-space);
  color:var(--sa-text);
}

body[data-path="login"] #page-login .page-content-wrapper {
  display:flex;
  align-items:center;
  min-height:100vh;
  min-height:100svh;
  padding:clamp(24px,6vh,72px) 16px;
}
body[data-path="login"] #page-login main.container {
  width:100%;
  padding:0;
}
body[data-path="login"] #page-login .page-card {
  background:var(--sa-surface);
  border:1px solid var(--sa-border);
  border-top:2px solid var(--sa-cyan);
  border-radius:20px;
  box-shadow:0 24px 80px #02091280;
  max-width:440px;
  min-height:0;
  padding:32px;
}
body[data-path="login"] #page-login .page-card-head .app-logo {
  display:block;
  width:100%;
  max-width:320px;
  height:auto;
  max-height:none;
  margin-bottom:12px;
}
body[data-path="login"] #page-login .page-card .form-control {
  min-height:46px;
  height:auto;
  padding:12px;
  border-radius:10px;
  font-size:16px;
  line-height:1.4;
}
body[data-path="login"] #page-login .password-field .form-control {
  padding-inline-end:44px;
}
body[data-path="login"] #page-login .page-card .form-control:focus-visible {
  outline:2px solid var(--sa-cyan);
  outline-offset:2px;
}
/* Keep Espresso's native hover/disabled/busy behavior; theme its component vars. */
body[data-path="login"] #page-login .es-button:not([data-theme="red"]) {
  --bt-solid-bg:var(--sa-cyan);
  --bt-solid-bg-hover:#80f0f6;
  --bt-solid-bg-active:#2bc8d2;
  --bt-solid-fg:var(--sa-space);
  --bt-fill-bg:var(--sa-raised);
  --bt-fill-bg-hover:#203d5d;
  --bt-fill-bg-active:#2b4c6c;
  --bt-fg:var(--sa-text);
  --bt-disabled-bg:var(--sa-raised);
  --bt-disabled-fg:var(--sa-muted);
  --es-bt-h:46px;
  border-radius:10px;
  font-size:16px;
  font-weight:600;
}
@media (max-width:480px) {
  body[data-path="login"] #page-login .page-content-wrapper { padding:20px 12px; }
  body[data-path="login"] #page-login .page-card { padding:24px 20px; }
}

@media (max-width:640px) { .modal-dialog { margin:.5rem; } .btn { min-height:44px; } .page-card { padding:1.25rem; } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }
