/* =============================================================
   Field Sales Coordination — application stylesheet (F1 design)
   Owner: frontend. Direction: black and white, one light-blue accent,
   Inter; desktop side menu, phone bottom tabs (decision 2026-11-18).
   Sections: 1 tokens · 2 font · 3 base · 4 layout · 5 menus ·
   6 buttons · 7 forms · 8 messages · 9 badges · 10 cards ·
   11 tables · 12 page header · 13 helpers
   ============================================================= */

/* 1. Tokens — a company changes only --ink/--accent-* to rebrand. */
:root {
  --ink: #111111;          /* text, primary buttons, active menu */
  --ink-2: #3d3d3d;        /* secondary text on white (11:1) */
  --muted: #5f5f5f;        /* help text, dates (6.4:1 on white) */
  --surface: #ffffff;      /* cards, forms, tables */
  --page: #f5f5f4;         /* page background */
  --hover: #efefed;        /* row and menu hover */
  --line: #e4e4e2;         /* card and table borders */
  --line-strong: #a9a9a6;  /* form field borders (3:1) */

  --accent-bg: #e3f0fd;    /* the one blue: "New ..." buttons, selection */
  --accent-ink: #0b4a85;   /* text on --accent-bg (7.6:1) */

  --ok-bg: #e7f4ec;   --ok-ink: #1e6b3f;
  --warn-bg: #fdf1dc; --warn-ink: #7a5200;
  --bad-bg: #fde8e7;  --bad-ink: #a8231a;
  --info-bg: #e3f0fd; --info-ink: #0b4a85;
  --neutral-bg: #f0f0ee; --neutral-ink: #3d3d3d;
  --focus: #2f7fd1;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --sidebar-w: 248px;
  --tabbar-h: 64px;
}

/* 2. Font — Inter served from our own static folder (no request to Google Fonts).
   If the file is missing the system font is used; nothing breaks. */
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.2bf3d951bf9d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* 3. Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 22px;
}
h1 { font-size: 24px; line-height: 30px; font-weight: 700; margin: 0 0 var(--s4); letter-spacing: -0.01em; }
h2 { font-size: 17px; line-height: 24px; font-weight: 600; margin: var(--s6) 0 var(--s3); }
h3 { font-size: 15px; line-height: 22px; font-weight: 600; margin: var(--s4) 0 var(--s2); }
p { margin: 0 0 var(--s3); }
a { color: var(--ink); text-decoration: none; font-weight: 600; }
a:hover { color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* 4. Layout
   Phone first: top bar + content + bottom tabs. From 1024px: side menu + content. */
.app { min-height: 100vh; }
.app-body { min-width: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.site-main { max-width: 1200px; margin: 0 auto; padding: var(--s4); }
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 700; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--ink); color: #ffffff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.brand-name { font-size: 15px; }

.icon-button {
  position: relative; width: 44px; height: 44px; border-radius: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface);
}
.dot-count {
  position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--ink); color: #ffffff;
  font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}

@media (min-width: 1024px) {
  .app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .app-body { padding-bottom: 0; }
  .topbar, .tabbar { display: none; }
  .site-main { padding: var(--s6) var(--s8) var(--s8); }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--s4);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: var(--s5) var(--s3);
    border-right: 1px solid var(--line);
    background: var(--page);
  }
  .sidebar > .brand { padding: 0 var(--s2) var(--s2); }
  .sidebar-footer { margin-top: auto; }
}

/* Login and other public pages */
.public { max-width: 440px; margin: 0 auto; padding: var(--s6) var(--s4); }
.public-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s6); }
.public .site-main { padding: var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }

/* 5. Menus */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 40px; padding: 0 var(--s3);
  border-radius: var(--r-md); border: 1px solid transparent;
  color: var(--ink-2); font-weight: 500; font-size: 14px;
}
.side-nav a:hover { background: var(--hover); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--surface); border-color: var(--line); color: var(--ink); font-weight: 600; }
.side-nav .badge { margin-left: auto; }
.nav-section { margin: var(--s4) 0 var(--s1); padding: 0 var(--s3); font-size: 12px; font-weight: 600; color: var(--muted); }

.account { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); border-top: 1px solid var(--line); }
.account-link { display: flex; align-items: center; gap: var(--s3); }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--hover); display: inline-flex; align-items: center; justify-content: center; }
.account-text { display: flex; flex-direction: column; min-width: 0; }
.account-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-size: 12px; font-weight: 500; color: var(--muted); }
.account-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.account-actions form { margin: 0; }

/* Phone: bottom tabs */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar > a, .tabbar summary {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: #6b6b6b; cursor: pointer; list-style: none;
}
.tabbar summary::-webkit-details-marker { display: none; }
.tabbar > a[aria-current="page"], .more-menu[open] > summary { color: var(--ink); font-weight: 600; }
.tabbar .icon { width: 22px; height: 22px; }
.more-menu { display: block; height: 100%; }
.more-panel {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  max-height: 75vh; overflow-y: auto;
  background: var(--surface); border-top: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s3);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
}

/* 6. Buttons
   Default <button>: black. "New ..." links: .button.button-new (light blue).
   Secondary: .button-secondary or a link directly inside a form ("Cancel"). */
