/* Kverneland MasterData Portal - shared styles
   Brand colors come from the logo: green #03533d, olive #beb500.
   Two themes, chosen with the toggle in the navbar and stored in a cookie:
   :root = white mode, :root[data-theme="dark"] = dark mode. */

:root{
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #f0f3f1;
  --border: #e0e6e2;
  --border-strong: #c9d3cd;
  --text: #14231d;
  --muted: #5e6c65;
  --accent: #03533d;
  --accent-hover: #02412f;
  --accent-soft: #e2efe8;
  --accent-text: #ffffff;
  --olive: #beb500;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1f7a4d;
  --warn: #b45309;
  --shadow-sm: 0 1px 2px rgba(16,24,20,.06);
  --shadow: 0 1px 3px rgba(16,24,20,.06), 0 8px 24px rgba(16,24,20,.06);
  --shadow-lg: 0 24px 60px rgba(16,24,20,.22);
  --radius: 14px;
  --radius-sm: 9px;
  --diagram-a: #cfd8d3;
  --diagram-b: #8b9a92;
  --diagram-stroke: #5e6c65;
  color-scheme: light;
}

  :root[data-theme="dark"]{
    --bg: #0e1412;
    --surface: #161e1b;
    --surface-2: #1d2723;
    --border: #28342f;
    --border-strong: #36443e;
    --text: #e5ece8;
    --muted: #93a29b;
    --accent: #3fae84;
    --accent-hover: #55c096;
    --accent-soft: #1b3a2e;
    --accent-text: #08130f;
    --danger: #f07167;
    --danger-soft: #3a1c1a;
    --ok: #4cc38a;
    --warn: #f0a04b;
    --shadow-sm: none;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
    --diagram-a: #7d8c85;
    --diagram-b: #47534e;
    --diagram-stroke: #9aa8a1;
    color-scheme: dark;
  }

*{ box-sizing: border-box; }

[hidden]{ display: none !important; }

html, body{ margin: 0; padding: 0; }

