/* =========================================================
   MERITUM COB — Portal Klienta "BRAKI"
   Paleta: #144848 | #c49b74 | #f4f1ec | #1b5c5c
   Typografia: Montserrat (nagłówki) + Lato (tekst)
========================================================= */

:root {
  --green:       #144848;
  --green-light: #1b5c5c;
  --gold:        #c49b74;
  --gold-dark:   #b28860;
  --cream:       #f4f1ec;
  --gray:        #e6e6e6;
  --text-dark:   #2b2b2b;
  --text-light:  #ffffff;
  --sidebar-w:   260px;
  --radius:      10px;
  --shadow:      0 2px 16px rgba(20,72,72,.10);
  --shadow-md:   0 4px 24px rgba(20,72,72,.14);
}

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

html { font-size: 15px; }

body {
  font-family: 'Lato', sans-serif;
  background: #eceae5;
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  background: var(--green);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  overflow: hidden;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(196,155,116,.25);
}
.logo-img { width: 140px; filter: brightness(0) invert(1); display: block; }
.logo-sub {
  font-family: 'Montserrat', sans-serif;
  font-size: .68rem;
  color: var(--gold);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 6px;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section {
  font-family: 'Montserrat', sans-serif;
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(196,155,116,.6);
  padding: 14px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .88rem;
  transition: background .18s, color .18s;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
  border-left-color: var(--gold);
}
.nav-item.active {
  background: rgba(196,155,116,.15);
  color: #fff;
  border-left-color: var(--gold);
  font-weight: 600;
}
.nav-item-sm { padding: 7px 20px; font-size: .82rem; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.nav-backup { margin-top: 8px; }

/* sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(196,155,116,.2);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green);
  flex-shrink: 0;
}
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  text-decoration: none;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background .18s;
}
.user-pill:hover { background: rgba(255,255,255,.08); }
.user-avatar {
  width: 34px; height: 34px;
  background: var(--gold);
  color: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; gap: 1px; }
.user-name { color: #fff; font-size: .83rem; font-weight: 600; }
.user-role {
  font-size: .65rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
}
.role-admin    { background: rgba(196,155,116,.35); color: var(--gold); }
.role-pracownik { background: rgba(255,255,255,.15); color: rgba(255,255,255,.8); }
.role-klient   { background: rgba(27,92,92,.6); color: rgba(255,255,255,.8); }

.logout-btn {
  color: rgba(255,255,255,.45);
  font-size: 1.1rem;
  text-decoration: none;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color .18s, background .18s;
}
.logout-btn:hover { color: #e87; background: rgba(255,100,80,.12); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.28);
  z-index: 150;
}

/* ── TOPBAR ──────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w);
  right: 0; height: 58px;
  background: #fff;
  border-bottom: 1px solid var(--gray);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px 0 20px;
  z-index: 100;
  box-shadow: 0 1px 6px rgba(20,72,72,.06);
}
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--green);
}
.page-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--green);
  flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-role {
  font-family: 'Montserrat', sans-serif;
  font-size: .65rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 5px;
}
.topbar-role.role-admin    { background: rgba(196,155,116,.15); color: var(--gold-dark); }
.topbar-role.role-pracownik { background: rgba(20,72,72,.1); color: var(--green); }
.topbar-role.role-klient   { background: rgba(20,72,72,.08); color: var(--green-light); }

/* ── MAIN CONTENT ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: 58px;
  min-height: calc(100vh - 58px);
  padding: 28px 32px;
  width: calc(100% - var(--sidebar-w));
}

/* ── FLASH MESSAGES ──────────────────────────────── */
.flash-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: opacity .4s;
}
.flash-success { background: rgba(20,72,72,.1); color: var(--green); border-left: 4px solid var(--green); }
.flash-error   { background: rgba(200,50,50,.1); color: #c03030; border-left: 4px solid #c03030; }
.flash button  { background: none; border: none; cursor: pointer; font-size: .9rem; opacity: .5; }

/* ── CARDS ───────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--cream);
}
.card-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── STAT CARDS ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--gold);
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-number {
  font-family: 'Montserrat', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}
.stat-label { font-size: .8rem; color: #888; margin-top: 4px; }

/* ── MODULE CARDS (dashboard) ────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.module-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--gray);
  transition: border-color .2s, box-shadow .2s, transform .2s;
  display: block;
}
.module-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.module-icon { font-size: 2rem; margin-bottom: 10px; }
.module-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: var(--green);
  font-size: .95rem;
}
.module-desc { font-size: .82rem; color: #888; margin-top: 4px; }

/* ── TAX SUMMARY ─────────────────────────────────── */
.tax-summary-card {
  border-top: 3px solid var(--green);
}
.tax-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.tax-tile {
  background: var(--cream);
  border: 1px solid #ebe4da;
  border-radius: 8px;
  padding: 14px 16px;
}
.tax-label {
  font-family: 'Montserrat', sans-serif;
  font-size: .7rem;
  font-weight: 700;
  color: #777;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.tax-value {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green);
  overflow-wrap: anywhere;
}
.tax-details {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(20,72,72,.06);
  border-radius: 8px;
  color: #555;
  display: grid;
  gap: 8px;
  font-size: .88rem;
}
.tax-details span { overflow-wrap: anywhere; }
.tax-history {
  margin-top: 14px;
  border-top: 1px solid var(--gray);
  padding-top: 10px;
  display: grid;
  gap: 6px;
}
.tax-history-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: .82rem;
  color: #666;
}
.tax-history-row strong { color: var(--green); }

/* ── TABLE ───────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
thead th {
  background: var(--green);
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #f0eeea; transition: background .15s; }
tbody tr:hover { background: #faf8f4; }
tbody td { padding: 10px 14px; vertical-align: middle; }
.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── STATUS BADGES ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  white-space: nowrap;
}
.badge-ok      { background: rgba(20,72,72,.12); color: var(--green); }
.badge-warn    { background: rgba(196,155,116,.2); color: #8a5c1e; }
.badge-error   { background: rgba(200,50,50,.12); color: #b22; }
.badge-info    { background: rgba(27,92,92,.12); color: var(--green-light); }
.badge-neutral { background: #ececec; color: #666; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background .18s, transform .12s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-light); }

.btn-gold      { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }

.btn-outline   { background: transparent; border: 1.5px solid var(--green); color: var(--green); }
.btn-outline:hover { background: var(--green); color: #fff; }

.btn-danger    { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-sm { padding: 5px 12px; font-size: .77rem; }

/* ── FORMS ───────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-size: .8rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 5px;
}
.form-label .req { color: var(--gold-dark); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray);
  border-radius: 8px;
  font-family: 'Lato', sans-serif;
  font-size: .9rem;
  color: var(--text-dark);
  background: #fff;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}
.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(20,72,72,.1);
}
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { cursor: pointer; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ── LOGIN PAGE ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  background: #fff;
  border-radius: 14px;
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { width: 150px; }
.login-logo p {
  font-family: 'Montserrat', sans-serif;
  font-size: .72rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--gold-dark);
  margin-top: 8px;
}
.login-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
  text-align: center;
  margin-bottom: 24px;
}
.login-error {
  background: rgba(200,50,50,.1);
  color: #c03030;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .87rem;
  margin-bottom: 16px;
  border-left: 3px solid #c03030;
}
.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: .76rem;
  color: #aaa;
}
.login-footer a { color: var(--gold-dark); }

/* ── PAGE HEADER ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--green);
}
.page-header .subtitle { font-size: .87rem; color: #888; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── SECTION DIVIDER ─────────────────────────────── */
.section-divider {
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 100%);
  margin: 24px 0;
  border-radius: 2px;
}

