/* ============================================================
   AUDIT CRM — LogisticFit Style
   ============================================================ */

@font-face {
  font-family: 'Nunito';
  src: url('fonts/Nunito-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}
@font-face {
  font-family: 'Nunito';
  src: url('fonts/Nunito-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
}

:root {
  --bg:           #f0f2f7;
  --bg2:          #ffffff;
  --bg3:          #e8ebf4;
  --border:       #cdd3e8;
  --accent:       #3a4d98;
  --accent2:      #2d3d7a;
  --accent-light: #4f65c0;
  --green:        #239d46;
  --green2:       #1a7a34;
  --text:         #1a2540;
  --text2:        #6b7a9f;
  --orange:       #d4820a;
  --red:          #c0392b;
  --yellow:       #d4a017;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(58,77,152,0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

.hidden { display: none !important; }
.page { min-height: 100vh; }

/* ============================================================
   LOGIN
   ============================================================ */
#page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8ebf4 0%, #f0f2f7 60%, #ffffff 100%);
}

.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 140px;
  margin: 0 auto 24px;
}
.login-logo img {
  width: 100%;
  height: auto;
}

.login-box h1 { font-size: 22px; margin-bottom: 6px; font-weight: 700; }
.login-box p  { color: var(--text2); margin-bottom: 28px; font-size: 13px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
  font-family: 'Nunito', sans-serif;
}
.btn-primary:hover { background: var(--accent-light); }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-light); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 58px;
  background: var(--bg2);
  border-bottom: 2px solid var(--accent);
  position: sticky; top: 0; z-index: 100;
}

.nav-left { display: flex; align-items: center; gap: 14px; }
.nav-logo {
  height: 36px;
  display: flex;
  align-items: center;
}
.nav-logo img { height: 36px; width: auto; }
.nav-divider { width: 1px; height: 24px; background: var(--border); }
.nav-title { font-weight: 700; font-size: 13px; color: var(--text2); letter-spacing: 0.3px; }

.nav-links { display: flex; gap: 4px; }
.nav-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent); color: white; }

.nav-right { display: flex; align-items: center; gap: 12px; }
#nav-user { font-size: 13px; color: var(--text2); }

/* ============================================================
   VIEWS
   ============================================================ */
.view { padding: 20px 24px; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.search-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border 0.2s;
  font-family: 'Nunito', sans-serif;
}
.search-input:focus { border-color: var(--accent-light); }

.filter-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border 0.2s;
  font-family: 'Nunito', sans-serif;
}
.filter-select:focus { border-color: var(--accent-light); }

/* ============================================================
   STATS
   ============================================================ */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  min-width: 120px;
  text-align: center;
}
.stat-card.planned { border-color: var(--accent-light); }
.stat-card.done    { border-color: var(--green); }
.stat-card.proforma{ border-color: var(--orange); }

.stat-num   { display: block; font-size: 26px; font-weight: 800; }
.stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }

