/* app-sales-base.css: Sales layout rules that used to be the inline <style> of index.html.
   Loaded BEFORE css/mysolar-ui.css on purpose (the inline block was first in the cascade; the package and the app files override it).
   Tokens only: var(--odoo-*) or the legacy bridge names; no raw hex. */
/* V3 look: the Odoo 20 tokens, the legacy-variable bridge (--blue, --green, --text-secondary, --o-* ...) and
   every component are in css/odoo.css, linked after this block. This block keeps only layout rules. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;   /* equal-width digits: money columns line up */
  overflow-x: hidden;
}

/* Keyboard focus is always visible (mouse clicks do not draw it). */
:focus-visible { outline: 2px solid var(--o-primary); outline-offset: 2px; }

header[hidden], nav[hidden] { display: none; }
/* Navbar, systray, dropdown menus and buttons: css/odoo.css */

/* Cards, KPI scorecards, list tables and badges: css/odoo.css */
.kpi-grid { align-items: stretch; }

/* ─── CHIPS (Masters: lead sources, statuses, products, regions) ─── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 12px;
  background: var(--o-primary-bg); color: var(--o-primary);
  border-radius: var(--o-radius); font-size: 12px; font-weight: 500; max-width: 100%; overflow-wrap: anywhere;
}
.chip-i { background: var(--o-info-bg); color: var(--odoo-badge-info-text); }   /* the info teal, darkened to read on its tint */
.chip-x {
  border: 0; background: none; color: var(--o-danger); cursor: pointer;
  font: inherit; padding: 0 2px; margin-left: 2px; line-height: 1;
}
.chip-x:focus-visible { outline: 2px solid var(--o-primary); outline-offset: 1px; }
@media (pointer: coarse), (max-width: 768px) { .chip-x { min-width: 28px; min-height: 28px; } }

/* ─── FORM SECTIONS ─── */
.sec { border: 1px solid var(--o-border); border-radius: var(--o-radius-lg); overflow: hidden; }
/* Inputs, selects, checkboxes: css/odoo.css */

/* ─── PETTY GRID ─── */
.petty {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 5px;
}
.petty label { font-size:12px; text-align: center; color: var(--text-tertiary); font-weight: 500; }
/* ─── WORKING CALENDAR (Monthly tab): a Mon..Sun grid of the month's dates ─── */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 560px; }
.cal-h { font-size: 11px; font-weight: 600; text-align: center; color: var(--text-tertiary); padding: 2px 0; }
.cal-d {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 44px; padding: 4px 2px; box-sizing: border-box; font: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid var(--o-border); border-radius: var(--o-radius);
  background: var(--o-bg2); color: var(--text-primary);
}
.cal-d small { font-size: 10px; font-weight: 600; line-height: 1.1; min-height: 11px; }
button.cal-d { cursor: pointer; transition: border-color var(--o-transition), background var(--o-transition); }
button.cal-d:hover { border-color: var(--o-primary); }
button.cal-d:focus-visible { outline: 2px solid var(--o-primary); outline-offset: 1px; }
.cal-d.off { background: var(--fill); color: var(--text-tertiary); }
.cal-d.wk { background: var(--o-success-bg); border-color: var(--o-success); color: var(--odoo-badge-success-text); }      /* a Sunday that is worked */
.cal-d.hol { background: var(--o-danger-bg); border-color: var(--o-danger); color: var(--odoo-badge-danger-text); }       /* a weekday holiday */
.cal-lg { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 0; font-size: 12px; color: var(--text-secondary); }
.cal-lg span { display: inline-flex; align-items: center; gap: 5px; }
.cal-sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--o-border); background: var(--o-bg2); }
.cal-sw.off { background: var(--fill); }
.cal-sw.wk { background: var(--o-success-bg); border-color: var(--o-success); }
.cal-sw.hol { background: var(--o-danger-bg); border-color: var(--o-danger); }
@media (pointer: coarse), (max-width: 768px) { .cal-d { min-height: 48px; } }
/* Entry form: the Remarks box takes the rest of the row, and on a tablet or
   phone the Save bar stays on screen while the fields scroll. */
