/* ==========================================================================
   SYMMETRA base — font, reset, document typography, native form controls,
   scrollbars, focus, and the handful of global utility classes the markup
   relies on (.hidden, .muted, .right, .bold, ...).
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/InterVariable.woff2") format("woff2");
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
  ul, ol { margin: 0; padding: 0; }
  img, svg, video, canvas { display: block; max-width: 100%; }
  svg { flex-shrink: 0; }
  button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  table { border-collapse: collapse; border-spacing: 0; }
  [hidden] { display: none !important; }
}

@layer base {
  html {
    font-size: 16px;
    font-family: var(--font-sans);
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    background: var(--bg);
    color: var(--text);
  }
  body {
    min-height: 100vh;
    font-size: var(--text-sm);
    line-height: var(--lh-sm);
    font-weight: var(--fw-regular);
    background: var(--bg) var(--bg-grad) no-repeat fixed;
    color: var(--text);
  }

  h1 { font-size: var(--text-xl); line-height: var(--lh-xl); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }
  h2 { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }
  h3 { font-size: var(--text-md); line-height: var(--lh-md); font-weight: var(--fw-semibold); }
  h4, h5, h6 { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: var(--fw-semibold); }
  strong, b { font-weight: var(--fw-semibold); }
  small { font-size: var(--text-xs); }
  code, kbd, pre { font-family: var(--font-mono); font-size: .92em; }
  a { color: var(--accent-fg); text-decoration: none; }
  a:hover { text-decoration: underline; text-underline-offset: 2px; }
  hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
  ::selection { background: var(--accent-soft-2); }

  /* Native form controls — the shared look every field inherits. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
  select, textarea {
    height: var(--control-md);
    padding: 0 var(--space-2-5);
    border: 1px solid var(--border-control);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: var(--text-sm);
    line-height: var(--lh-sm);
    min-width: 0;
    transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), background-color var(--dur-2);
  }
  textarea { height: auto; min-height: 76px; padding: var(--space-2) var(--space-2-5); resize: vertical; }
  select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237683a0' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    cursor: pointer;
    text-overflow: ellipsis;
  }
  select[multiple] { height: auto; background-image: none; padding: var(--space-1); }
  input::placeholder, textarea::placeholder { color: var(--subtle); opacity: 1; }
  input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) {
    border-color: var(--border-control-hover);
  }
  input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--focus-border);
    box-shadow: var(--focus-ring);
  }
  input:disabled, select:disabled, textarea:disabled, input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
    cursor: not-allowed;
  }
  input[type="date"], input[type="month"] { font-variant-numeric: tabular-nums; }
  input[type="date"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }
  :root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); }
  input[type="number"] { font-variant-numeric: tabular-nums; }
  input[type="checkbox"], input[type="radio"] {
    width: 16px; height: 16px; margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
  }
  input[type="file"] { font-size: var(--text-xs); color: var(--muted); }
  label { color: var(--text-2); }

  button:focus-visible, [role="tab"]:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--focus-border);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
  }
  button:disabled { cursor: not-allowed; }

  /* Scrollbars: thin, quiet, theme-aware */
  * { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--subtle); }

  details > summary { cursor: pointer; list-style: none; }
  details > summary::-webkit-details-marker { display: none; }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0ms !important; transition-duration: 0ms !important; scroll-behavior: auto !important; }
  }
  /* ===== F-53 — bidirectional text (Hebrew / Arabic names mixed with numbers & parentheses) =====
     Text that comes from the user or from an imported file takes its base direction from its OWN
     first strong character (what dir="auto" does), so a Hebrew name that starts with a number or a
     bracket or contains a Latin word — "4000 - מכירות", "(רווח) לפני מס", "עמלות Stripe 2.9%" — no
     longer shows its numbers, parentheses and Latin words in the wrong place (checked in Chrome).
     - LTR text is unchanged: its first strong character is Latin, so it stays LTR exactly as before.
     - text-align:match-parent keeps every cell aligned with its column (a Hebrew name does not
       jump to the other edge); an explicit alignment rule on a cell still wins. Chromium computes
       the standard keyword to "start", which plaintext then flips per paragraph, so the
       -webkit-match-parent spelling follows it (Chromium/WebKit use it; Firefox drops it and keeps
       match-parent).
     - Every selector is wrapped in :where() (specificity 0), so no existing rule is overridden.
     - Amount / number columns (.right, .num, .amount, .breakdown-amt) are pinned LTR.
     Chat bubbles carry dir="auto" in their markup (symmetra-ai-copilot.js). */
  :where(table.grid, table.report, table.mapping-table, table.sym-users-table, table.simple) :where(td):not(:where(.right, .num, .amount, .breakdown-amt)){
    unicode-bidi: plaintext;
    text-align: match-parent;
    text-align: -webkit-match-parent;
  }
  :where(table.grid, table.report, table.mapping-table, table.sym-users-table, table.simple) :where(th):not(:where(.right, .num, .amount, .breakdown-amt)){
    unicode-bidi: plaintext;
  }
  :where(table.grid, table.report, table.mapping-table, table.sym-users-table, table.simple) :where(td, th):where(.right, .num, .amount, .breakdown-amt){
    direction: ltr;
    unicode-bidi: isolate;
  }
  :where(.report-title, .company-overview-name, .workflow-company-name, .co-name-text, .sym-user-name, .sym-profile-dock__name, .sym-wm-name, .sym-wm-detail-title){
    unicode-bidi: plaintext;
    text-align: match-parent;
    text-align: -webkit-match-parent;
  }
  /* ===== end of F-53 ===== */

  /* No colour animation while the theme flips */
  :root.theme-switching *, :root.theme-switching *::before, :root.theme-switching *::after { transition: none !important; }
}

@layer utilities {
  .hidden { display: none !important; }
  .muted, .muted-text, .text-muted { color: var(--muted); }
  .subtle { color: var(--subtle); }
  .right, .num, .text-right { text-align: right; }
  .center, .text-center { text-align: center; }
  .bold { font-weight: var(--fw-semibold); }
  .small { font-size: var(--text-xs); }
  .nowrap { white-space: nowrap; }
  .num, td.right, th.right, [data-amount] { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum", "lnum", "cv11"; }
  .mono { font-family: var(--font-mono); }
  .is-negative, .neg, .negative, .amount-negative { color: var(--amount-negative); }
  .is-positive-delta, .pos-delta { color: var(--amount-positive-delta); }
  .sr-only, .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .span-2 { grid-column: span 2; }

  /* Product rules carried over from the previous stylesheets (behaviour, not looks):
     no explanatory blurbs under headings (owner decision), empty action bars collapse,
     the assistant stays out of the way of the full-height Chart of Accounts grid,
     and single-period statements need no column header row. */
  .subtitle, .page-head .subtitle, .page-head + .subtitle, .panel > .muted.subtitle, .modal-head .subtitle,
  .company-directory-note, .preview-guidance,
  .panel-title-row .muted, .panel-title-row + .muted:not(.pill):not(.coa-filter-meta) { display: none !important; }
  .actions:empty { display: none; }
  .rtb-dash, .bva-top-scroll, .rtb-actions-spacer { display: none !important; }
  html:has(main .coa-global-grid) #sym-copilot-fab, html:has(main .coa-global-grid) #sym-copilot-panel { display: none !important; }
  .report-wrap[data-compare-count="0"]:is([data-report-type="pnl"], [data-report-type="bs"], [data-report-type="cf"]) table.report thead { display: none; }
  .no-print { }
  .stack { display: flex; flex-direction: column; gap: var(--space-3); }
  .row-flex, .inline-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
}