button, .button {
  font: inherit; font-weight: 600; font-size: 15px;
  min-height: 44px; padding: 0 var(--s4);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  border-radius: var(--r-md); border: 1px solid var(--ink);
  background: var(--ink); color: #ffffff; cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, transform 0.05s;
}
button:hover, .button:hover { background: #2b2b2b; color: #ffffff; }
button:active, .button:active { transform: translateY(1px); }
.button-secondary, form > a {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s4);
  border-radius: var(--r-md); border: 1px solid #d6d6d3; background: var(--surface); color: var(--ink);
}
.button-secondary:hover, form > a:hover { background: var(--hover); color: var(--ink); }
.button.button-new { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--accent-ink); }
.button.button-new:hover { background: #cfe3f8; border-color: #cfe3f8; color: var(--accent-ink); }
.button-quiet {
  min-height: 36px; padding: 0 var(--s3); font-size: 13px; font-weight: 500;
  background: transparent; border-color: transparent; color: var(--ink-2);
}
.button-quiet:hover { background: var(--hover); color: var(--ink); }
td button, .inline-form button { min-height: 36px; padding: 0 var(--s3); font-size: 14px; }

/* 7. Forms */
.form-field { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s4); max-width: 560px; }
label { font-size: 14px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="time"], input[type="month"], input[type="tel"], input[type="url"],
input[type="search"], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 0 var(--s3); min-height: 44px; width: 100%;
}
textarea { padding: var(--s3); min-height: 96px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--ink); }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--bad-ink); font-size: 13px; line-height: 18px; }
.form-field:has(.errorlist) :is(input, select, textarea) { border-color: var(--bad-ink); }
.help, .form-help { color: var(--muted); font-size: 13px; line-height: 18px; }
.inline-form, td form { display: inline-flex; gap: var(--s2); align-items: center; margin: 0; }
.language-form { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; }
.language-form select { min-height: 36px; width: auto; font-size: 13px; padding: 0 var(--s2); }
.language-form button { min-height: 36px; font-size: 13px; }

/* Filters: fields side by side, buttons on the same line; wraps on phones. */
.task-filters, .filters, .calendar-options {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); margin-bottom: var(--s4);
}
.task-filters > div, .filters > div { display: flex; flex-direction: column; gap: var(--s1); flex: 1 1 140px; max-width: 220px; }
.task-filters > div:has(input[type="checkbox"]) { flex-direction: row; align-items: center; flex-basis: 100%; max-width: none; }
.task-filters select, .filters select, .calendar-options select { width: 100%; }

/* 8. Messages */
.messages { list-style: none; max-width: 1200px; margin: var(--s4) auto 0; padding: 0 var(--s4); }
.message { padding: var(--s3) var(--s4); border-radius: var(--r-md); margin-bottom: var(--s2); font-weight: 500; }
.message-success { background: var(--ok-bg); color: var(--ok-ink); }
.message-warning { background: var(--warn-bg); color: var(--warn-ink); }
.message-error { background: var(--bad-bg); color: var(--bad-ink); }
.message-info { background: var(--info-bg); color: var(--info-ink); }
@media (min-width: 1024px) { .messages { padding: 0 var(--s8); } }

/* 9. Badges — status shown with text and colour, never colour alone. */
.badge {
  display: inline-flex; align-items: center; gap: var(--s1);
  padding: 2px var(--s2); border-radius: var(--r-sm);
  font-size: 12px; line-height: 18px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-ink);
}
.badge-success, .badge-reviewed, .badge-nfc, .badge-location { background: var(--ok-bg); color: var(--ok-ink); }
.badge-warning, .badge-flag { background: var(--warn-bg); color: var(--warn-ink); }
.badge-danger, .badge-overdue { background: var(--bad-bg); color: var(--bad-ink); }
.badge-info { background: var(--info-bg); color: var(--info-ink); }
/* Counters in menus: small black pills. */
.badge-unread, .badge-pending, .badge-count { min-width: 20px; justify-content: center; border-radius: 10px; background: var(--ink); color: #ffffff; }

/* 10. Cards */
.card, .team-card, .profile-card, .kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4);
}

/* 11. Tables — one look everywhere; too wide ones scroll inside their own box. */
.site-main table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  font-size: 14px; line-height: 20px; margin-bottom: var(--s6); overflow: hidden;
}
.site-main th, .site-main td { padding: var(--s3) var(--s4); text-align: left; vertical-align: middle; border-top: 1px solid var(--line); }
.site-main thead th { border-top: 0; color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.site-main tbody tr:hover { background: #fafaf9; }
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 1023px) {
  .site-main table:not(.responsive-table) { display: block; overflow-x: auto; white-space: nowrap; }
}
/* .responsive-table: cards on phones (cells carry data-label). */
@media (max-width: 767px) {
  .site-main table.responsive-table { display: block; border: 0; background: transparent; overflow: visible; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .responsive-table tbody { display: flex; flex-direction: column; gap: var(--s3); }
  .responsive-table tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s3) var(--s4); }
  .site-main .responsive-table td { display: grid; grid-template-columns: 38% 1fr; gap: var(--s2); padding: var(--s1) 0; border: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 500; }
  .site-main .responsive-table td.cell-title { display: block; font-size: 16px; padding-bottom: var(--s2); }
  .responsive-table td.cell-title::before { content: none; }
}

/* 12. Page header: title on the left, main action on the right. */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-header h1 { margin: 0; }

/* 13. Helpers */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (min-width: 1024px) {
  .topbar, .tabbar { display: none; }
}