/* ── CLIENT SELECTOR ─────────────────────────────── */
.client-selector {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.client-selector label {
  font-family: 'Montserrat', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
}
.client-selector select { max-width: 320px; }

/* ── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: #aaa;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── LOGS TABLE ──────────────────────────────────── */
.log-action { font-family: 'Montserrat', sans-serif; font-size: .75rem; font-weight: 600; }
.log-ip { font-family: monospace; font-size: .78rem; color: #999; }

/* ── JSON EDITOR ─────────────────────────────────── */
.json-editor {
  font-family: monospace;
  font-size: .82rem;
  min-height: 200px;
  background: #1a1a2e;
  color: #a8d8a8;
  border: none;
  border-radius: 8px;
  padding: 14px;
}

/* ── PAGINATION ──────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .82rem;
  text-decoration: none;
  border: 1.5px solid var(--gray);
  color: var(--text-dark);
  transition: all .15s;
}
.pagination a:hover { border-color: var(--green); color: var(--green); }
.pagination .current { background: var(--green); color: #fff; border-color: var(--green); }

/* ── PERIOD BADGE ────────────────────────────────── */
.period-tag {
  display: inline-block;
  background: rgba(20,72,72,.08);
  color: var(--green);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: .76rem;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
}

/* ── CONFIRM DELETE ──────────────────────────────── */
.confirm-inline { display: inline; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); z-index: 220; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .topbar { left: 0; }
  .main-content { margin-left: 0; width: 100%; }
  .menu-toggle { display: block; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .page-header { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── STATUS COLORS (dynamic) ─────────────────────── */
.status-ok    { color: var(--green); font-weight: 700; }
.status-warn  { color: #b26a00; font-weight: 700; }
.status-error { color: #c03030; font-weight: 700; }
