/* GTS design system — ported from the brand book (GTS logoraamat) and the
   legacy app's design tokens (legacy/resources/css/app.css).
   Hand-written on purpose: no build step, semantic classes, element baselines
   so unclassed views inherit the look. */

/* ── Tokens ─────────────────────────────────────────────────────────── */

:root {
  --gts-navy: #002b66;        /* Pantone 281 C  */
  --gts-blue-mid: #0f4ca1;    /* Pantone 653 C  */
  --gts-blue: #578bd3;        /* Process Blue C */
  --gts-cyan: #96b8ff;        /* Process Cyan C */
  --gts-success: #2bde73;
  --gts-success-text: #066839;
  --gts-warning: #ffc924;
  --gts-warning-text: #7a5d00;
  --gts-danger: #ff4843;
  --gts-danger-text: #b3221e;
  --gts-gray-50: #f8fafc;
  --gts-gray-100: #f1f5f9;
  --gts-gray-200: #e2e8f0;
  --gts-gray-300: #cbd5e1;
  --gts-gray-500: #64748b;
  --gts-gray-700: #334155;
  --gts-gray-900: #0f172a;
  --gts-font: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --gts-radius: 12px;
  --gts-radius-sm: 8px;
  --gts-sidebar-w: 220px;
  --gts-focus-ring: 0 0 0 3px rgba(87, 139, 211, 0.35);
}

/* ── Base ───────────────────────────────────────────────────────────── */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--gts-gray-50);
  color: var(--gts-gray-900);
  font-family: var(--gts-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  color: var(--gts-gray-900);
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.17rem; font-weight: 600; margin-top: 1.75rem; }
h3 { font-size: 1rem; font-weight: 600; margin-top: 1.25rem; }

p {
  color: var(--gts-gray-700);
  margin: 0 0 0.75rem;
}

a {
  color: var(--gts-blue-mid);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:is(a, button, input, select, textarea):focus-visible {
  outline: none;
  box-shadow: var(--gts-focus-ring);
}

/* ── App shell ──────────────────────────────────────────────────────── */

.gts-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--gts-sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--gts-navy);
  z-index: 50;
}

.gts-sidebar-logo {
  display: block;
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gts-sidebar-logo img {
  display: block;
  height: 44px;
  /* Brand lockup is the full-colour PNG; render it white on navy. */
  filter: brightness(0) invert(1);
}

.gts-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.gts-nav-link,
button.gts-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 0;
  border-radius: var(--gts-radius-sm);
  background: none;
  color: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
}

.gts-nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.gts-nav-link.active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.gts-nav-link svg {
  width: 20px;
  height: 20px;
  flex: none;
}

.gts-nav-badge {
  margin-left: auto;
  background: var(--gts-cyan);
  color: var(--gts-navy);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
}

.gts-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gts-sidebar-user {
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  padding: 0 0.75rem 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gts-main {
  margin-left: var(--gts-sidebar-w);
  padding: 2rem;
}

.gts-container {
  max-width: 960px;
  margin: 0 auto;
}

/* Locale switcher: light-on-navy in the sidebar, plain on white surfaces. */
.gts-locale {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0 0.75rem;
  font-size: 12px;
}

.gts-locale .current {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.gts-locale button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: underline;
  cursor: pointer;
}

.gts-locale--light .current {
  color: var(--gts-gray-900);
}

.gts-locale--light button {
  color: var(--gts-blue-mid);
}

/* ── Cards & stats ──────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--gts-gray-200);
  border-radius: var(--gts-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.card-featured {
  background: var(--gts-navy);
  border-color: var(--gts-navy);
  color: #fff;
}

.card-featured :is(h1, h2, h3, p, .stat-value) {
  color: #fff;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card-grid .card {
  margin-bottom: 0;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gts-gray-500);
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--gts-gray-900);
}

.stat-sub {
  font-size: 12px;
  color: var(--gts-gray-500);
  margin-top: 0.25rem;
}

.card-featured :is(.stat-label, .stat-sub) {
  color: rgba(255, 255, 255, 0.6);
}

/* ── Tables ─────────────────────────────────────────────────────────── */

.gts-main table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--gts-gray-200);
  border-radius: var(--gts-radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.gts-main th {
  text-align: left;
  padding: 0.75rem 1.25rem;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gts-gray-500);
  background: var(--gts-gray-50);
  border-bottom: 1px solid var(--gts-gray-100);
}

.gts-main td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--gts-gray-700);
  border-bottom: 1px solid var(--gts-gray-100);
}

.gts-main tr:last-child td {
  border-bottom: 0;
}

/* border-radius is clipped away on collapsed tables in some engines;
   wrap wide tables for rounded corners + horizontal scroll on mobile. */
