/* esc Aerospace ERP — base stylesheet (no framework) */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2733;
  --muted: #6b7a8c;
  --line: #dde4ec;
  --accent: #0b6cff;
  --accent-dark: #0953c4;
  --sidebar: #14202e;
  --sidebar-ink: #c3cfdc;
  --ok: #1c8a4c;
  --warn: #b07a12;
  --error: #c0392b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
h1, h2, h3, h4 { margin: 0.4em 0; }
h2 { font-size: 20px; }
h3 { font-size: 16px; margin-top: 1.4em; }
code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--error); }
.pos { color: var(--ok); }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex: none; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; padding: 14px 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 16px 16px; }
.brand-logo { height: 42px; width: auto; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; }
.brand-sub { font-size: 11px; color: rgba(255, 255, 255, 0.45); }
.sidebar nav { display: flex; flex-direction: column; flex: 1; overflow-y: auto; overflow-x: hidden; }
.sidebar nav a {
  display: block;
  color: var(--sidebar-ink); text-decoration: none; padding: 8px 20px 8px 26px;
  border-left: 3px solid transparent; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active { background: rgba(11, 108, 255, 0.18); border-left-color: var(--accent); color: #fff; }
.nav-group {
  display: flex; flex-direction: column; margin: 4px 8px 0; padding-bottom: 3px;
  border-radius: 8px; border-left: 3px solid var(--grp, transparent);
  background: var(--grp-bg, transparent);
}
.nav-section {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 4px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--grp, rgba(255, 255, 255, 0.4));
  cursor: pointer; user-select: none;
}
.nav-section:hover { filter: brightness(1.25); }
.grp-caret { font-size: 10px; transition: transform 0.15s; }
.grp-caret.collapsed { transform: rotate(-90deg); }

/* per-group accent colours (mirrors the CRM) */
.grp-overview    { --grp: #38bdf8; --grp-bg: rgba(56, 189, 248, 0.08); }
.grp-projects    { --grp: #34d399; --grp-bg: rgba(52, 211, 153, 0.08); }
.grp-sales       { --grp: #a5b4fc; --grp-bg: rgba(129, 140, 248, 0.10); }
.grp-procurement { --grp: #fbbf24; --grp-bg: rgba(251, 191, 36, 0.08); }
.grp-masterdata  { --grp: #22d3ee; --grp-bg: rgba(34, 211, 238, 0.08); }
.grp-reports     { --grp: #f472b6; --grp-bg: rgba(244, 114, 182, 0.08); }
.grp-admin       { --grp: #fb7185; --grp-bg: rgba(251, 113, 133, 0.08); }

/* footer (bottom left, mirrors the CRM): user + actions + language switch */
.sidebar-footer {
  padding: 10px 14px 4px; border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer-user { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.footer-user-text { min-width: 0; flex: 1; }
.footer-name {
  color: #fff; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.footer-role { font-size: 10px; color: rgba(255, 255, 255, 0.4); }
.footer-icon {
  background: none; border: none; padding: 4px; cursor: pointer;
  color: rgba(255, 255, 255, 0.5); display: inline-flex; text-decoration: none;
}
.footer-icon:hover, .footer-icon.active { color: #fff; }
.footer-lang {
  display: flex; align-items: center; gap: 8px; font-size: 11px;
  margin-top: 8px; padding: 8px 0 6px; border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.footer-lang a {
  color: rgba(255, 255, 255, 0.5); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px; opacity: 0.6;
}
.footer-lang a.current { color: #fff; font-weight: 600; opacity: 1; }
.footer-lang .sep { color: rgba(255, 255, 255, 0.3); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { padding: 18px 26px 60px; max-width: 1280px; }

/* mobile top bar + off-canvas nav (shown only below the breakpoint) */
.topbar { display: none; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--sidebar); color: #fff; position: sticky; top: 0; z-index: 30; }
.hamburger { display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: #fff; cursor: pointer; padding: 4px; }
.topbar-logo { height: 28px; width: auto; }
.topbar-title { font-size: 15px; font-weight: 700; }
.nav-backdrop { display: none; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); }
.login-card { background: var(--panel); border-radius: 10px; padding: 34px 38px; width: 400px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35); }
.login-card h1 { font-size: 20px; margin-bottom: 18px; }
.login-card label { display: block; margin: 12px 0 4px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 18px; width: 100%; }
.qr-box { text-align: center; margin: 10px 0; }
.qr-box img { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.backup-codes { columns: 2; list-style: none; padding: 0; }
.backup-codes li { margin: 4px 0; }

/* controls */
input, select, button { font: inherit; }
input, select {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid rgba(11, 108, 255, 0.35); border-color: var(--accent); }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 6px; padding: 7px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 3px 9px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.file-btn { display: inline-block; }

/* structure */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-box { min-width: 240px; }
.list-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 6px; }
.load-more { text-align: center; margin: 12px 0; }
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 16px; min-width: 170px; flex: 1;
}
.card-label { color: var(--muted); font-size: 12px; }
.card-value { font-size: 19px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-link { text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
.card-link:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }
.card.attn-warn { border-left: 3px solid var(--warn); }
.card.attn-ok { border-left: 3px solid var(--ok); }

/* dashboard quick links + revenue-realization mini bars */
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.quick-link {
  display: inline-block; padding: 8px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; text-decoration: none;
  color: var(--ink); font-size: 13.5px;
}
.quick-link:hover { border-color: var(--accent); color: var(--accent); }
.rr-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.rr-name { width: 210px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rr-bar { flex: 1; height: 14px; background: #eef2f7; border-radius: 7px; overflow: hidden; }
.rr-fill { height: 100%; background: var(--ok); border-radius: 7px; }
.rr-val { width: 210px; flex: none; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .rr-name, .rr-val { width: 110px; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin: 14px 0; }
.tabs { display: flex; gap: 4px; margin: 16px 0 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.tabs button {
  border: none; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.form-col { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.form-col label, .form-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.inline-check { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); margin-left: auto; }
.checkbox-list { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 12px; }
.checkbox-list .inline-check { margin-left: 0; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.table.narrow { width: auto; min-width: 380px; }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #eef2f7; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.table th.th-sort { cursor: pointer; user-select: none; }
.table th.th-sort:hover { background: #e2e9f2; color: var(--ink); }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f2f7ff; }
.table tr.inactive td { color: var(--muted); }
.table tr.storno td { color: var(--muted); font-style: italic; }
.table tr.reversed td { text-decoration: line-through solid rgba(107, 122, 140, 0.5); }
.detail-cell { background: #f8fafc; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

/* badges & alerts */
.badge {
  display: inline-block; background: #e5ebf2; color: var(--muted); border-radius: 20px;
  font-size: 11px; padding: 2px 9px; margin-left: 6px; white-space: nowrap;
}
.badge.ok { background: #d9f2e3; color: var(--ok); }
.badge.warn { background: #f7ead0; color: var(--warn); }
.badge.ghost { background: transparent; border: 1px solid var(--line); }
.alert { border-radius: 6px; padding: 9px 13px; margin: 10px 0; }
.alert.error { background: #fbe4e1; color: var(--error); }
.alert.ok { background: #d9f2e3; color: var(--ok); }
.alert.warn { background: #f7ead0; color: var(--warn); }
.alert.info { background: #dfeaff; color: var(--accent-dark); }

/* timesheet calendar */
.ts-summary { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.ts-summary .ts-actions { margin-left: auto; display: flex; gap: 6px; }
.ts-cal { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--panel); border: 1px solid var(--line); }
.ts-cal th { background: #eef2f7; color: var(--muted); font-size: 12px; padding: 6px; border: 1px solid var(--line); }
.ts-cal td { border: 1px solid var(--line); height: 74px; vertical-align: top; padding: 4px 6px; cursor: pointer; }
.ts-cal td.ts-empty { background: #fafbfc; cursor: default; }
.ts-cal td.ts-weekend { background: #f4f6f9; }
.ts-cal td.ts-holiday { background: #eaf1ff; }
.ts-cal td.ts-absence { background: #fff5e6; }
.ts-cal td.ts-under { box-shadow: inset 3px 0 0 var(--warn); }
.ts-cal td.ts-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.ts-daynum { font-weight: 600; font-size: 12px; color: var(--muted); }
.ts-tag { font-size: 10px; color: var(--accent-dark); margin-top: 4px; line-height: 1.2; }
.ts-hours { font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 8px; }
.target-day { display: inline-flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }

/* modal overlay (e.g. glossary) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 32, 46, 0.55);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 6vh 16px;
}
.modal-card {
  background: var(--panel); border-radius: 10px; padding: 20px 24px;
  width: 640px; max-width: 100%; max-height: 84vh; overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.glossary { margin-top: 12px; }
.glossary dt { font-weight: 700; margin-top: 12px; }
.glossary dd { margin: 2px 0 0; color: var(--ink); }

/* nav badge (e.g. hygiene finding count) */
.nav-badge {
  display: inline-block; min-width: 18px; text-align: center; background: var(--warn);
  color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 6px;
}

/* hygiene / checks page */
.hyg-check { padding: 12px 16px; }
.hyg-head { display: flex; align-items: center; gap: 8px; }
.hyg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.hyg-dot.sev-danger { background: var(--error); }
.hyg-dot.sev-warn { background: var(--warn); }
.hyg-dot.sev-info { background: var(--muted); }
.hyg-items { margin: 6px 0 0; padding-left: 18px; }
.hyg-items li { margin: 2px 0; }

/* responsive: tablet + phone
   Below the breakpoint the sidebar becomes an off-canvas drawer toggled by the
   top-bar hamburger, and wide data tables scroll horizontally instead of
   breaking the page layout. */
@media (max-width: 900px) {
  .topbar { display: flex; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(20, 32, 46, 0.5); z-index: 40;
  }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    transform: translateX(-100%); transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 14px 14px 48px; }
  .content table.table {
    display: block; max-width: 100%; overflow-x: auto;
    -webkit-overflow-scrolling: touch; white-space: nowrap;
  }
  .page-head .search-box { min-width: 0; width: 100%; }
}
