/* Pesticides ERP — single stylesheet, no build step (shared-hosting friendly). */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --border: #dfe4e2;
  --text: #1f2a26;
  --muted: #66736e;
  --primary: #1f7a4d;
  --primary-dark: #17603c;
  --primary-soft: #e6f3ec;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff6dd;
  --info-soft: #e8f1fb;
  --outline: #2f6fd6;   /* blue outline of buttons and input boxes */
  --sidebar: #15241e;
  --sidebar-text: #c9d6d0;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  padding: 14px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 18px 14px; display: block; }
.sidebar .brand small { display: block; font-weight: 400; color: var(--sidebar-text); font-size: 11px; }
.nav-group { padding: 10px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7f948b; }
.sidebar a.nav { display: block; color: var(--sidebar-text); padding: 6px 18px; border-left: 3px solid transparent; }
.sidebar a.nav:hover { background: rgba(255,255,255,.05); text-decoration: none; color: #fff; }
.sidebar a.nav.active { border-left-color: var(--nav-accent, #4cc38a); background: var(--nav-active-bg, rgba(76,195,138,.1)); color: #fff; }
/* Collapsible sections, one open at a time: the hovered one, else the open one (clicked, or holding the current page). */
.nav-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; cursor: pointer; font: inherit; font-size: 11px; text-align: left; }
.nav-toggle::after { content: '\203A'; font-size: 15px; line-height: 1; transition: transform .15s; }
.nav-toggle:hover, .nav-section.open > .nav-toggle { color: #fff; }
.nav-section.open > .nav-toggle::after { transform: rotate(90deg); }
.nav-items { display: none; padding-bottom: 4px; }
.nav-section.open > .nav-items { display: block; }
@media (hover: hover) {
  .nav-section:hover > .nav-items { display: block; }
  .nav-section:hover > .nav-toggle::after { transform: rotate(90deg); }
  .sidebar:has(.nav-section:hover) .nav-section:not(:hover) > .nav-items { display: none; }
  .sidebar:has(.nav-section:hover) .nav-section:not(:hover) > .nav-toggle::after { transform: none; }
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 24px;
}
.topbar .user { color: var(--muted); display: flex; gap: 12px; align-items: center; }
.menu-toggle { display: inline-flex; }
/* Sidebar hidden with the Menu button (desktop): the page takes the full width. */
.app.nav-hidden .sidebar { display: none; }
.content { padding: 20px 24px 40px; }

/* Menu position, chosen per company in the Developer Console: left (default), right, or across the top like MS Office
   (section names as tabs; under them a strip with the open section's pages). Phones always use the slide-in menu. */
@media (min-width: 761px) {
  .app.menu-right { flex-direction: row-reverse; }
  .app.menu-right .sidebar a.nav { border-left: 0; border-right: 3px solid transparent; }
  .app.menu-right .sidebar a.nav.active { border-right-color: var(--nav-accent, #4cc38a); }
  /* Section arrows point towards the page (left) and turn down when the section opens. */
  .app.menu-right .nav-toggle::after { content: '\2039'; }
  .app.menu-right .nav-section.open > .nav-toggle::after,
  .app.menu-right .nav-section:hover > .nav-toggle::after { transform: rotate(-90deg); }
  .app.menu-right .sidebar:has(.nav-section:hover) .nav-section:not(:hover) > .nav-toggle::after { transform: none; }

  .app.menu-top { flex-direction: column; }
  .app.menu-top .sidebar {
    width: auto; height: auto; position: sticky; top: 0; z-index: 30; overflow: visible;
    display: flex; align-items: stretch; padding: 0 8px 40px; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  }
  .app.menu-top .sidebar .brand { padding: 4px 14px 4px 6px; font-size: 14px; max-width: 230px; flex-shrink: 0; align-self: center; }
  .app.menu-top .sidebar .brand img { height: 30px !important; width: 30px !important; }
  /* The name may take two lines (then cut with ...), so it shows complete next to the tabs. */
  .app.menu-top .sidebar .brand span { overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.2; max-width: 170px; }
  .app.menu-top .sidebar .brand small { display: none; }
  .app.menu-top .nav-section { position: static; display: flex; }
  .app.menu-top .nav-toggle { padding: 0 12px; height: 46px; white-space: nowrap; border-bottom: 3px solid transparent; }
  .app.menu-top .nav-toggle::after { content: none; }
  .app.menu-top .nav-section.open > .nav-toggle { border-bottom-color: var(--nav-accent, #4cc38a); }
  .app.menu-top .nav-items {
    position: absolute; left: 0; right: 0; top: 46px; height: 40px; padding: 0 12px; gap: 2px; align-items: center;
    overflow-x: auto; overflow-y: hidden; border-top: 1px solid rgba(255,255,255,.08); background: rgba(0,0,0,.12);
  }
  .app.menu-top .nav-section.open > .nav-items, .app.menu-top .nav-section:hover > .nav-items { display: flex; }
  .app.menu-top .sidebar a.nav { white-space: nowrap; padding: 6px 12px; border-left: 0; border-bottom: 3px solid transparent; border-radius: 4px 4px 0 0; }
  .app.menu-top .sidebar a.nav.active { border-bottom-color: var(--nav-accent, #4cc38a); }
}
@media (min-width: 761px) and (max-width: 1200px) {
  .app.menu-top .sidebar .brand span { display: none; }   /* narrower screens: the logo only, so every tab fits */
  .app.menu-top .nav-toggle { padding: 0 8px; }
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.warn .value { color: var(--warn); }
.stat.danger .value { color: var(--danger); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 4px; color: #34433d; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--outline); border-radius: 6px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,122,77,.25); border-color: var(--primary); }
textarea { min-height: 70px; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 400; font-size: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 3px; }
.is-invalid { border-color: var(--danger) !important; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters > div { min-width: 140px; }
.filters input[type=search] { min-width: 220px; }

/* Searchable dropdown (partials/searchable-select) */
.ss { position: relative; }
.ss-native { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; }
.ss .ss-input {
  width: 100%; padding: 7px 28px 7px 9px; border: 1px solid var(--outline); border-radius: 6px; font: inherit; color: var(--text);
  background: #fff 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='%2366736e' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat right 9px center;
}
.ss .ss-input:disabled { background-color: #f2f5f4; cursor: not-allowed; }
.lines .ss .ss-input { padding: 5px 24px 5px 6px; font-size: 13px; }
.ss-list {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; min-width: 220px;
  max-height: 280px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(16, 24, 20, .14);
}
.ss.is-open .ss-list { display: block; }
.ss-item { padding: 6px 10px; cursor: pointer; font-weight: 400; }
.ss-item.ss-blank { color: var(--muted); }
.ss-item.is-selected { font-weight: 600; }
.ss-item.is-active { background: var(--primary-soft); color: var(--primary-dark); }
.ss-empty { padding: 8px 10px; color: var(--muted); font-size: 12px; }

/* Confirmation box (layouts/app) */
.confirm-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; max-width: 440px; width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(16, 24, 20, .25); }
.confirm-box::backdrop { background: rgba(16, 24, 20, .45); }
.confirm-box p { margin: 0; font-size: 15px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--outline);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f2f5f4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #8f1c13; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-link { border: none; background: none; color: var(--primary); padding: 0; font-weight: 400; cursor: pointer; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f7f9f8; font-size: 12px; color: #4a5a53; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tbody tr:hover { background: #fafcfb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: #f7f9f8; }
.table-compact td, .table-compact th { padding: 5px 6px; }
.empty { text-align: center; color: var(--muted); padding: 24px; }

/* Badges & alerts */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef1f0; color: #4a5a53; }
.badge-success { background: var(--primary-soft); color: var(--primary-dark); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: #1d4f91; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: var(--primary-soft); border-color: #bfe3cf; color: var(--primary-dark); }
.alert-danger { background: var(--danger-soft); border-color: #f5c2bd; color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: #f1dc9c; color: var(--warn); }
.alert ul { margin: 4px 0 0 18px; padding: 0; }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Pagination (Laravel bootstrap-5 markup) */
nav .pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 12px 0 0; flex-wrap: wrap; }
.pagination .page-link { display: block; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pagination .active .page-link { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled .page-link { color: #a9b3af; }
nav .small, nav p.small { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
nav .d-sm-none { display: none; }

/* Login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }

/* Purchase lines */
.lines input, .lines select { padding: 5px 6px; font-size: 13px; }
.lines td { padding: 4px; }
.lines .disc-cell { display: flex; gap: 4px; align-items: center; }
.lines .disc-cell .btn { min-width: 38px; justify-content: center; }
.lines .w-xs { width: 70px; } .lines .w-sm { width: 95px; } .lines .w-md { width: 130px; }
.totals { width: 320px; margin-left: auto; }
.totals td { border: none; padding: 4px 8px; }
.totals tr.grand td { font-size: 16px; font-weight: 700; border-top: 2px solid var(--text); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s; }
  .sidebar.open { left: 0; }
  .app.nav-hidden .sidebar { display: block; }   /* on a phone the button slides the sidebar in and out instead */
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .totals { width: 100%; }
  .dl { grid-template-columns: 1fr; }
}

/* Print: invoices and reports */
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .no-print, .filters, nav .pagination, .form-actions, .alert { display: none !important; }
  .print-only { display: block; }
  .app { display: block; min-height: 0; }   /* no full-screen height on paper: it pushed a blank last page */
  /* Only the ERP page is printed: boxes that browser extensions add to the page (e.g. a voice-typing bar) can push an
     empty extra page. */
  body > :not(.app), html > :not(head):not(body) { display: none !important; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  a { color: inherit; }
}
