:root {
  /* Brand: IDN navy with the pink accent, as DeskX and Kesher */
  --navy: #0c2856;
  --brand: #0c2856;
  --brand-strong: #081c3f;
  --brand-tint: #e9eef7;
  --brand-ring: rgba(12, 40, 86, 0.16);
  --accent: #f0408a;
  --accent-strong: #c81e62;
  --accent-tint: #fde9f1;

  /* Neutrals */
  --ink: #16213a;
  --ink-2: #4a5a7a;
  --ink-3: #7a879f;
  --line: #e3e8f0;
  --line-soft: #eef1f6;
  --surface: #ffffff;
  --canvas: #f4f6fa;

  /* Semantic */
  --ok: #067647;
  --warn: #b45309;
  --bad: #b42318;
  --info: #175cd3;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(12, 40, 86, 0.05), 0 1px 3px rgba(12, 40, 86, 0.04);
  --shadow-lift: 0 6px 16px rgba(12, 40, 86, 0.10);

  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Archivo', 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Legacy aliases */
  --primary-color: var(--brand);
  --primary-hover: var(--brand-strong);
  --primary: var(--brand);
  --bg-color: var(--canvas);
  --surface-color: var(--surface);
  --glass-border: var(--line);
  --text-dark: var(--ink);
  --text-light: var(--ink-2);
  --success: var(--ok);
  --danger: var(--bad);
  --warning: var(--warn);
}

html, body {
  overflow-x: hidden;
  position: relative;
  width: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  background: var(--canvas);
  color: var(--ink);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.015em;
  text-wrap: balance;
}

a { color: var(--brand-strong); }

.mono, td.num, .tdr-stat .v, .ref {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.glass-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

/* Navigation & Header Overhaul */
header, header.glass-panel {
  padding: 0 1.75rem;
  height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  z-index: 1000;
  position: sticky;
  top: 0;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 0 0 auto;
  margin-right: 1.5rem;
}

.logo-img {
  height: 34px !important;
  width: auto;
  filter: none !important;
  border-radius: 6px;
}

header .logo {
  font-family: var(--font-display);
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em;
  color: var(--ink) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  margin: 0;
  line-height: 1.15;
}

header .logo-sub {
  font-family: var(--font-ui);
  font-size: 0.6rem !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--ink-3) !important;
  line-height: 1.3;
}

/* DESKTOP Navigation Section */
.desktop-nav-container {
  display: flex;
  flex: 1;
  justify-content: space-between;
  align-items: center;
  height: 100%;
}

@media (max-width: 768px) {
  .desktop-nav-container {
    display: none;
  }
}

nav.main-nav {
  flex: 1;
  display: flex;
  justify-content: center;
}

nav.main-nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

nav.main-nav { justify-content: flex-start; }

nav.main-nav ul { gap: 0.15rem; }

nav.main-nav > ul > li > a {
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, color 0.15s ease;
  display: block;
  white-space: nowrap;
}

nav.main-nav > ul > li > a:hover {
  background: var(--brand-tint);
  color: var(--brand-strong);
}

/* Dropdown caret */
nav.main-nav .dropbtn::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-left: 7px;
  vertical-align: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
}

/* User Zone */
.user-zone {
  flex: 0 0 240px;
  display: flex;
  justify-content: flex-end;
}

/* Hamburger Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 3000;
}

/* Mobile drawer: hidden by default on desktop */
.mobile-drawer {
  display: none;
}

/* Close button inside mobile drawer */
.mobile-drawer-close {
  position: absolute;
  top: 1.2rem;
  right: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-dark);
  z-index: 9100;
  padding: 0.5rem;
  transition: color 0.2s;
}
.mobile-drawer-close:hover {
  color: var(--primary-color);
}

.hamburger-box { width: 30px; height: 24px; display: inline-block; position: relative; }
.hamburger-inner { width: 100%; height: 2px; background-color: var(--primary-color); position: absolute; left: 0; top: 50%; transform: translateY(-50%); transition: all 0.3s; }
.hamburger-inner::before, .hamburger-inner::after { content: ""; width: 100%; height: 2px; background-color: var(--primary-color); position: absolute; transition: all 0.3s; }
.hamburger-inner::before { top: -8px; }
.hamburger-inner::after { top: 8px; }

.mobile-menu-toggle.active .hamburger-inner { background-color: transparent; }
.mobile-menu-toggle.active .hamburger-inner::before { top: 0; transform: rotate(45deg); background-color: var(--danger); }
.mobile-menu-toggle.active .hamburger-inner::after { top: 0; transform: rotate(-45deg); background-color: var(--danger); }

/* Professional Dropdown */
.dropdown {
  position: relative;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lift);
  padding: 0.3rem;
  z-index: 2000;
  margin-top: 0;
}

