/* ==========================================
   OPLEX - MODUŁ KOSZTY
   Dark theme contract v1.0 | max-width: 1600px
   ========================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #181818;
  --card-bg:       #1e1e1e;
  --border:        rgba(255,255,255,0.06);
  --border-hover:  rgba(255,255,255,0.10);
  --text-primary:  #e5e7eb;
  --text-secondary:#9ca3af;
  --text-muted:    #6b7280;
  --radius:        14px;
}

/*
 * `../css/no-scrollbar.css` (loaded earlier) sets `html, body { overflow: hidden }`
 * for modules that own their own scroll container. Costs does not have an
 * inner scroll container — content lives directly on the body — so we
 * reinstate vertical scrolling here. The custom scrollbar is still hidden
 * via the shared rules in no-scrollbar.css.
 */
html, body {
  overflow: hidden auto;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: rgba(255,255,255,0.08); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* === TOP BAR === */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: rgba(24,24,24,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
}

.topbar-left  { flex: 1; }
.topbar-right { display: flex; justify-content: flex-end; }

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-title .ui-icon { width: 17px; height: 17px; stroke: #9ca3af; }
.topbar-text  { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); }

.topbar-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: color 150ms, border-color 150ms, background 150ms;
}
.topbar-action:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}

.topbar-icon {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.ui-icon {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

/* === PAGE WRAPPER === */
#costsView {
  max-width: 1600px;
  margin: 0 auto;
  padding: 84px 28px 48px;
}

/* === PAGE HEADER === */
.costs-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.dashboard-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.dashboard-period {
  margin-top: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* === NAV BUTTONS === */
.costs-nav-buttons { display: flex; align-items: center; gap: 8px; }

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms;
  white-space: nowrap;
}
.btn-nav:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.btn-nav .ui-icon { width: 14px; height: 14px; }

.btn-nav-current {
  background: rgba(59,130,246,0.12);
  border-color: rgba(59,130,246,0.35);
  color: #60a5fa;
}
.btn-nav-current:hover { background: rgba(59,130,246,0.2); }

/* === TOP ROW (warning + summary) === */
.costs-top-row {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

/* === CARD BASE === */
.cost-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 22px;
  transition: border-color 180ms, box-shadow 180ms;
}

/* === WARNING CARD === */
.cost-card--warning {
  border-color: rgba(245,158,11,0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 32px;
}

.warning-hero-icon {
  width: 36px; height: 36px;
  stroke: #fbbf24;
  opacity: 0.7;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cost-card--warning h3 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #fbbf24;
}

.hero-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 500px;
}

/* === SUMMARY CARD === */
.cost-card--summary {
  display: flex;
  align-items: center;
  gap: 18px;
}

.costs-source-icon {
  width: 44px; height: 44px;
  background: rgba(16,185,129,0.12);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #34d399;
}
.costs-source-icon .ui-icon { width: 18px; height: 18px; }

.costs-source-content { flex: 1; }

.costs-source-content > label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 14px;
}

.costs-total-display {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
}

.costs-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.costs-total-row:last-child { border-bottom: none; }

.costs-total-label { font-size: 0.8rem; color: var(--text-muted); }
.costs-total-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.costs-source-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.costs-source-hint .ui-icon { width: 12px; height: 12px; }

/* === INTEGRATION TOOLBAR === */
.cost-integrations-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, color 150ms;
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.07);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary .ui-icon { width: 14px; height: 14px; }

.cost-integrations-status { font-size: 0.8rem; color: var(--text-muted); }

/* === CATEGORIES GRID === */
.costs-categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

/* === CATEGORY CARD === */
.cost-cat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 180ms, box-shadow 180ms;
  display: flex;
  flex-direction: column;
}
.cost-cat-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.cost-cat-card label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 12px;
}
.cost-cat-card label .ui-icon { width: 15px; height: 15px; color: var(--text-muted); }

.cost-value-display {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.cost-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.cost-hint .ui-icon { width: 12px; height: 12px; margin-top: 1px; flex-shrink: 0; color: #fbbf24; }

.cost-details-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 150ms;
}
.cost-details-btn .ui-icon { width: 13px; height: 13px; }
.cost-cat-card:hover .cost-details-btn { color: #60a5fa; }

/* === NOTES SECTION === */
.costs-notes-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 20px;
  margin-bottom: 14px;
}

.costs-notes-section > label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  cursor: default;
}
.costs-notes-section > label .ui-icon { width: 15px; height: 15px; color: var(--text-muted); }

.costs-notes-section textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  transition: border-color 150ms, background 150ms;
  line-height: 1.6;
}
.costs-notes-section textarea:focus {
  border-color: rgba(59,130,246,0.5);
  background: rgba(59,130,246,0.04);
}
.costs-notes-section textarea::placeholder { color: var(--text-muted); }