.de-top { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: end; }
.de-rem { flex: 1 1 200px; min-width: 0; }
.de-bar { display: flex; gap: 14px; align-items: center; margin-top: 16px; padding: 12px 14px; background: var(--fill); border: 1px solid var(--o-border-light); border-radius: var(--o-radius-lg); flex-wrap: wrap; }
@media (max-width: 768px) {
  /* The card clips and .card-b scrolls sideways; either would become the
     sticky bar's scroller and it would never stick. */
  .card:has(#de_f), .card-b:has(> #de_f) { overflow: visible; }
  .de-bar { position: sticky; bottom: 8px; z-index: 5; background: var(--fill); box-shadow: var(--o-shadow-lg); }
  .de-bar .btn { flex: 1 1 100%; }
}

/* ─── GRID LAYOUTS ─── */
.g { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Modal dialogs and toasts: css/odoo.css */

/* ─── FOOTER ─── */
footer {
  text-align: center; padding: 12px;
  font-size:12px; color: var(--text-tertiary);
  border-top: 1px solid var(--o-border-light);
  margin-top: 16px;
}

/* ─── ANIMATIONS ─── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ─── FILTER BAR / PRINT HEADER ─── */
.fbar { display: flex; gap: 8px; padding: 8px 0 12px; flex-wrap: wrap; align-items: center; }
/* v2: at the top of a tab the filter bar is a white strip from edge to edge. */
main > .fbar:first-child {
  margin: -16px -20px 16px; padding: 8px 20px;
  background: var(--o-bg2); border-bottom: 1px solid var(--o-border-light);
}
.fbar label { font-size:12px; color: var(--text-secondary); font-weight: 500; }
.fbar select { padding: 5px 10px; font-size: 12px; }
.fbar-i { margin-left: auto; font-size:12px; color: var(--text-tertiary); }
.ph { display: none; }                /* print-only heading, see @media print */
.po { display: none; }                /* print-only text, e.g. a status shown as a button on screen */

/* ─── PAIRED CARDS (Ratios) ─── one column below 1280px, two from 1280px. */
.gp { grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 1280px) { .gp { grid-template-columns: 1fr 1fr; } }

/* ─── DASHBOARD KPI ROWS ─── 12 tiles as even rows: 6+6 from 1200px, 4+4+4
   from 900px; below that the auto-fill rule above applies. */
@media (min-width: 1200px) { .kpi-grid.k6 { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 900px) and (max-width: 1199.98px) { .kpi-grid.k6 { grid-template-columns: repeat(4, 1fr); } }

/* ─── WIDE TABLES ─── up to tablet width the name column stays visible while
   a 7-10 column table scrolls sideways inside its card. In a table that
   starts with "#" (class tn: Team Roster, Customer Master, rankings) the
   number column is narrow and the name after it stays in view as well. A
   shadow on the card's right edge shows there is more to the right; it
   is covered once the table is scrolled to its end, or when it fits (B-17). */
@media (max-width: 1024px) {
  .card-b > table td:first-child, .card-b > table th:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface-solid);
  }
  .card-b > table thead th:first-child { z-index: 3; }
  /* Opaque, in the header's own grey, so the columns scroll under it. */
  .card-b > table thead th:first-child, .card-b > table.tn thead th:nth-child(2) {
    background: var(--o-bg);
  }
  .card-b > table td, .card-b > table th { white-space: nowrap; }
  /* A long name (a full name, a company) is cut to "..." at a little over
     half the screen, or the sticky column would hide every figure behind it. */
  .card-b > table td:first-child, .card-b > table th:first-child,
  .card-b > table.tn td:nth-child(2), .card-b > table.tn th:nth-child(2) {
    max-width: 55vw; overflow: hidden; text-overflow: ellipsis;
  }
  .card-b > table.tn td:first-child, .card-b > table.tn th:first-child {
    box-sizing: border-box; width: 36px; min-width: 36px; max-width: 36px; padding-left: 6px; padding-right: 6px;
  }
  .card-b > table.tn td:nth-child(2), .card-b > table.tn th:nth-child(2) {
    position: sticky; left: 36px; z-index: 1; background: var(--surface-solid);
  }
  .card-b > table.tn thead th:nth-child(2) { z-index: 3; }
  .card-b:has(> table) {
    background:
      linear-gradient(to right, transparent, var(--surface-solid) 14px) right center / 28px 100% no-repeat local,
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), transparent) right center / 14px 100% no-repeat scroll;
  }
}

