:root {
  color-scheme: light;
  color: #111827;
  background: #f8fafc;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f8fafc;
}

button,
a {
  border: none;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  color: inherit;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 14px;
  background: #f59e0b;
  color: #111827;
  font-weight: 700;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.primary-button:hover {
  background: #fcd34d;
  transform: translateY(-1px);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 14px;
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.secondary-button:hover {
  background: #e5e7eb;
  transform: translateY(-1px);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 24px 20px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-logo-container {
  width: 64px;
  min-width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  cursor: pointer;
  overflow: hidden;
}

.brand-icon {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: #f59e0b;
  color: white;
  font-size: 18px;
}

.brand-icon img,
.brand-logo-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.9rem;
  color: #6b7280;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.sidebar-dashboard-button {
  margin-bottom: 18px;
}

.nav-link,
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fafc;
  color: #111827;
  transition: background-color 0.2s ease;
}

.nav-link:hover,
.sidebar-toggle:hover,
.nav-link.active,
.sidebar-toggle.active {
  background: #fef3c7;
}

.nav-link.active {
  font-weight: 700;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-submenu {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding-left: 16px;
}

.sidebar-submenu.open {
  display: flex;
}

.sidebar-submenu a,
.submenu-link {
  padding: 10px 16px;
  border-radius: 14px;
  background: #f8fafc;
  color: #374151;
  font-size: 0.95rem;
}

.sidebar-submenu a:hover,
.submenu-link:hover {
  background: #f3f4f6;
}

.submenu-link.active {
  background: #fef3c7;
  font-weight: 700;
}

.chevron {
  transition: transform 0.2s ease;
}

.sidebar-toggle.open .chevron {
  transform: rotate(90deg);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-footer .nav-link {
  background: #f8fafc;
}

.sidebar-footer .nav-link.secondary {
  background: #f3f4f6;
}

.main-content {
  padding: 28px 32px;
  overflow: auto;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 26px;
}

.top-bar h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
}

.subtitle,
.chart-subtitle {
  margin: 6px 0 0;
  color: #6b7280;
  font-size: 0.95rem;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-controls select,
.icon-button,
.search-input {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: white;
}

.search-input {
  width: min(100%, 420px);
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  z-index: 1000;
}

.modal-content {
  width: min(680px, 100%);
  max-height: min(85vh, 720px);
  overflow-y: auto;
  background: white;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.18);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-size: 1.25rem;
  cursor: pointer;
}

.modal-title {
  margin: 0 0 12px;
  font-size: 1.4rem;
  font-weight: 800;
}

.modal-text {
  color: #4b5563;
  line-height: 1.75;
  white-space: pre-line;
  margin-bottom: 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.settings-button {
  padding: 14px 20px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  background: #fef3c7;
  color: #111827;
  font-weight: 700;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.settings-button:hover {
  background: #fcd34d;
  transform: translateY(-1px);
}

.icon-button {
  position: relative;
  font-size: 18px;
}

.back-button {
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #111827;
  font-weight: 700;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.back-button:hover {
  background: #fef3c7;
  transform: translateY(-1px);
}

.badge {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 8px;
  height: 8px;
  background: #f59e0b;
  border-radius: 999px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #f59e0b;
  color: white;
  font-weight: 700;
}

.profile-name {
  font-weight: 700;
}

.profile-role {
  font-size: 0.82rem;
  color: #6b7280;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.metric-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 24px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label {
  color: #6b7280;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.metric-value {
  font-size: 2.4rem;
  font-weight: 800;
}

.metric-change {
  font-size: 0.95rem;
  font-weight: 700;
}

.metric-change.positive {
  color: #16a34a;
}

.metric-change.negative {
  color: #dc2626;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.chart-card,
.table-card,
.documents-grid {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 22px;
}

.chart-header,
.section-header {
  margin-bottom: 20px;
}

.doc-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.doc-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border-radius: 20px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #111827;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
}

.doc-card-label {
  font-weight: 700;
  font-size: 1rem;
}

.doc-card-text {
  color: #6b7280;
  font-size: 0.95rem;
}

.chart-card,
.table-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  padding: 22px;
}

.chart-header {
  margin-bottom: 20px;
}

.chart-wrapper {
  width: 100%;
  min-height: 280px;
}

.calendar-container {
  width: 100%;
  min-height: 280px;
  padding: 18px;
  border-radius: 20px;
  background: #f8fafc;
  display: grid;
  gap: 14px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.calendar-day,
.calendar-cell {
  display: grid;
  align-items: start;
  min-height: 70px;
  padding: 12px;
  border-radius: 16px;
  background: white;
  border: 1px solid #e5e7eb;
}

.calendar-day {
  background: transparent;
  border: none;
  color: #6b7280;
  font-weight: 700;
}

.calendar-cell.today {
  background: #fef3c7;
  border-color: #f59e0b;
}

.calendar-cell.selected {
  outline: 2px solid #f59e0b;
  background: #fff7df;
}

.calendar-cell .date-number {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.calendar-event {
  margin-top: 6px;
  padding: 8px;
  border-radius: 14px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.3;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.message-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-radius: 20px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.message-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.message-from {
  font-weight: 700;
}

.message-subject {
  font-size: 1rem;
  color: #111827;
}

.message-preview {
  color: #6b7280;
  font-size: 0.95rem;
}

.message-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  white-space: nowrap;
}

.message-time {
  color: #6b7280;
  font-size: 0.9rem;
}

.message-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: white;
  background: #f59e0b;
}

svg {
  width: 100%;
  height: 100%;
}

.table-header {
  margin-bottom: 18px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

th,
td {
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

th {
  color: #6b7280;
  font-size: 0.9rem;
  font-weight: 700;
}

tbody tr:nth-child(odd) {
  background: #fafafa;
}

tbody td {
  color: #111827;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .metrics-grid,
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-controls {
    width: 100%;
  }
}

/* domyślnie BEZ podświetlenia */
.sidebar-toggle {
  background: #f3f5f9;
  color: #0f172a;
  border: 1px solid transparent;
}

/* podświetlenie tylko gdy aktywne/otwarte */
.sidebar-toggle.active,
.sidebar-toggle.open,
.sidebar-toggle[aria-expanded="true"] {
  background: #f6edc3;
  border-color: #eadb9a;
  font-weight: 600;
}

/* Modal maila: bez wyśrodkowania, pozycja ustawiana z JS */
#mail-modal {
  background: rgba(15, 23, 42, 0.25);
  place-items: start;
  padding: 0;
}

#mail-modal .modal-content {
  position: fixed;
  margin: 0;
  border-radius: 24px;
  padding: 22px;
  display: flex;
  flex-direction: column;
}

#mail-modal .modal-footer {
  margin-top: auto;
  display: flex;
  justify-content: flex-end; /* prawy dół */
}

/* ============================================================
   MOTYWY — globalne
============================================================ */

/* CIEMNY */
body.theme-dark,
body.theme-darker {
  background: #0f172a !important;
}
body.theme-dark .sidebar,
body.theme-darker .sidebar {
  background: #0f172a !important;
  border-right: 1px solid #1e293b !important;
}
body.theme-dark .main-content  { background: #1e293b !important; }
body.theme-darker .main-content { background: #0f172a !important; }

body.theme-dark .top-bar,
body.theme-darker .top-bar {
  background: #1e293b !important;
  border-bottom-color: #334155 !important;
}
body.theme-dark h1, body.theme-darker h1 { color: #f1f5f9 !important; }
body.theme-dark .subtitle, body.theme-darker .subtitle { color: #94a3b8 !important; }
body.theme-dark .brand-title,    body.theme-darker .brand-title,
body.theme-dark .brand-subtitle, body.theme-darker .brand-subtitle,
body.theme-dark .nav-link,       body.theme-darker .nav-link,
body.theme-dark .sidebar-toggle, body.theme-darker .sidebar-toggle,
body.theme-dark .submenu-link,   body.theme-darker .submenu-link { color: #cbd5e1 !important; }
body.theme-dark .table-card,     body.theme-darker .table-card,
body.theme-dark .settings-card,  body.theme-darker .settings-card {
  background: #1e293b !important;
  border-color: #334155 !important;
}
body.theme-dark .table-card h2,  body.theme-darker .table-card h2,
body.theme-dark .settings-card h3, body.theme-darker .settings-card h3,
body.theme-dark .lbl,            body.theme-darker .lbl { color: #f1f5f9 !important; }
body.theme-dark table th,        body.theme-darker table th {
  background: #0f172a !important;
  color: #94a3b8 !important;
  border-color: #334155 !important;
}
body.theme-dark table td,        body.theme-darker table td {
  color: #cbd5e1 !important;
  border-color: #1e293b !important;
}
body.theme-dark table tr:hover td,
body.theme-darker table tr:hover td { background: #334155 !important; }
body.theme-dark input,  body.theme-dark textarea,  body.theme-dark select,
body.theme-darker input, body.theme-darker textarea, body.theme-darker select {
  background: #0f172a !important;
  color: #f1f5f9 !important;
  border-color: #334155 !important;
}

/* NIEBIESKI */
body.theme-blue .sidebar { background: #1e3a5f !important; }
body.theme-blue .brand-title,    body.theme-blue .brand-subtitle,
body.theme-blue .nav-link,       body.theme-blue .sidebar-toggle,
body.theme-blue .submenu-link    { color: #fff !important; }

/* ZIELONY */
body.theme-green .sidebar { background: #14532d !important; }
body.theme-green .brand-title,   body.theme-green .brand-subtitle,
body.theme-green .nav-link,      body.theme-green .sidebar-toggle,
body.theme-green .submenu-link   { color: #fff !important; }

.notif-panel {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 320px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 24px #0001;
  z-index: 1000;
  display: none;
}
.notif-panel.open { display: block; }
.notif-head {
  font-weight: bold;
  padding: 12px 16px 8px 16px;
  border-bottom: 1px solid #eee;
  background: #f9fafb;
}
.notif-item {
  padding: 10px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.notif-item:last-child { border-bottom: none; }
.notif-title { font-size: 1rem; }
.notif-meta { color: #6b7280; font-size: 0.85em; }
.notif-empty { padding: 18px; color: #aaa; text-align: center; }
.notif-new-dot {
  display: none;
  width: 10px;
  height: 10px;
  background: #f59e0b;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  right: 2px;
}