.dropdown-content::before {
  content: "";
  position: absolute;
  top: -20px;
  left: 0;
  width: 100%;
  height: 20px;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content a {
  display: block;
  padding: 0.5rem 0.7rem !important;
  font-size: 0.855rem !important;
  line-height: 1.35;
  color: var(--ink-2);
  border-radius: 6px !important;
  font-weight: 500 !important;
  text-decoration: none;
  white-space: nowrap;
}

.dropdown-content a:hover {
  background: var(--brand-tint) !important;
  color: var(--brand-strong) !important;
}

.dropdown-content form button {
  padding: 0.5rem 0.7rem !important;
  font-size: 0.855rem !important;
  border-radius: 6px !important;
  color: var(--danger);
  font-weight: 600 !important;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.dropdown-content form button:hover {
  background: var(--danger) !important;
  color: #fff !important;
}

.user-zone { flex: 0 0 auto; }

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  padding: 0.3rem 0.5rem 0.3rem 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.user-profile-trigger:hover {
  background: var(--line-soft);
}

.user-avatar {
  width: 30px;
  height: 30px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta .username {
  font-weight: 600;
  font-size: 0.83rem;
}

.user-meta .institution {
  font-size: 0.7rem;
  color: var(--ink-3);
  font-weight: 500;
}

.user-dropdown-content {
  right: 0 !important;
  left: auto !important;
  transform: none !important;
  min-width: 240px;
}

.dropdown:hover .user-dropdown-content {
  display: block;
}

.dropdown-header {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  margin-bottom: 0.5rem;
}

.dropdown-header .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-light);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.dropdown-header .value {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--brand-strong);
  font-family: var(--font-mono);
}

/* Ensure the divider is clean */
.dropdown-divider {
  height: 1px;
  background: rgba(0,0,0,0.05);
  margin: 0.5rem 0;
}

/* Main Container */
main {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Dashboard Cards */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.25rem 1.4rem;
  text-align: left;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
  border-color: #c9d3e3;
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 3px;
  background: var(--brand);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.stat-card:hover::before { opacity: 1; }

.stat-card h3 {
  margin: 0; font-family: var(--font-ui);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-3);
}
.stat-card p {
  margin: 0.35rem 0 0; font-family: var(--font-display);
  font-size: 2rem; font-weight: 700; color: var(--ink);
  line-height: 1.05; font-variant-numeric: tabular-nums;
}

/* Tables */
.table-container {
  overflow-x: auto;
  padding: 0;
  margin-top: 1.25rem;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}

th {
  padding: 0.6rem 0.9rem;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  background: var(--line-soft);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 0.7rem 0.9rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.15s ease;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fbf9; }

/* Status Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.685rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  line-height: 1.55;
}
.badge.pending, .badge.draft { background: #fef3c7; color: #92400e; }
.badge.approved, .badge.fulfilled { background: #d5f2e3; color: #065f46; }
.badge.rejected, .badge.cancelled { background: #fde7e5; color: #991b1b; }

/* Forms */
.form-group { margin-bottom: 1.1rem; }
.form-group > label {
  display: block; margin-bottom: 0.3rem;
  font-size: 0.775rem; font-weight: 600; color: var(--ink-2);
}
.form-input, .form-select,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"],
input[type="search"], input[type="date"], input[type="datetime-local"],
input[type="time"], input[type="month"], input[type="week"],
input[type="file"], textarea, select {
  width: 100%;
  padding: 0.44rem 0.65rem;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
textarea { min-height: 64px; line-height: 1.5; padding: 0.5rem 0.65rem; }
input::placeholder, textarea::placeholder { color: #a4b2ac; }
input[type="date"], input[type="datetime-local"], input[type="number"] {
  font-variant-numeric: tabular-nums;
}
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; min-height: 0; padding: 0;
  accent-color: var(--brand); vertical-align: middle; cursor: pointer;
}
.form-input:focus, .form-select:focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="tel"]:focus, input[type="url"]:focus,
input[type="search"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus,
input[type="time"]:focus, input[type="month"]:focus, input[type="week"]:focus,
input[type="file"]:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* Tom Select */
.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
  width: 100%;
  padding: 0.44rem 1.6rem 0.44rem 0.65rem;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  box-shadow: none;
}
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
.ts-wrapper .ts-control > input {
  font-family: inherit;
  font-size: 0.875rem;
}
.ts-wrapper.single .ts-control::after {
  border-color: var(--ink-3) transparent transparent !important;
}
.ts-dropdown {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  padding: 0.25rem;
}
.ts-dropdown .option {
  padding: 0.45rem 0.7rem;
  font-size: 0.865rem;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.ts-dropdown .option:hover,
.ts-dropdown .active {
  background: var(--brand-tint);
  color: var(--brand-strong);
}
.ts-dropdown .option.selected {
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-weight: 600;
}
.ts-dropdown .no-results {
  padding: 0.75rem 0.9rem;
  font-style: italic;
}
/* Compact variant for inline table cells */
#itemsTable .ts-wrapper.single .ts-control { min-height: 38px; padding: 0.4rem 0.6rem; }

/* Icon button */
.btn-icon {
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 1;
  border-radius: 6px;
}
.btn-icon svg { display: block; }
.btn-icon-group { display: inline-flex; gap: 4px; align-items: center; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.45rem 0.9rem; min-height: 38px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 0.855rem;
  cursor: pointer; text-decoration: none; box-sizing: border-box;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--line-soft); color: var(--ink); border-color: #c9d3e3; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }

/* Actions */
.action-forms { display: flex; gap: 0.5rem; }
.btn-sm { padding: 0.25rem 0.6rem; min-height: 30px; font-size: 0.78rem; }
.btn-success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-success:hover { background: #05603a; border-color: #05603a; color: #fff; }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-danger:hover { background: #912018; border-color: #912018; color: #fff; }

/* Micro animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.5s ease forwards; }

.messages {
  padding: 1rem 2rem 0; max-width: 1320px;
  margin: 0 auto; width: 100%; box-sizing: border-box;
}
.messages:empty { padding: 0; }
.alert {
  padding: 0.7rem 0.95rem; border-radius: var(--radius-sm);
  margin-bottom: 0.6rem; font-weight: 500; font-size: 0.875rem;
  border: 1px solid transparent; box-shadow: none;
}
.alert-success { background: #eafaf1; color: #05603a; border-color: #b6e6cd; }
.alert-warning { background: #fdeceb; color: #912018; border-color: #f5cfcb; }
.alert-error { background: #fdeceb; color: #912018; border-color: #f5cfcb; }
.alert-info { background: #eff4ff; color: #1849a9; border-color: #cddcfb; }

/* --- Mobile Responsiveness Overhaul --- */
@media (max-width: 768px) {
  header, header.glass-panel {
    height: 56px;
    margin: 0;
    padding: 0 1rem;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  header .logo-link {
    flex: none;
    gap: 8px;
  }

  header .logo-img {
    height: 30px !important;
  }

  header .logo {
    flex: none;
    font-size: 1.05rem !important;
  }

  header .logo-sub { display: none; }

  .messages { padding: 0.75rem 1rem 0; }

  .mobile-menu-toggle {
    display: block;
  }

  /* --- The New Full-Page Mobile Drawer --- */
  .mobile-drawer {
    display: block; /* Override global display:none for mobile */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    z-index: 9000; /* Sit above everything */
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
    pointer-events: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-drawer.active {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-drawer-content {
    padding: 100px 2rem 5rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    min-height: 100%;
    box-sizing: border-box;
  }

  .mobile-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
  }

  .mobile-nav a {
    text-decoration: none;
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    transition: color 0.2s ease;
  }

  .mobile-nav a:hover {
    color: var(--primary-color);
  }

  /* Handle Dropdowns in Mobile (Flatten them) */
  .mobile-nav .dropdown-content {
    display: block;
    position: static;
    box-shadow: none;
    padding: 1rem 0 0 1.5rem;
    background: none;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .mobile-nav .dropdown-content a {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-light);
  }

  .mobile-nav .dropbtn {
    /* Match regular nav link style */
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    text-decoration: none;
    display: block;
    pointer-events: none; /* Label only, not clickable */
    padding: 0;
    background: none;
    border: none;
    text-transform: none;
    letter-spacing: normal;
  }

  .mobile-lang-zone, .mobile-user-zone {
    border-top: 1px solid var(--glass-border);
    padding-top: 2rem;
  }

  body.menu-open {
    overflow: hidden; /* Prevent background scroll without position:fixed jump */
  }
  main {
    padding: 1rem;
  }
  
  .glass-panel {
    border-radius: 12px;
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  div[style*="grid-template-columns: 1fr 1fr"], 
  div[style*="grid-template-columns:1fr 1fr"], 
  div[style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .messages {
    padding: 0 1rem;
  }

  .table-container {
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }
  
  th, td {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }
  
  .btn {
    padding: 0.6rem 1rem;
  }

  /* --- BOQ Table → Card Layout on Mobile --- */
  #itemsTable thead {
    display: none; /* Hide the header row */
  }

  #itemsTable tr {
    display: block;
    background: rgba(255,255,255,0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
  }

  #itemsTable td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
  }

  #itemsTable td:last-child {
    border-bottom: none;
    padding-top: 0.75rem;
    justify-content: flex-end;
  }

  /* Show data-label as the left label */
  #itemsTable td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 0 0 auto;
    min-width: 80px;
  }

  #itemsTable td .form-input {
    flex: 1;
    min-width: 0;
  }

  #itemsTable td[data-label=" "]::before {
    display: none; /* No label for the remove button cell */
  }

  /* Autocomplete dropdown should still work in card layout */
  #itemsTable td[style*="position: relative"] {
    position: relative !important;
    flex-direction: column;
    align-items: stretch;
  }

  #itemsTable td[style*="position: relative"]::before {
    align-self: flex-start;
  }
}