body{
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a{ color: var(--accent); }

.num, .mono{ font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ navbar */
.navbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-inner{
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand{
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  flex: 0 0 auto;
}

.brand img{
  height: 38px;
  width: auto;
  display: block;
}

/* logo-dark.png is the same logo with the dark green recoloured light */
.brand .logo-dark{ display: none; }
:root[data-theme="dark"] .brand .logo-light{ display: none; }
:root[data-theme="dark"] .brand .logo-dark{ display: block; }

/* language flags + theme toggle, top right */
.nav-tools{
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}
.nav-tools.alone{ margin-left: auto; }
.logout-form{ margin: 0; display: contents; }
.flag-btn{
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
  opacity: .5;
  filter: grayscale(.6);
  transition: opacity .15s ease, filter .15s ease, border-color .15s ease, background .15s ease;
}
.flag-btn svg{ width: 24px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.12); display: block; }
.flag-btn:hover{ opacity: 1; filter: none; background: var(--surface-2); }
.flag-btn.active{ opacity: 1; filter: none; border-color: var(--border-strong); background: var(--surface-2); }
.flag-btn:focus-visible, .theme-btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-btn{
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-left: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.theme-btn:hover{ color: var(--accent); border-color: var(--accent); }
.theme-btn.active{ color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-btn svg{ width: 17px; height: 17px; }
.theme-btn .sun{ display: none; }
:root[data-theme="dark"] .theme-btn .sun{ display: block; }
:root[data-theme="dark"] .theme-btn .moon{ display: none; }

.brand-name{
  font-weight: 600;
  font-size: 15px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.nav-links{
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin-left: auto;
}
.nav-links::-webkit-scrollbar{ display: none; }

.nav-link{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.nav-link svg{ width: 17px; height: 17px; flex: 0 0 auto; }
.nav-link:hover{ background: var(--surface-2); color: var(--text); }
.nav-link.active{ background: var(--accent-soft); color: var(--accent); }
.nav-link:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* common.js adds .compact when the labels don't fit (width depends on language),
   and .tight when even the icons need the brand name's space. */
.navbar.compact .nav-link span{ display: none; }
.navbar.compact .nav-link{ padding: 9px 11px; }
.navbar.tight .brand-name{ display: none; }
.navbar.tight .navbar-inner{ gap: 12px; padding: 0 16px; }
@media (max-width: 640px){
  .brand-name{ display: none; }
  /* phones: logo + flags/theme/logout on the first row, menu icons on a second row */
  .navbar-inner{ gap: 4px 12px; padding: 8px 16px 6px; height: auto; flex-wrap: wrap; }
  .nav-tools{ margin-left: auto; padding-left: 0; border-left: 0; gap: 4px; }
  .nav-links{ order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .nav-link span{ display: none; }
  .nav-link{ padding: 9px 14px; }
}

/* -------------------------------------------------------------------- page */
.page{
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 36px 24px 56px;
  flex: 1;
}
.page.narrow{ max-width: 1160px; }

.page-header{ margin-bottom: 28px; }

.eyebrow{
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}

h1{
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 8px;
  font-weight: 700;
}

.lead{
  color: var(--muted);
  font-size: 16px;
  margin: 0;
  max-width: 64ch;
}

.site-footer{
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

@media (max-width: 640px){
  .page{ padding: 24px 16px 40px; }
  h1{ font-size: 25px; }
}

/* ------------------------------------------------------------------- cards */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body{ padding: 24px; }

.card-title{
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 16px;
}

.divider{ border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ----------------------------------------------------------------- buttons */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .05s ease;
}
.btn svg{ width: 16px; height: 16px; }
.btn:hover{ background: var(--surface-2); }
.btn:active{ transform: translateY(1px); }
.btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled{ opacity: .5; cursor: not-allowed; }

.btn-primary{ background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover{ background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger{ background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover{ filter: brightness(.92); background: var(--danger); }

.btn-ghost{ border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover{ background: var(--surface-2); color: var(--text); }
.btn-ghost.danger:hover{ background: var(--danger-soft); color: var(--danger); }

.btn-sm{ padding: 6px 10px; font-size: 13px; }

.icon-btn{
  width: 34px; height: 34px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}
.icon-btn svg{ width: 16px; height: 16px; }
.icon-btn:hover{ color: var(--accent); border-color: var(--accent); }
.icon-btn.copied{ color: var(--ok); border-color: var(--ok); }
.icon-btn:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------- forms */
.field{ display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child{ margin-bottom: 0; }
.field label, .label{ font-size: 13px; font-weight: 600; color: var(--muted); }
.field .hint{ font-size: 12px; color: var(--muted); }

.input, .select{
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 9px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input.num{ font-variant-numeric: tabular-nums; }
.input::placeholder{ color: var(--muted); opacity: .75; }
.input:focus, .select:focus{
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input.invalid{ border-color: var(--danger); }

.select{
  appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%235e6c65'%3E%3Cpath d='M5.3 7.3a1 1 0 0 1 1.4 0L10 10.6l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}

.input-group{ position: relative; }
.input-group .suffix{
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 13px; pointer-events: none;
}
.input-group .input{ padding-right: 48px; }

.form-grid{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full{ grid-column: 1 / -1; }
@media (max-width: 560px){ .form-grid{ grid-template-columns: 1fr; } }

.form-error{ color: var(--danger); font-size: 13px; min-height: 1em; margin: 4px 0 0; }

/* ---------------------------------------------------------- segmented pills */
.segmented{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.segmented button{
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all .15s ease;
}
.segmented button svg{ width: 20px; height: 20px; flex: 0 0 auto; }
.segmented button:hover{ border-color: var(--border-strong); color: var(--text); }
.segmented button[aria-pressed="true"]{
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.segmented button:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------------- stat tiles */
.stats{ display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat{
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  min-width: 0;
}
.stat .label{ display: block; margin-bottom: 6px; }
.stat .value{
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.stat .value small{ font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .sub{ font-size: 13px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.primary{ background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.stat.primary .label, .stat.primary .sub, .stat.primary .value small{ color: inherit; opacity: .8; }
.stat.primary .value{ font-size: 32px; }
.stat.primary .icon-btn{ background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 35%, transparent); }
.stat.primary .icon-btn:hover{ border-color: currentColor; }
.stat .value-row{ display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ------------------------------------------------------------------ switch */
.switch{
  display: inline-flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease;
}
.switch input{ position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track{
  position: relative; flex: 0 0 auto;
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--border-strong);
  transition: background .15s ease;
}
.switch .track::after{
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3);
  transition: transform .15s ease;
}
.switch input:checked + .track{ background: var(--accent); }
.switch input:checked + .track::after{ transform: translateX(18px); }
.switch input:focus-visible + .track{ outline: 2px solid var(--accent); outline-offset: 2px; }
.switch:has(input:checked){ border-color: var(--accent); background: var(--accent-soft); }
.switch-text{ display: flex; flex-direction: column; line-height: 1.3; }
.switch-text small{ color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ alerts */
.alert{
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  font-size: 14px;
}
.alert b{ display: block; margin-bottom: 4px; }
.alert ul{ margin: 4px 0 0; padding-left: 20px; }
.alert li + li{ margin-top: 3px; }
.alert.err{ color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.warn{ color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert.ok{ color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.info{ color: var(--muted); background: var(--surface-2); border-color: var(--border); }

/* ------------------------------------------------------------------ badges */
.badge{
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.badge.ok{ color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: transparent; }
.badge.warn{ color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); border-color: transparent; }

/* ------------------------------------------------------------------- table */
/* No inner scroll box: the page itself scrolls and the header sticks below the navbar.
   Only narrow screens get horizontal scrolling. */
.table-wrap{ border-top: 1px solid var(--border); }
.table th{ top: 64px; }
@media (max-width: 1100px){
  .table-wrap{ overflow-x: auto; scrollbar-width: thin; }
  .table th{ top: 0; }
}
.table{ border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.table th{
  position: sticky; z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td{
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table tbody tr:hover td{ background: var(--surface-2); }
.table td.num, .table th.num{ text-align: right; }
.table .actions{ display: flex; gap: 4px; justify-content: flex-end; }
.table th:first-child, .table td:first-child{ padding-left: 20px; }
.table th:last-child, .table td:last-child{ padding-right: 20px; }
.table tbody tr:last-child td{ border-bottom: 0; }

.empty-state{ text-align: center; padding: 64px 20px; color: var(--muted); }

/* ------------------------------------------------------------------- modal */
.modal{
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(10,16,13,.5);
  backdrop-filter: blur(3px);
}
.modal.open{ display: flex; animation: fade .15s ease; }
.dialog{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
.dialog.small{ width: min(420px, 100%); }
.dialog-header{ padding: 20px 24px 0; }
.dialog-header h2{ margin: 0; font-size: 19px; }
.dialog-header p{ margin: 6px 0 0; color: var(--muted); }
.dialog-body{ padding: 20px 24px; }
.dialog-footer{
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 16px 16px;
}
@keyframes fade{ from{ opacity: 0; } }
@keyframes pop{ from{ opacity: 0; transform: translateY(8px) scale(.98); } }

/* ------------------------------------------------------------------- toast */
#toast{
  position: fixed; right: 24px; bottom: 24px; z-index: 200;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 10px;
  font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px);
  transition: .2s ease; pointer-events: none;
}
#toast.show{ opacity: 1; transform: none; }
#toast.error{ background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce){
  *, *::before, *::after{ transition: none !important; animation: none !important; }
}

/* ---------- range slider ---------- */
.range{
  --fill: 0%;
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 8px 0;
  border-radius: 999px; cursor: pointer; outline: none;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--border-strong) var(--fill));
}
.range::-webkit-slider-thumb{
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.range::-moz-range-thumb{
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.range:focus-visible::-webkit-slider-thumb{ box-shadow: 0 0 0 4px var(--accent-soft); }
.range:focus-visible::-moz-range-thumb{ box-shadow: 0 0 0 4px var(--accent-soft); }
