/* Base: reset, typography, forms, tables, flashes and the small utilities every page uses. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.9 var(--font); position: relative; overflow-x: hidden; overflow-x: clip;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--link-hover); }
img { max-width: 100%; display: block; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.45; margin: 0 0 .6em; font-family: var(--font-display); font-weight: 800; letter-spacing: -.3px; text-wrap: balance; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; font-weight: 700; }
p { margin: 0 0 1em; }
strong, b { color: var(--text-strong); }
::selection { background: var(--accent-a30); color: var(--text-strong); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* utilities (kept from the first design so every template keeps working) */
.container { width: min(1200px, 100% - 64px); margin-inline: auto; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: embed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
.stack > * + * { margin-top: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.inline { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prose ul { padding-inline-start: 20px; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); font-size: 14px; }
.field { margin-bottom: 18px; }
.hint { color: var(--text-faint); font-size: 12px; font-weight: 400; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  padding: 10px 14px; min-height: 46px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--field-bg);
  box-shadow: none; outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { min-height: 0; line-height: 1.9; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, textarea:hover, select:hover { border-color: var(--text-faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-a16); }
/* select (closed): same field as the inputs + a pine chevron on the left (RTL end); the open list is modules/select.js */
select, .select-btn { appearance: none; -webkit-appearance: none; cursor: pointer; padding-left: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2370857F' stroke-width='2.2' 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: left 14px center; }
select option { background: var(--surface-2); color: var(--text); }
input[type=checkbox], input[type=radio] {
  width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); box-shadow: none; flex-shrink: 0;
}
input[type=file] { min-height: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
legend, .label-like { display: block; padding: 0; font-weight: 600; margin-bottom: 8px; color: var(--text-soft); font-size: 14px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--text-faint); font-weight: 700; font-size: 12.5px; background: var(--surface-2); }
th:first-child { border-start-start-radius: var(--r-sm); border-end-start-radius: var(--r-sm); }
th:last-child { border-start-end-radius: var(--r-sm); border-end-end-radius: var(--r-sm); }
tbody tr:hover { background: var(--surface-2); }

/* flash messages */
.flash {
  padding: 12px 18px; border-radius: var(--r-md); margin-bottom: 16px; font-size: 14px;
  color: var(--accent-mint); background: var(--accent-a10); border: 1px solid var(--accent-a30);
}
.flash.error { color: var(--danger-text); background: var(--danger-soft); border-color: var(--danger-soft); }

/* .select-list is a fixed dropdown; everything else in body stays in normal flow */

@media (max-width: 900px) {
  .container { width: calc(100% - 32px); }
}

/* small utilities used by page templates instead of inline styles */
.center { text-align: center; }
.m-0 { margin: 0; }
.mt-sm { margin-top: 12px; }
.narrow { max-width: 560px; }
.narrow-lg { max-width: 820px; margin-inline: auto; }
.narrow-sm { max-width: 460px; margin-inline: auto; }
.w-auto { width: auto; }
.grow { flex: 1; min-width: 140px; }
.end { justify-content: flex-end; }
.hidden-input { display: none; }
.delta-pos { color: var(--accent-light); }
.delta-neg { color: var(--danger); }
.spinner-sm { width: 12px; height: 12px; border-width: 2px; }
.row > h1, .row > h2, .row > h3 { margin: 0; }
.w-full { width: 100%; }
.mt-lg { margin-top: 28px; }
.text-danger { color: var(--danger); }
.check-line { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; font-weight: 400; }
.check-line input { margin-top: 4px; }
.code-input { font-size: 1.6rem; letter-spacing: .4em; text-align: center; direction: ltr; }

/* scrollbars inside rounded panels (sidebar, dropdown list, wide tables): thin, rounded, clear of the corners;
   in the sidebar it only shows while the pointer is over it. Chrome/Safari/Edge use ::-webkit-scrollbar
   (margin keeps the track off the rounded corners); Firefox gets the standard thin scrollbar. */
.sidebar-inner::-webkit-scrollbar, .select-list::-webkit-scrollbar, .table-wrap::-webkit-scrollbar, .cmp-box::-webkit-scrollbar { width: 10px; height: 10px; }
.sidebar-inner::-webkit-scrollbar-track, .select-list::-webkit-scrollbar-track { background: transparent; margin-block: 14px; }
.table-wrap::-webkit-scrollbar-track, .cmp-box::-webkit-scrollbar-track { background: transparent; margin-inline: 14px; }
.sidebar-inner::-webkit-scrollbar-thumb, .select-list::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb, .cmp-box::-webkit-scrollbar-thumb {
  background-color: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box;
}
.sidebar-inner::-webkit-scrollbar-thumb { background-color: transparent; }
.sidebar-inner:hover::-webkit-scrollbar-thumb, .sidebar-inner:focus-within::-webkit-scrollbar-thumb { background-color: var(--line-strong); }
.sidebar-inner::-webkit-scrollbar-thumb:hover, .select-list::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }
.sidebar-inner::-webkit-scrollbar-corner { background: transparent; }
@supports not selector(::-webkit-scrollbar) {
  .sidebar-inner, .select-list, .table-wrap, .cmp-box { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
}