/* ─── RESPONSIVE ─── */
/* The navbar's own breakpoints (tabs on their own row below 992px, or when
   fitBar() sets header.bar-2row because they would not all fit) are in
   css/odoo.css. */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .g2 { grid-template-columns: 1fr; }
  .card-h { padding: 12px 14px; }
  .card-b { padding: 12px 14px; }
}
@media (max-width: 600px) {
  main > .fbar:first-child { margin: -8px -12px 8px; padding: 8px 12px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ─── TOUCH: phones and tablets ───
   Finger-sized controls (about 40px) on touch screens and narrow windows;
   desktop with a mouse keeps Odoo's sizes. The tab row starts at the left,
   so the first tab is always reachable, and navInView() scrolls the selected
   tab into view. Inputs are 16px on phones so iOS does not zoom the page. */
@media (pointer: coarse), (max-width: 768px) {
  .o_nav_entry { min-height: 40px; padding: 0 14px; }
  .hdr-r .btn, #co-wrap .btn { min-height: 40px; }
  .per-row .btn { min-height: 40px; min-width: 40px; }
  .dropdown-item { min-height: 40px; }
  main .btn, main select, main input:not([type=checkbox]):not([type=radio]), main textarea { min-height: 40px; }
  main .btn-sm { min-height: 36px; }
  main input[type=checkbox], main input[type=radio] { width: 20px; height: 20px; }
}

/* ─── PRINT ─── */
/* A4 portrait on every tab: Print (the daily report) and Ctrl+P / Export ▾
   PDF (Print) on Dashboard, Reports, Ratios and Analytics. Screen-only
   controls (.np, filter bars, What-If inputs, buttons, drill-downs) are
   hidden; long tables repeat their header row on each page and never split
   a row; colours are forced light so the pills and accents still read. */
@page { size: A4 portrait; margin: 10mm; }
@media print {
  header, nav, footer, .btn, .np, .fbar, .o_notification_manager, #modal, .modal, .modal-backdrop, .dropdown-menu { display: none !important; }
  :root { --bg: var(--odoo-light); --surface-solid: var(--odoo-light); --text-primary: var(--odoo-heading-color); --text-secondary: var(--odoo-body-color); --text-tertiary: var(--odoo-gray-700); }
  html, body { background: var(--odoo-light) !important; color: var(--odoo-heading-color); font-size: 11px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  main { padding: 0; max-width: 100%; }
  .ph { display: block; font-size: 10px; color: var(--odoo-body-color); margin: 0 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--odoo-dash-grid); }
  .po { display: inline; }
  /* Entry prints as the Activity Log (and the month's petty cash and
     invoices): the entry and new-invoice forms are screen-only. */
  .card:has(#de_f), .card:has(#de_note), .card:has(#ni_cust) { display: none !important; }
  .card { box-shadow: none; border: 1px solid var(--odoo-border-color); border-radius: 6px; margin-bottom: 8px; break-inside: auto; page-break-inside: auto; }
  .card-h { padding: 6px 10px; font-size: 12px; background: var(--odoo-gray-100); break-after: avoid; page-break-after: avoid; }
  .card-b { padding: 6px 10px; overflow: visible; }
  .card:hover, .kpi:hover { box-shadow: none; transform: none; }
  .kpi { box-shadow: none; border: 1px solid var(--odoo-border-color); padding: 8px 10px; min-height: 0; break-inside: avoid; }
  .kpi-val { font-size: var(--odoo-fs-h5); }
  .kpi-grid, .kpi-grid.k6 { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
  /* Paired Ratios cards print one under the other: a 6-column table does
     not fit half an A4 page. */
  .g2, .g3 { grid-template-columns: 1fr 1fr; }
  .gp { grid-template-columns: 1fr; }
  table { font-size: 10px; }
  thead { display: table-header-group; }
  thead th { position: static; background: var(--odoo-gray-100); color: var(--odoo-body-color); padding: 4px 6px; border-bottom: 1px solid var(--odoo-dash-grid); }
  tbody td { padding: 4px 6px; font-size: 10px; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  .card-b > table td:first-child, .card-b > table th:first-child,
  .card-b > table.tn td:nth-child(2), .card-b > table.tn th:nth-child(2) { position: static; max-width: none; overflow: visible; }
  .card-b:has(> table) { background: none; }
  .card-b > table thead th:first-child, .card-b > table.tn thead th:nth-child(2) { background: var(--odoo-gray-100); }
  .card-b > table td, .card-b > table th { white-space: normal; }   /* A4 is < 1024px: undo the screen nowrap */
}

/* ===== Sign-in gate (layout only; the look is o_auth_* in css/mysolar-ui.css) ===== */
#auth-gate{position:fixed;inset:0;z-index:9000;display:none;overflow:auto}
#auth-gate.show{display:grid}
#auth-submit:disabled{opacity:.6;cursor:progress}
#boot-splash{position:fixed;inset:0;z-index:8000;display:none;align-items:center;justify-content:center;gap:11px}
#boot-splash.show{display:flex}
.spin{width:17px;height:17px;border:2px solid;border-radius:50%;animation:spin .7s linear infinite;display:inline-block}
@keyframes spin{to{transform:rotate(360deg)}}
/* Save state (js/bridge.js): the header indicator, the Settings card ticks,
   the month-switch loading line and its error card (colours: css/odoo.css). */
#save-state{display:inline-flex;align-items:center;gap:6px;font-size:12px;white-space:nowrap}
#save-state:empty{display:none}
#save-state .spin,#period-load .spin{width:12px;height:12px}
#save-state button{background:none;border:1px solid currentColor;border-radius:4px;padding:3px 9px;
  font-size:12px;font-weight:600;cursor:pointer;color:inherit;font-family:var(--font)}
#period-load{display:inline-flex;align-items:center;gap:6px;font-size:12px;white-space:nowrap}
#period-load[hidden]{display:none}
main[aria-busy="true"]{pointer-events:none;transition:opacity .15s}
.sv-tick{margin-left:10px;font-size:12px;font-weight:500;color:var(--green)}
.sv-tick[data-st="saving"]{color:var(--text-secondary)}
.sv-tick[data-st="error"]{color:var(--red);font-weight:600}
.card-h[style*="background"] .sv-tick{color:var(--odoo-light)}
.sw-err{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;
  margin-bottom:16px;padding:14px 18px;border-radius:8px;font-size:13px}
.sw-err-b{display:flex;gap:8px}
@media print{#save-state,#period-load,.sv-tick,.sw-err{display:none!important}}
/* Who is signed in (js/bridge.js #who): one button (the name) -> menu with Password, Sign out. */
@media (max-width:600px){#who > .o_user_menu_btn{max-width:96px}.per-fy{display:none}#co-wrap .co-trigger,#co-wrap .co-label{max-width:128px}}
@media print{#auth-gate,#boot-splash,#who{display:none!important}}
.users-ro{color:var(--text-tertiary);font-size:12px}
@media print{#usr-dlg{display:none!important}}
/* V2-11 company switcher (js/companies.js): layout only. The chip sits in the navbar's app-name position,
   the menu is a .dropdown-menu; colours, radii and sizes are in css/odoo.css. */
#co-wrap[hidden]{display:none}
.co-trigger{max-width:220px;overflow:hidden;text-overflow:ellipsis;display:inline-flex;align-items:center;gap:6px}
.co-logo{flex:0 0 auto}
.co-trigger > span,.co-label > span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.co-trigger .co-caret{flex:0 0 auto}
.co-label{display:inline-flex;align-items:center;gap:6px;max-width:220px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.dropdown-menu.co-menu{left:0;right:auto;min-width:270px;max-width:min(360px,calc(100vw - 24px))}
.co-menu-h small{display:block;margin-top:2px;white-space:normal}
.co-item{display:flex;align-items:center;justify-content:space-between;gap:8px}
.co-check{display:flex;align-items:center;gap:8px;flex:1;min-width:0;cursor:pointer}
.co-check input:disabled{cursor:default}
.co-n{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.co-active .co-n{font-weight:700}
.co-badge{flex-shrink:0}
.dropdown-menu .btn.co-act{flex-shrink:0}
.dropdown-menu .btn.co-new{width:100%;justify-content:center}
.co-note{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:14px;
  padding:10px 14px}
.co-cards{display:grid;gap:4px}
/* Sharing (D9): a toggle for the admin, a badge wherever a shared item is listed. */
.sh-badge,.sh-tg{display:inline-flex;align-items:center;margin-left:6px;padding:1px 6px;border-radius:4px;font-size:10px;
  font-weight:600;line-height:1.5;vertical-align:middle;white-space:nowrap}
.sh-badge{background:var(--o-primary-bg2);color:var(--o-primary)}
.sh-tg{border:1px solid var(--o-border);background:var(--o-bg2);color:var(--o-text2);cursor:pointer;font-family:inherit}
.sh-tg[aria-pressed="true"]{background:var(--o-primary);border-color:var(--o-primary);color:var(--odoo-light)}
.sh-tg:focus-visible{outline:2px solid var(--o-primary);outline-offset:1px}
.usr-cos{display:grid;gap:6px;margin:0 0 12px;padding:10px 12px;border:1px solid var(--separator);border-radius:8px}
.usr-cos legend{font-size:12px;font-weight:500;color:var(--text-secondary);padding:0 4px}
.usr-cos label{display:flex;align-items:center;gap:8px;font-size:13px}
@media print{#co-wrap,.co-note{display:none!important}}