/* === SAVE SECTION === */
.costs-save-section { display: flex; justify-content: flex-end; }

.btn-premium-success {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: rgba(16,185,129,0.1);
  color: #34d399;
  border: 1.5px solid rgba(16,185,129,0.35);
  border-radius: 0;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 180ms, box-shadow 180ms, transform 150ms;
}
.btn-premium-success:hover:not(:disabled) {
  background: rgba(16,185,129,0.18);
  box-shadow: 0 2px 10px rgba(16,185,129,0.2);
}
.btn-premium-success:active { transform: translateY(1px); }
.btn-premium-success:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-premium-success .ui-icon { width: 15px; height: 15px; }

/* === MODAL — SUBCATEGORY STYLES === */
.subcategories-modal-content { padding: 4px 0; }

.subcategories-list { display: flex; flex-direction: column; gap: 8px; }

.subcategory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 0;
  gap: 12px;
}
.subcategory-item-title  { flex: 1; font-size: 0.875rem; color: var(--text-primary); }
.subcategory-item-amount { font-weight: 700; color: #60a5fa; font-variant-numeric: tabular-nums; }

.subcategory-item-actions button {
  background: rgba(239,68,68,0.1);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 0;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 150ms;
}
.subcategory-item-actions button:hover { background: rgba(239,68,68,0.2); }

.subcategory-empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.subcategory-total {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-align: right;
}
.subcategory-total strong { color: #60a5fa; font-variant-numeric: tabular-nums; }

.add-subcategory-btn {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 16px;
  background: rgba(59,130,246,0.1);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 0;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms;
}
.add-subcategory-btn:hover { background: rgba(59,130,246,0.18); }

.subcategory-form { display: flex; flex-direction: column; gap: 14px; }
.subcategory-form-group { display: flex; flex-direction: column; gap: 6px; }
.subcategory-form-group label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.subcategory-form-group input {
  padding: 9px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 0;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms, background 150ms;
}
.subcategory-form-group input:focus {
  border-color: rgba(59,130,246,0.5);
  background: rgba(59,130,246,0.04);
}

/* Netto/Brutto radio group inside the "Dodaj pozycje kosztu" modal.
   2026-05-13 — operator can now declare whether the entered amount
   is the net or gross value; VAT-zero categories (ZUS / wypłaty)
   lock this to "netto" and replace the radio with an info hint. */
.subcategory-amount-type {
  display: flex;
  gap: 8px;
}

.subcategory-amount-type__option {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 150ms, border-color 150ms, color 150ms;
}

.subcategory-amount-type__option:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.subcategory-amount-type__option input[type="radio"] {
  margin: 0;
  accent-color: #3b82f6;
}

.subcategory-amount-type__option:has(input:checked) {
  background: rgba(59,130,246,0.14);
  border-color: rgba(59,130,246,0.45);
  color: #93c5fd;
}

.subcategory-form-subhint {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.subcategory-form-hint {
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  border-radius: 6px;
  color: var(--text-secondary);
}

.subcategory-form-hint--info {
  background: rgba(59,130,246,0.08);
  border: 1px solid rgba(59,130,246,0.25);
  color: #93c5fd;
}

.subcategory-form-hint strong {
  color: #bfdbfe;
}

/* Small pill next to the amount on the list ("Dodaj koszt") — tells
   the operator how the value was entered. */
.subcategory-item-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 999px;
  vertical-align: middle;
  font-variant-numeric: normal;
}

.subcategory-item-badge--brutto {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.28);
}

.subcategory-item-badge--netto {
  background: rgba(16, 185, 129, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.32);
}

.text-muted { color: var(--text-muted); font-size: 0.8rem; }

/* === MODAL — PAYROLL DETAILS === */
.payroll-settlement-item {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px;
  margin-bottom: 10px;
}
.payroll-settlement-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.payroll-settlement-label { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.payroll-settlement-value { font-size: 0.875rem; color: var(--text-primary); font-weight: 600; }
.payroll-settlement-amount { font-size: 1.1rem; font-weight: 700; color: #34d399; font-variant-numeric: tabular-nums; }
.payroll-details-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 6px; }
.payroll-details-employees {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.payroll-details-employees-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.payroll-details-employee {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  padding: 3px 0;
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
  .costs-top-row { grid-template-columns: 1fr 360px; }
}

@media (max-width: 900px) {
  #costsView { padding: 80px 16px 32px; }
  .costs-top-row { grid-template-columns: 1fr; }
  .cost-card--summary { flex-direction: column; }
}

@media (max-width: 600px) {
  .costs-nav-buttons { flex-wrap: wrap; }
  .costs-categories-grid { grid-template-columns: 1fr; }
}