/* --- Global Page Loader --- */
.global-loader {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--brand-tint);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  box-shadow: none;
}

.loader-text {
  margin-top: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  font-size: 1.1rem;
  letter-spacing: 1px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin { 
  to { transform: rotate(360deg); } 
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.95); }
}

/* ============================================================
   Custom Autocomplete Dropdown (BOQ Item Descriptions)
   ============================================================ */
.ac-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--glass-border);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 5000;
  max-height: 220px;
  overflow-y: auto;
}

.ac-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dark);
  border-bottom: 1px solid rgba(0,0,0,0.04);
  transition: background 0.15s;
}

.ac-item:last-child {
  border-bottom: none;
  border-radius: 0 0 10px 10px;
}

.ac-item:hover, .ac-item.ac-active {
  background: var(--brand-tint);
  color: var(--brand-strong);
}

.ac-item mark {
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-weight: 700;
  border-radius: 2px;
  padding: 0 2px;
}


/* ============================================================
   Attachment Cards
   ============================================================ */
.att-card {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.att-preview {
  height: 140px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.04);
}

.att-icon-card {
  flex-direction: column;
  gap: 0.5rem;
}

.att-ext-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.att-filename {
  font-size: 0.8rem;
  font-weight: 600;
  word-break: break-all;
  color: var(--text-dark);
  margin: 0;
  line-height: 1.4;
}

/* ============================================================
   Tender management (phases 1-3)
   ============================================================ */

.tdr-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}

.faint { color: var(--text-light, #6b7280); font-size: 0.82rem; }

.tdr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.tdr-stat {
  background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 14px;
  padding: 0.9rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem;
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.tdr-stat .k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light, #6b7280); }
.tdr-stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.tdr-stat.warn { background: #fffaf0; border-color: #f5d9a8; }
.tdr-stat.warn .v { color: #b45309; }

.tdr-filters { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }

.chip-link {
  display: inline-block; padding: 0.22rem 0.7rem; border-radius: 999px;
  background: #eef2f6; color: #374151; font-size: 0.8rem; text-decoration: none;
}
.chip-link:hover { background: #e2e8f0; text-decoration: none; }
.chip-link.on { background: #10b981; color: #fff; }
.chip-link.warn { background: #fde8c8; color: #92400e; }

.tdr-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.tdr-key {
  background: #fff; border: 1px solid rgba(0,0,0,0.06); border-radius: 14px; padding: 0.9rem 1.1rem;
}
.tdr-key .k { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-light, #6b7280); }
.tdr-key .v { display: block; font-size: 1.05rem; font-weight: 700; margin-top: 0.15rem; }
.tdr-key .s { display: block; font-size: 0.78rem; color: var(--text-light, #6b7280); }
.tdr-key .s.urgent { color: #b91c1c; font-weight: 600; }

.tdr-bar { height: 7px; border-radius: 999px; background: #eef2f6; margin-top: 0.5rem; overflow: hidden; }
.tdr-bar span { display: block; height: 100%; background: linear-gradient(90deg, #10b981, #059669); }

.tdr-alert {
  background: #fef2f2; border: 1px solid #fbcfcf; color: #991b1b;
  border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.88rem;
}
.tdr-alert.soft { background: #fffaf0; border-color: #f5d9a8; color: #92400e; }

.tdr-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.5rem; }
.inline-form { display: inline-flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form .form-input, .inline-form .form-select { max-width: 230px; padding: 0.35rem 0.6rem; font-size: 0.85rem; }

.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; flex-wrap: wrap; margin: 1rem 1.5rem;
}

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

.tdr-section {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-light, #6b7280); margin: 1.4rem 0 0.6rem;
  border-bottom: 1px solid rgba(0,0,0,0.06); padding-bottom: 0.35rem;
}

.tdr-due { font-size: 0.75rem; font-weight: 600; }
.tdr-due.soon { color: #b45309; }
.tdr-due.over { color: #b91c1c; }
.tdr-ok { color: #059669; font-weight: 700; }
.tdr-unassigned { color: #b45309; font-weight: 600; font-size: 0.85rem; }

.tdr-outstanding { margin-top: 0.7rem; display: flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }

.tdr-timeline { list-style: none; padding: 0; margin: 1rem 0 0; }
.tdr-timeline li { padding: 0.6rem 0; border-bottom: 1px solid rgba(0,0,0,0.06); font-size: 0.88rem; }
.tdr-timeline li:last-child { border-bottom: none; }

.tdr-event-form { display: flex; flex-direction: column; gap: 0.5rem; }
.tdr-event-form .frow { display: flex; gap: 0.5rem; }

table.mini { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.mini td { padding: 0.35rem 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }

tr.row-past { opacity: 0.55; }
tr.row-soon { background: #fffaf0; }

/* Stage and status badges */
.badge.stage-registered  { background: #e5edff; color: #1e40af; }
.badge.stage-go_no_go    { background: #ede9fe; color: #5b21b6; }
.badge.stage-packaging   { background: #e0f2fe; color: #075985; }
.badge.stage-preparation { background: #fef3c7; color: #92400e; }
.badge.stage-submitted   { background: #dbeafe; color: #1d4ed8; }
.badge.stage-evaluation  { background: #ede9fe; color: #5b21b6; }
.badge.stage-won         { background: #d1fae5; color: #065f46; }
.badge.stage-lost        { background: #fee2e2; color: #991b1b; }
.badge.stage-no_bid      { background: #e5e7eb; color: #374151; }
.badge.stage-cancelled   { background: #e5e7eb; color: #374151; }

.badge.pk-invited    { background: #e5e7eb; color: #374151; }
.badge.pk-accepted   { background: #e0f2fe; color: #075985; }
.badge.pk-submitting { background: #fef3c7; color: #92400e; }
.badge.pk-complete   { background: #d1fae5; color: #065f46; }
.badge.pk-withdrawn  { background: #fee2e2; color: #991b1b; }

.badge.it-pending   { background: #e5e7eb; color: #374151; }
.badge.it-submitted { background: #dbeafe; color: #1d4ed8; }
.badge.it-accepted  { background: #d1fae5; color: #065f46; }
.badge.it-rejected  { background: #fee2e2; color: #991b1b; }
.badge.it-waived    { background: #f3f4f6; color: #6b7280; }

/* ==== Layout ==== */

/* --- Form grid --- */
.frow {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem 1.1rem;
  margin-bottom: 0.85rem;
  align-items: start;
}

.f, .frow > label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.85rem;
  min-width: 0;
}

.frow > .f, .frow > label { margin-bottom: 0; }

.f > span:first-child {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--ink-2);
}

/* Field hint */
.f > .hint, .f small {
  font-size: 0.72rem;
  color: var(--ink-3);
  line-height: 1.4;
}

.f.wide { grid-column: span 2; }
.f.full { grid-column: 1 / -1; }
.f .errorlist {
  list-style: none; margin: 0.2rem 0 0; padding: 0;
  color: var(--bad); font-size: 0.74rem; font-weight: 500;
}

/* Checkbox row */
.f.check { flex-direction: row; align-items: center; gap: 0.5rem; min-height: 38px; }
.f.check > span:first-child { order: 2; font-weight: 500; }

/* Form footer */
.form-actions {
  display: flex; gap: 0.6rem; align-items: center;
  margin-top: 1.4rem; padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
.form-actions .spacer { flex: 1; }

.f textarea { min-height: 72px; }

/* --- Page header --- */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h2, .page-head h1 {
  margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2;
}
.page-head .sub { color: var(--ink-2); font-size: 0.875rem; margin-top: 0.2rem; }
.page-head .acts { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.crumb {
  font-size: 0.76rem; color: var(--ink-3); margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--brand-strong); text-decoration: underline; }

/* --- Card interior --- */
.card-pad { padding: 1.25rem 1.4rem; }
.card-title {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  margin: 0 0 0.9rem;
}

.table-card { overflow: hidden; padding: 0; }
.table-card > .panel-head { margin: 1rem 1.25rem; }

.empty-state {
  padding: 2.5rem 1rem; text-align: center;
  color: var(--ink-3); font-size: 0.9rem;
}

/* ==== tender surfaces, retuned ============================================ */

.faint { color: var(--ink-3); font-size: 0.8rem; }

.tdr-head { margin-bottom: 1.25rem; align-items: flex-end; }

.tdr-stats {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem; margin-bottom: 1.1rem;
}
.tdr-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.8rem 1rem; box-shadow: var(--shadow); gap: 0.2rem;
}
.tdr-stat .k {
  font-size: 0.68rem; letter-spacing: 0.07em; color: var(--ink-3); font-weight: 600;
}
.tdr-stat .v {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; color: var(--ink);
}
.tdr-stat.warn { background: #fffbf2; border-color: #f3ddb4; }
.tdr-stat.warn .v { color: var(--warn); }

/* Filter row */
.tdr-filters {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tdr-filters .inline-form { gap: 0.5rem; }

.inline-form { display: inline-flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form .form-input,
.inline-form .form-select,
.inline-form input,
.inline-form select { width: auto; min-width: 200px; }
.inline-form .ts-wrapper { width: auto !important; min-width: 200px; max-width: 260px; }
.inline-form .ts-wrapper .ts-control { min-height: 34px; padding-top: 0.28rem; padding-bottom: 0.28rem; }
.inline-form .btn { min-height: 34px; padding: 0.25rem 0.75rem; font-size: 0.8rem; }
.inline-form input, .inline-form select { min-height: 34px; font-size: 0.83rem; }

.chip-link {
  display: inline-block; padding: 0.25rem 0.7rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 0.79rem; font-weight: 500; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip-link:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.chip-link.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-link.warn { background: #fdf3e3; border-color: #f3ddb4; color: var(--warn); }

.tdr-keys { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.75rem; }
.tdr-key {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.8rem 1rem;
}
.tdr-key .k { font-size: 0.68rem; letter-spacing: 0.07em; color: var(--ink-3); font-weight: 600; }
.tdr-key .v { font-size: 1rem; font-weight: 700; margin-top: 0.15rem; }
.tdr-key .s { font-size: 0.76rem; color: var(--ink-3); }
.tdr-key .s.urgent { color: var(--bad); font-weight: 600; }

.tdr-bar { background: var(--line-soft); height: 6px; }
.tdr-bar span { background: var(--brand); }

.tdr-alert {
  background: #fdeceb; border-color: #f5cfcb; color: #912018;
  border-radius: var(--radius-sm); font-size: 0.855rem; padding: 0.7rem 0.95rem;
}
.tdr-alert.soft { background: #fffbf2; border-color: #f3ddb4; color: var(--warn); }

.tdr-section {
  font-size: 0.7rem; letter-spacing: 0.08em; font-weight: 600;
  color: var(--ink-3); margin: 1.5rem 0 0.8rem;
  border-bottom: 1px solid var(--line); padding-bottom: 0.4rem;
}
.tdr-section:first-child { margin-top: 0; }

.tdr-actions { gap: 0.5rem; margin-bottom: 0.75rem; }

.panel-head { margin: 1.1rem 1.4rem; align-items: center; }
.panel-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }

.tdr-columns { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; margin-top: 1rem; }

.tdr-due { font-size: 0.73rem; font-weight: 600; }
.tdr-timeline li { font-size: 0.855rem; border-bottom-color: var(--line-soft); }
.tdr-event-form .frow { display: flex; gap: 0.5rem; margin-bottom: 0; }
.tdr-event-form .frow > .f { margin-bottom: 0; }

table.mini td { border-bottom-color: var(--line-soft); font-size: 0.855rem; }
tr.row-soon { background: #fffbf2; }

td .ref, a.ref { font-family: var(--font-mono); font-size: 0.82rem; letter-spacing: -0.01em; }

@media (max-width: 640px) {
  .frow { grid-template-columns: 1fr; }
  .f.wide, .f.full { grid-column: auto; }
  main { padding: 1rem 1rem 2rem; }
  .page-head { align-items: flex-start; }
  .inline-form .ts-wrapper,
  .inline-form input,
  .inline-form select { min-width: 0; width: 100%; max-width: none; }
  .inline-form { width: 100%; }
}

/* --- Brand block and language switcher --- */
.brand-text { display: flex; flex-direction: column; }

.lang-switcher-zone { margin-right: 0.5rem; }

.lang-btn {
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0.28rem 0.6rem; font-family: inherit; font-size: 0.78rem; font-weight: 600;
  color: var(--ink-2); cursor: pointer; display: flex; align-items: center; gap: 0.35rem;
  letter-spacing: 0.04em; transition: background 0.15s ease;
}
.lang-btn:hover { background: var(--line-soft); color: var(--ink); }
.lang-btn::after {
  content: ""; width: 4px; height: 4px; vertical-align: 1px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px); opacity: 0.6;
}

.lang-menu { min-width: 160px; right: 0; left: auto; transform: none; }
.lang-menu a.is-current {
  font-weight: 600; color: var(--brand-strong) !important; background: var(--brand-tint);
}

.mobile-lang-zone .btn { width: 100%; }

.chip-group { display: inline-flex; gap: 0.3rem; align-items: center; }
.tdr-filters .inline-form { margin-left: auto; }
@media (max-width: 760px) {
  .tdr-filters .inline-form { margin-left: 0; }
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0 1.1rem;
}
.form-grid .form-group { min-width: 0; }
.form-grid .form-group:has(textarea) { grid-column: 1 / -1; }

.field-error { color: var(--bad); font-size: 0.75rem; margin-top: 0.3rem; font-weight: 500; }
.field-error ul { list-style: none; margin: 0; padding: 0; }
.hint { font-size: 0.72rem; color: var(--ink-3); margin-top: 0.25rem; line-height: 1.4; }

/* Tom Select wrapper reset */
.ts-wrapper.form-select,
.ts-wrapper.form-input,
.ts-wrapper.form-control {
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  min-height: 0 !important;
  box-shadow: none !important;
}

.ts-wrapper .ts-control > .item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ts-wrapper.disabled .ts-control { background: var(--line-soft); color: var(--ink-3); }

/* Semantic buttons */
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-warn:hover { background: #92400e; border-color: #92400e; color: #fff; }
.btn-info { background: var(--info); color: #fff; border-color: var(--info); }
.btn-info:hover { background: #1849a9; border-color: #1849a9; color: #fff; }

/* Tom Select caret */
.ts-wrapper.single .ts-control { padding-right: 1.8rem !important; }
.ts-wrapper.single .ts-control::after {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  top: 50% !important;
  right: 0.75rem !important;
  left: auto !important;
  width: 6px !important;
  height: 6px !important;
  margin: 0 !important;
  border: 0 !important;
  border-right: 1.5px solid var(--ink-3) !important;
  border-bottom: 1.5px solid var(--ink-3) !important;
  transform: translateY(-70%) rotate(45deg) !important;
  transition: transform 0.15s ease;
}
.ts-wrapper.single.dropdown-active .ts-control::after {
  transform: translateY(-25%) rotate(-135deg) !important;
}

/* Checklist row actions */
.row-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row-actions .inline-form { margin: 0; }
.form-input.file-sm { max-width: 190px; min-height: 30px; padding: 0.15rem 0.3rem; font-size: 0.78rem; }
.row-actions .form-input[name="reason"] { max-width: 150px; min-width: 0; min-height: 30px; font-size: 0.78rem; }

/* File inputs */
input[type="file"] { padding: 0.28rem 0.5rem; font-size: 0.83rem; }
input[type="file"]::file-selector-button {
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink-2);
  padding: 0.2rem 0.6rem; margin-right: 0.6rem; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--line-soft); color: var(--ink); }

.ref, td .ref, a.ref { white-space: nowrap; }

/* Table links */
tbody td a { color: var(--ink); text-decoration: none; }
tbody td a:hover { color: var(--brand-strong); text-decoration: underline; }
tbody td a.ref { color: var(--brand-strong); font-weight: 600; }

/* Terms preview */
.terms-preview { font-size: 0.9rem; line-height: 1.65; }
.terms-preview .terms-h { font-size: 0.95rem; font-weight: 700; margin: 1.2rem 0 0.35rem; }
.terms-preview .terms-h:first-child { margin-top: 0; }
.terms-preview .terms-p { margin: 0 0 0.7rem; color: var(--ink-2); }
.terms-preview strong { color: var(--ink); }

/* Tender form validation, shown instead of swallowed. */
.tdr-form-errors {
  background: #fdecec; border: 1px solid #f0b9b4; color: #a02c21;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 0.9rem;
}
.tdr-form-errors div { margin: 2px 0; }

/* The inline partner picker on the package list. */
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.form-select-sm { padding: 6px 26px 6px 10px; font-size: 0.85rem; min-width: 170px; }

.cmp-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}
.cmp-toggle:hover, .cmp-toggle[aria-expanded="true"] { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-strong); }
.cmp-sub > td { background: var(--canvas); padding: 0.6rem 1rem 0.9rem 3rem; }
.cmp-subgrid { width: 100%; font-size: 0.82rem; background: var(--surface); border: 1px solid var(--line-soft); border-radius: 8px; }
.cmp-subgrid th { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line-soft); }
.cmp-subgrid td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.cmp-subgrid tr:last-child td { border-bottom: 0; }

/* ---------- RelaX shell: navy sidebar on the left, white top bar, content beside ---------- */
.shell { display: block; padding-left: 236px; min-height: 100vh; }
.shell.shell-public { padding-left: 0; }
.sidebar { background: var(--navy); color: #cdd6e6; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; width: 236px; overflow-y: auto; overscroll-behavior: contain; z-index: 950; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 3px; }
.sb-brand { display: flex; align-items: center; padding: 18px 18px 10px; position: sticky; top: 0; background: var(--navy); z-index: 2; }
.sb-brand img { height: 46px; width: auto; }
.sb-nav { padding: 8px 10px 16px; flex: 1; }
.sb-link { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: #cdd6e6; text-decoration: none; font-size: 0.86rem; font-weight: 500; line-height: 1.3; }
.sb-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sb-link.on { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sb-link svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: 0.9; }
.sb-group { margin-top: 4px; }
.sb-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; background: none; color: #93a2bd; font-family: var(--font-ui); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; border-radius: 8px; text-align: left; }
.sb-head:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.sb-head svg { width: 16px; height: 16px; }
.sb-head .caret { margin-left: auto; font-size: 1.1rem; line-height: 1; transition: transform 0.15s ease; }
.sb-group.open .sb-head .caret { transform: rotate(90deg); }
.sb-group.on .sb-head { color: #fff; }
.sb-items { display: none; }
.sb-group.open .sb-items { display: block; }
.sb-items .sb-link { padding: 6px 12px 6px 38px; font-size: 0.84rem; }
.sb-foot { margin-top: auto; padding: 12px 18px 16px; font-size: 0.74rem; color: #93a2bd; border-top: 1px solid rgba(255, 255, 255, 0.08); line-height: 1.4; }
.sb-foot b { display: block; color: #e3e9f3; font-weight: 600; }

.topbar { position: sticky; top: 0; z-index: 900; height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .mobile-brand { display: none; height: 30px; width: auto; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar .user-zone { flex: 0 0 auto; }
.content { min-width: 0; }

.sb-backdrop { display: none; }
@media (max-width: 900px) {
  .shell { padding-left: 0; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 1200; height: 100vh; box-shadow: 0 0 40px rgba(0, 0, 0, 0.3); }
  body.menu-open .sidebar { transform: none; }
  .sb-backdrop { position: fixed; inset: 0; background: rgba(8, 20, 45, 0.5); z-index: 1100; }
  body.menu-open .sb-backdrop { display: block; }
  .topbar { padding: 0 1rem; }
  .topbar .mobile-menu-toggle { display: inline-flex; }
  .topbar .mobile-brand { display: block; }
  .topbar .user-meta { display: none; }
}

/* Small pieces the new pages use */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; padding: 0.75rem 0.9rem; margin: 1rem 0 0; }
.filter-bar .form-input, .filter-bar .form-select { min-height: 36px; font-size: 0.85rem; width: auto; min-width: 160px; }
.filter-bar .form-input[type="search"] { min-width: 240px; }
.form-card { padding: 1.5rem 1.75rem; margin-top: 1rem; }
.form-grid.cols-3, .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.form-group.checks { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.form-group.checks .check { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.form-group.checks input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.row-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.row-link:hover { color: var(--brand); text-decoration: underline; }
.muted-row td { color: var(--ink-3); }
.muted { color: var(--ink-3); }
.badge.neutral { background: var(--line-soft); color: var(--ink-2); }
.badge.info { background: #eaf1ff; color: #1849a9; }
.badge.accent { background: var(--accent-tint); color: var(--accent-strong); }
.code-sample { background: var(--line-soft); border-radius: var(--radius-sm); padding: 0.75rem 1rem; font-family: var(--font-mono); font-size: 0.78rem; overflow-x: auto; white-space: pre; margin: 0.5rem 0 0; }
th.num, td.num { text-align: right; }
@media (max-width: 900px) { .form-grid.cols-3 { grid-template-columns: 1fr 1fr; } .form-grid .span-2, .form-grid .span-3 { grid-column: 1 / -1; } }

/* ---------- Customers (CRM) ---------- */
.tiles-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
a.tile:hover { box-shadow: var(--shadow-lift); }
.tile .k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); font-weight: 700; }
.tile .v { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-top: 4px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 0.78rem; color: var(--ink-2); margin-top: 4px; }
.tile.warn .v { color: var(--warn); }
.tile.bad .v { color: var(--bad); }
.tile.accent .v { color: var(--accent-strong); }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: 1rem; }
.two-col.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .two-col, .two-col.even { grid-template-columns: 1fr; } }
.panel { padding: 1rem 1.25rem; }
.panel h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.panel .panel-head { margin-bottom: 0.6rem; }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-top: 1rem; }
.kcol { background: var(--line-soft); border-radius: 12px; padding: 10px; min-height: 320px; }
.kcol.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kcol-head { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 8px; }
.kcol-head b { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-2); }
.kcol-head span { font-size: 0.78rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.kcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; text-decoration: none; color: inherit; }
.kcard:hover { box-shadow: var(--shadow-lift); }
.kcard.dragging { opacity: 0.5; }
.kcard .t { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.kcard .c { font-size: 0.78rem; color: var(--ink-2); margin-top: 2px; }
.kcard .f { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.76rem; color: var(--ink-3); }
.kcard .f b { color: var(--ink); font-variant-numeric: tabular-nums; }
.kcard .f .stale { color: var(--warn); font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 32px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.tl-ico { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-tint); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 0.62rem; font-weight: 700; letter-spacing: 0.02em; }
.tl-item.system .tl-ico { background: var(--line-soft); color: var(--ink-3); }
.tl-item.whatsapp .tl-ico { background: #e7f8ee; color: #0b7a3e; }
.tl-item.call .tl-ico { background: #eaf1ff; color: #1849a9; }
.tl-item.meeting .tl-ico { background: var(--accent-tint); color: var(--accent-strong); }
.tl-body .s { font-weight: 600; font-size: 0.9rem; }
.tl-body .b { font-size: 0.85rem; color: var(--ink-2); white-space: pre-wrap; margin-top: 2px; }
.tl-meta { font-size: 0.74rem; color: var(--ink-3); margin-top: 3px; }
.tl-meta a { color: var(--ink-3); }
.stage-steps { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.stage-steps form { margin: 0; }
.stage-steps .btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.task-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.task-row:last-child { border-bottom: 0; }
.task-row .task-check { width: 18px; height: 18px; accent-color: var(--brand); margin-top: 3px; cursor: pointer; }
.task-row .tt { font-weight: 500; }
.task-row.done .tt { text-decoration: line-through; color: var(--ink-3); }
.task-row .meta { font-size: 0.76rem; color: var(--ink-3); }
.task-row.overdue .due { color: var(--bad); font-weight: 600; }
.task-row form { margin: 0; }
.task-row .grow { flex: 1; min-width: 0; }
.task-tick { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.62rem; color: var(--ink-3); cursor: pointer; }
.task-tick .task-check { margin-top: 0; }
.task-add .form-group label { display: block; font-size: 0.7rem; color: var(--ink-3); margin-bottom: 2px; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: end; }
.inline-form .form-group { margin: 0; }
.inline-form .full { grid-column: 1 / -1; }
.inline-form .form-input, .inline-form .form-select { min-height: 38px; font-size: 0.86rem; min-width: 0; width: 100%; box-sizing: border-box; }
.inline-form label { font-size: 0.7rem; }
.chip-link { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-strong); text-decoration: none; font-size: 0.8rem; font-weight: 600; }
.chip-link.wa { background: #e7f8ee; color: #0b7a3e; }
.chip-link:hover { filter: brightness(0.96); }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 0.86rem; }
.kv-row:last-child { border-bottom: 0; }
.kv-row b { font-variant-numeric: tabular-nums; }
.stage-row { padding: 6px 0; }
.stage-row .l { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 4px; }
.badge.stage-lead { background: #e5e7eb; color: #374151; }
.badge.stage-qualified { background: #e5edff; color: #1e40af; }
.badge.stage-quoted { background: #fef3c7; color: #92400e; }
.badge.stage-negotiation { background: #ede9fe; color: #5b21b6; }
.badge.stage-won { background: #d1fae5; color: #065f46; }
.badge.stage-lost { background: #fee2e2; color: #991b1b; }
.head-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-2); margin-top: 4px; }
.head-meta a { color: var(--brand); text-decoration: none; font-weight: 600; }
.subtle-list a { text-decoration: none; color: var(--ink); font-weight: 600; }
.subtle-list a:hover { color: var(--brand); }

/* Navigation progress: a thin bar at the top while the next page loads. */
#page-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent, #f0408a); z-index: 3000; opacity: 0; transition: width 0.35s ease, opacity 0.2s ease; pointer-events: none; }
#page-progress.on { opacity: 1; }

.chip-tender { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: #fff; vertical-align: middle; margin-left: 4px; }
.kcard.locked { cursor: default; border-left: 3px solid var(--accent); }

/* Hint mark: the explanation of a page or field, shown on hover or focus instead of a sentence on the screen. */
.hint-mark { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line); color: var(--ink-3); font-size: 0.66rem; font-weight: 700; font-family: var(--font-ui); line-height: 1; vertical-align: middle; margin-left: 2px; cursor: help; position: relative; background: var(--surface); }
h2 .hint-mark, h3 .hint-mark { margin-left: 6px; position: relative; top: -2px; }
.hint-mark:hover, .hint-mark:focus { color: var(--brand); border-color: var(--brand); outline: none; }
.hint-mark::after { content: attr(data-hint); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 320px; padding: 8px 11px; border-radius: 8px; background: var(--navy); color: #fff; font-size: 0.78rem; font-weight: 500; line-height: 1.4; text-align: left; white-space: normal; text-transform: none; letter-spacing: 0; box-shadow: var(--shadow-lift); opacity: 0; pointer-events: none; transition: opacity 0.12s ease; z-index: 1500; }
.hint-mark:hover::after, .hint-mark:focus::after { opacity: 1; }
.page-head .hint-mark::after, .panel-head .hint-mark::after { left: 0; transform: none; }

/* Notifications bell */
.bell-zone { position: relative; }
.bell-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.bell-btn:hover { color: var(--brand); border-color: var(--brand); }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.68rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.bell-menu { width: 400px; max-width: 92vw; right: 0; left: auto; padding: 0; box-sizing: border-box; overflow: hidden; }
.bell-menu .bell-item { display: block; padding: 10px 14px; border-top: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.bell-menu .bell-item .t { display: block; font-size: 0.84rem; line-height: 1.35; white-space: normal; }
.bell-item .m { display: block; font-size: 0.7rem; color: var(--ink-3); margin-top: 2px; }
.bell-item.unread { background: #f4f7fd; }
.bell-item.unread .t { font-weight: 600; }
.bell-item:hover { background: var(--line-soft); }
.bell-empty { padding: 14px; font-size: 0.82rem; color: var(--ink-3); }
.bell-menu .bell-all { display: block; padding: 9px 14px; white-space: normal; font-size: 0.78rem; font-weight: 600; color: var(--brand-strong); text-decoration: none; border-top: 1px solid var(--line); text-align: center; }
.bell-clear { border: 0; background: none; color: var(--brand-strong); font-size: 0.74rem; font-weight: 600; cursor: pointer; font-family: var(--font-ui); }
.notif-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 4px; border-bottom: 1px solid var(--line-soft); text-decoration: none; color: inherit; }
.notif-row:last-child { border-bottom: 0; }
.notif-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-top: 7px; flex: 0 0 auto; }
.notif-row.unread .dot { background: var(--accent); }
.notif-row .t { display: block; font-size: 0.88rem; }
.notif-row.unread .t { font-weight: 600; }
.notif-row .m { display: block; font-size: 0.72rem; color: var(--ink-3); margin-top: 2px; }

/* The bell panel hangs under the bell itself, not centred like the other menus. */
.bell-zone .bell-menu { left: auto; right: 0; transform: none; margin-left: 0; }
.bell-zone .bell-menu::before { left: auto; right: 14px; transform: none; margin-left: 0; }

/* Filter rows (tender register, bid library, competitors): chips on the left, the search form on the right,
   everything on one line. The generic .inline-form grid above is for stacked add-forms, not for this. */
.tdr-filters { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tdr-filters form, .tdr-filters form.inline-form { display: flex; grid-template-columns: none; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0 0 0 auto; width: auto; }
.tdr-filters form .ts-wrapper, .tdr-filters form select.form-select { width: auto !important; min-width: 170px; max-width: 220px; grid-column: auto; }
.tdr-filters form .form-input { width: 300px; min-width: 200px; max-width: 340px; }
.tdr-filters form .ts-wrapper .ts-control, .tdr-filters form .form-input, .tdr-filters form select.form-select { min-height: 38px; height: 38px; font-size: 0.85rem; box-sizing: border-box; }
.tdr-filters form .btn { min-height: 38px; height: 38px; padding: 0 1rem; font-size: 0.82rem; white-space: nowrap; }
.tdr-filters .chip-group { gap: 0.35rem; }
@media (max-width: 760px) {
  .tdr-filters form { margin-left: 0; width: 100%; }
  .tdr-filters form .form-input { flex: 1; width: auto; max-width: none; }
}

/* The follow-up add form (deal, contact, company and tender pages) fills its cells; an old cap kept every
   control at 230px. On the tender page (.tasks-wide) it is one line: the follow-up text stretches, then Due,
   Priority, For and Add. */
.task-add { width: 100%; }
.task-add .form-group { margin: 0; min-width: 0; }
.task-add .form-input, .task-add .form-select, .task-add input, .task-add select { width: 100% !important; min-width: 0; max-width: none; min-height: 38px; box-sizing: border-box; font-size: 0.86rem; }
.task-add .ts-wrapper { width: 100% !important; min-width: 0; max-width: none; }
.task-add .ts-wrapper .ts-control { min-height: 38px; }
.task-add .btn { min-height: 38px; height: 38px; padding: 0 1.1rem; white-space: nowrap; }
.tasks-wide .task-add { grid-template-columns: minmax(0, 1fr) 160px 140px minmax(200px, 260px) auto; }
.tasks-wide .task-add .form-group.full { grid-column: auto; }
@media (max-width: 900px) {
  .tasks-wide .task-add { grid-template-columns: 1fr 1fr; }
  .tasks-wide .task-add .form-group.full { grid-column: 1 / -1; }
}

/* Dialogs: a small modal for a decision that needs a word or a password (bid proposal signing). */
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(440px, 92vw); max-height: 90vh; overflow: hidden auto; background: var(--surface, #fff); color: var(--ink); box-shadow: 0 24px 60px -20px rgba(10, 20, 40, 0.45); }
.dlg::backdrop { background: rgba(10, 20, 40, 0.45); }
.dlg form { margin: 0; }
.dlg-h { display: flex; align-items: flex-start; gap: 0.75rem; padding: 1.1rem 1.25rem 0.95rem; border-bottom: 1px solid var(--line-soft); }
.dlg-h .t { flex: 1; min-width: 0; }
.dlg-h h3 { margin: 0; font-size: 1.05rem; font-weight: 700; line-height: 1.3; }
.dlg-h .sub { margin-top: 0.2rem; font-size: 0.8rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlg-x { flex: none; width: 32px; height: 32px; margin: -0.3rem -0.4rem 0 0; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dlg-x:hover, .dlg-x:focus-visible { background: var(--line-soft); color: var(--ink); outline: none; }
.dlg-b { padding: 1rem 1.25rem 1.1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.dlg-b .f { margin-bottom: 0; }
.dlg-b textarea { min-height: 70px; resize: vertical; }
.dlg-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.dlg-chips .score { font-weight: 800; font-size: 0.95rem; font-variant-numeric: tabular-nums; margin-right: 0.15rem; }
.dlg-sig { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 54px; padding: 0.45rem 0.8rem; border: 1px dashed var(--line); border-radius: 10px; }
.dlg-sig .k { font-size: 0.775rem; font-weight: 600; color: var(--ink-2); }
.dlg-sig img { max-height: 40px; max-width: 170px; display: block; }
.dlg-sig .none { font-size: 0.8rem; color: var(--ink-3); text-align: right; }
.dlg-f { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.85rem 1.25rem; background: var(--canvas, #f8fafc); border-top: 1px solid var(--line-soft); }