.table-wrap {
  border-radius: var(--gts-radius);
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.table-wrap table {
  margin-bottom: 0;
}

/* ── Badges & progress ──────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--gts-gray-100);
  color: var(--gts-gray-700);
}

.badge-success { background: #e6fbef; color: var(--gts-success-text); }
.badge-warning { background: #fff6d6; color: var(--gts-warning-text); }
.badge-danger  { background: #ffe9e8; color: var(--gts-danger-text); }
.badge-info    { background: #e8effa; color: var(--gts-blue-mid); }

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
  background: var(--gts-gray-300);
}

.dot-success { background: var(--gts-success); }
.dot-warning { background: var(--gts-warning); }
.dot-danger  { background: var(--gts-danger); }

/* ── Phase-2 sweep: error / badge / tile / muted tokens (#141) ───────────
   Semantic replacements for inline `style='...#c00...#fee...#a66...#666...
   #ddd...'` literals scattered across the view + component layer, so a brand
   colour change is a single edit here, not a hand-edit across many files. */

/* Per-field + form error text and the top-of-form / flash error banner.
   `.gts-error` is the inline per-field span (block so it sits under its
   input); `.flash--error` is the boxed banner (form_errors_banner, the
   tenders flash, the account.py error). */
.gts-error {
  display: block;
  color: var(--gts-danger-text);
}

.flash--error {
  color: var(--gts-danger-text);
  background: #ffe9e8;
  padding: 0.5rem;
  border: 1px solid var(--gts-danger);
  border-radius: var(--gts-radius-sm);
}

/* Inline "Vajab täitmist" warning badge on the tank sensor block. */
.badge--danger {
  color: var(--gts-danger-text);
  background: #ffe9e8;
  padding: 0.1rem 0.4rem;
  margin-left: 0.5rem;
  border: 1px solid var(--gts-danger);
  border-radius: 999px;
}

/* "(peidetud)" / "(lukus)" / "(arhiveeritud)" inactive markers next to a
   row's primary link in the admin list views. */
.badge--inactive {
  color: var(--gts-gray-500);
}

/* Dashboard summary tile (admin index). */
.gts-tile {
  display: inline-block;
  padding: 1rem;
  margin: 0.5rem;
  border: 1px solid var(--gts-gray-300);
  border-radius: var(--gts-radius-sm);
}

/* Muted secondary text — the parenthetical counts on the dashboard tiles
   and the inline status-summary separators. */
.gts-muted {
  color: var(--gts-gray-500);
}

/* Visually-hidden text exposed to assistive tech only (unread glyph label,
   etc.). Standard clip-rect sr-only pattern. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.progress-bar {
  height: 28px;
  border-radius: 6px;
  background: var(--gts-gray-100);
  overflow: hidden;
}

.progress-bar .bar {
  height: 100%;
  border-radius: 6px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
}

.progress-bar .bar.green  { background: var(--gts-success); }
.progress-bar .bar.orange { background: var(--gts-warning); }
.progress-bar .bar.red    { background: var(--gts-danger); }

/* ── Forms & buttons ────────────────────────────────────────────────── */

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gts-gray-700);
  margin-bottom: 0.75rem;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--gts-gray-900);
  background: #fff;
  border: 1px solid var(--gts-gray-300);
  border-radius: var(--gts-radius-sm);
}

input[type="hidden"] {
  display: none;
}

:is(input, select, textarea):focus {
  outline: none;
  border-color: var(--gts-blue);
  box-shadow: var(--gts-focus-ring);
}

button,
.btn {
  display: inline-block;
  padding: 0.5rem 1.125rem;
  border: 1px solid var(--gts-navy);
  border-radius: var(--gts-radius-sm);
  background: var(--gts-navy);
  color: #fff;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

:is(button, .btn):hover {
  background: var(--gts-blue-mid);
  border-color: var(--gts-blue-mid);
  text-decoration: none;
}

.btn-secondary {
  background: #fff;
  border-color: var(--gts-gray-300);
  color: var(--gts-gray-700);
}

.btn-secondary:hover {
  background: var(--gts-gray-100);
  border-color: var(--gts-gray-300);
  color: var(--gts-gray-900);
}

.btn-danger {
  background: var(--gts-danger);
  border-color: var(--gts-danger);
}

.btn-danger:hover {
  background: var(--gts-danger-text);
  border-color: var(--gts-danger-text);
}

button.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gts-blue-mid);
  font-weight: 500;
  text-decoration: underline;
}

button.btn-link:hover {
  background: none;
  color: var(--gts-navy);
}

.flash-ok,
.flash-err {
  padding: 0.625rem 1rem;
  border-radius: var(--gts-radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.flash-ok {
  background: #e6fbef;
  color: var(--gts-success-text);
}

.flash-err {
  background: #ffe9e8;
  color: var(--gts-danger-text);
}

/* ── Login ──────────────────────────────────────────────────────────── */

.gts-login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--gts-navy) 0%, var(--gts-blue-mid) 100%);
}

.gts-login-card {
  width: min(400px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 17, 41, 0.35);
}

.gts-login-card .gts-login-logo {
  display: block;
  height: 48px;
  margin: 0 auto 1.5rem;
}

.gts-login-card input:not([type="checkbox"]):not([type="radio"]) {
  max-width: none;
}

/* Full-width submit for the auth forms only — the locale switcher in the
   card footer is also a form with a submit button and must stay inline. */
.gts-login-card form:not(.gts-locale) button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

.gts-login-aux {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 13px;
}

.gts-login-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 12px;
}

/* ── Mobile: sidebar becomes a top bar ──────────────────────────────── */

@media (max-width: 1023px) {
  .gts-sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
  }

  .gts-sidebar-logo {
    padding: 0.5rem 0.75rem 0.5rem 0;
    border-bottom: 0;
  }

  .gts-sidebar-logo img {
    height: 32px;
  }

  .gts-nav {
    flex-direction: row;
    flex: 1 1 auto;
    padding: 0;
    overflow-x: auto;
  }

  .gts-nav-link,
  button.gts-nav-link {
    width: auto;
    white-space: nowrap;
    padding: 0.5rem 0.625rem;
  }

  .gts-sidebar-footer {
    flex-direction: row;
    align-items: center;
    border-top: 0;
    padding: 0;
    margin-left: auto;
  }

  .gts-sidebar-user {
    display: none;
  }

  .gts-main {
    margin-left: 0;
    padding: 1rem;
  }
}