.stat-card.planned .stat-num { color: var(--accent-light); }
.stat-card.done    .stat-num { color: var(--green); }
.stat-card.proforma .stat-num { color: var(--orange); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--bg3);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody tr.row-manual { background: #f5f0ff; }
tbody tr.row-manual:hover { background: #ede5ff; }
td.prj-col { color: var(--text2); font-size: 12px; white-space: nowrap; width: 60px; }

tbody td {
  padding: 10px 14px;
  font-size: 13px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading { text-align: center; color: var(--text2); padding: 40px !important; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-fsc      { background: #dce6fb; color: #2d4da0; }
.badge-pefc     { background: #d4f0dc; color: #1a7a34; }
.badge-kzr      { background: #fdefd4; color: #a05c00; }
.badge-sure     { background: #ede0fb; color: #6b3ab0; }
.badge-eudr     { background: #fde0e0; color: #b02020; }

.badge-planned  { background: #dce6fb; color: #2d4da0; }
.badge-done     { background: #d4f0dc; color: #1a7a34; }
.badge-rejected { background: #fde0e0; color: #b02020; }
.badge-change   { background: #fdefd4; color: #a05c00; }
.badge-invoice  { background: #d4f0e4; color: #1a6640; }

.badge-proforma-brak     { background: #ebebeb; color: #777; }
.badge-proforma-wysłana  { background: #fdefd4; color: #a05c00; }
.badge-proforma-zapłacona{ background: #d4f0dc; color: #1a7a34; }

.mode-online  { color: var(--accent); }
.mode-onsite  { color: var(--text2); }

/* ============================================================
   AUDITORS VIEW
   ============================================================ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.view-header h2 { font-size: 16px; font-weight: 700; }
.header-filters { display: flex; gap: 10px; }

.my-row { background: rgba(35,157,70,0.08) !important; }
.my-row td:first-child { font-weight: 700; color: var(--green); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg2);
  z-index: 1;
}
.modal-header h2 { font-size: 16px; max-width: 680px; font-weight: 700; }

.modal-body { padding: 20px 24px 24px; }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 600px) { .modal-grid { grid-template-columns: 1fr; } }

.modal-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-light);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.modal-section.full { margin-bottom: 20px; }

.field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  align-items: flex-start;
}
.field-row label {
  color: var(--text2);
  min-width: 100px;
  font-size: 12px;
  padding-top: 1px;
  font-weight: 600;
}
.field-row span { color: var(--text); word-break: break-word; }

.notes-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg3);
  border-radius: 8px;
  padding: 12px;
  min-height: 40px;
}

.modal-actions {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.action-group { display: flex; flex-direction: column; gap: 8px; }
.action-group label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

.status-btn, .proforma-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
}
.status-btn:hover, .proforma-btn:hover { border-color: var(--accent-light); color: var(--text); }
.status-btn.active  { background: var(--accent); border-color: var(--accent); color: white; }
.proforma-btn.active{ background: var(--green);  border-color: var(--green);  color: white; }

#btn-save { margin-left: auto; }

/* ============================================================
   ACTION BUTTONS (navbar)
   ============================================================ */
.btn-action {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: 'Nunito', sans-serif;
  white-space: nowrap;
}
.btn-action:hover { background: var(--accent-light); }
.btn-action-green { background: var(--green); }
.btn-action-green:hover { background: var(--green2); }

/* ============================================================
   IMPORT MODAL
   ============================================================ */
.modal-import { max-width: 700px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg3);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(58,77,152,0.05);
}
.drop-icon { font-size: 48px; margin-bottom: 12px; }
.drop-zone p { color: var(--text2); font-size: 14px; line-height: 1.6; margin-bottom: 0; }

.import-info { margin-bottom: 12px; font-size: 14px; }
.import-info strong { color: var(--accent); }

.import-auditors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.auditor-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text2);
}
.auditor-chip.my-chip {
  background: rgba(35,157,70,0.1);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.import-progress {
  padding: 40px 24px;
  text-align: center;
}
.progress-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}
#import-progress-text { color: var(--text2); font-size: 13px; }

.import-result-box { padding: 20px 0; }
.result-item {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.result-item.success { background: rgba(35,157,70,0.1); color: var(--green); }
.result-item.skip    { background: var(--bg3); color: var(--text2); }
.result-item.error   { background: rgba(192,57,43,0.1); color: var(--red); }
.result-item.warn    { background: rgba(230,160,0,0.12); color: #9a6700; }
.import-warning {
  background: rgba(230,160,0,0.12);
  border: 1.5px solid rgba(230,160,0,0.4);
  color: #9a6700;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 10px;
}

/* ============================================================
   FORMULARZ (dodaj audyt)
   ============================================================ */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-row label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Nunito', sans-serif;
  outline: none;
  transition: border 0.2s;
  width: 100%;
}
.form-input:focus { border-color: var(--accent-light); }
.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* ============================================================
   AUTOCOMPLETE
   ============================================================ */
.autocomplete-wrap {
  position: relative;
  width: 100%;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1.5px solid var(--accent-light);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(58,77,152,.15);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 240px;
  overflow-y: auto;
  z-index: 1000;
}

.autocomplete-list li {
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--bg3);
  color: var(--accent);
}

.autocomplete-list li strong {
  color: var(--accent);
  font-weight: 700;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 300;
  transition: opacity 0.3s;
}
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }
