:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-soft: #ccfbf1;
  --accent: #0284c7;
  --bg: #f0fdfa;
  --surface: #ffffff;
  --text: #134e4a;
  --muted: #64748b;
  --border: #dbe4ea;
  --shadow: 0 1px 3px rgba(15, 118, 110, 0.08), 0 10px 24px rgba(15, 118, 110, 0.08);
  --sidebar-w: 266px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -5%, #c8faf2 0, rgba(200, 250, 242, 0) 36%),
    radial-gradient(circle at 95% 8%, #d6efff 0, rgba(214, 239, 255, 0) 26%),
    var(--bg);
  min-height: 100vh;
}

.crm-guest {
  color: var(--text);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f766e 0%, #134e4a 100%);
  color: #fff;
  padding: 18px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 140;
  transition: transform 0.25s ease;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.brand-text h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.brand-text small {
  font-size: 11px;
  opacity: 0.7;
}

.menu {
  margin-top: 14px;
  flex: 1;
  overflow-y: auto;
}

.menu-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.6;
  padding: 12px 10px 8px;
}

.menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.87);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 9px;
  margin-bottom: 3px;
  font-size: 14px;
  font-weight: 500;
}

.menu a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu a.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.menu a .ic {
  display: inline-flex;
  width: 20px;
  justify-content: center;
  align-items: center;
  font-size: 15px;
  line-height: 1;
}

.menu a .ic i {
  display: block;
}

.menu-badge {
  margin-left: auto;
  min-width: 22px;
  border-radius: 999px;
  padding: 1px 7px;
  text-align: center;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 11px;
}

.sidebar-actions {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 12px;
}

.main-shell {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.topbar .as-of {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.topbar .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  margin-right: 10px;
}

body.crm-auth.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
}

body.crm-auth.sidebar-collapsed .main-shell {
  margin-left: 0;
}

.btn-like,
button.ghost,
button.primary {
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
}

button.ghost {
  border-color: var(--border);
  color: var(--text);
  background: #fff;
}

.btn-like.primary,
button.primary {
  background: var(--primary);
  color: #fff;
}

.btn-like.primary:hover,
button.primary:hover {
  background: var(--primary-dark);
}

.content-shell {
  margin: 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(13, 148, 136, 0.14);
  background: rgba(255, 255, 255, 0.68);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  overflow: visible;
}

body.modal-open .content-shell {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.alert {
  border: 0;
  margin: 0 18px;
}

.card.panel,
.panel,
.stat,
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: #0f3d3a;
  box-shadow: var(--shadow);
}

.card-header {
  background: #f8fffe;
  border-bottom: 1px solid var(--border);
}

.stat {
  padding: 16px;
}

.stat small {
  color: var(--muted);
}

.stat b {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.table,
.table td,
.card-header {
  color: #0f3d3a;
}

.table thead th {
  color: var(--muted);
  border-bottom-color: var(--border);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.table td {
  border-bottom-color: #eaf1f4;
}

.table-dark,
.table-dark > :not(caption) > * > * {
  color: #fff !important;
}

thead.table-dark th,
.table thead.table-dark th,
.table thead.bg-dark th,
table.table thead.bg-dark th,
table.table thead[style*='background'] th {
  color: #fff !important;
}

.bg-dark,
.bg-dark > th,
.bg-dark > td {
  color: #fff !important;
}

.badge.text-bg-light {
  border: 1px solid #d4e4ec;
}

.form-control,
.form-select {
  border-radius: 9px;
  border-color: #cadbe4;
}

.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 148, 136, 0.16);
  border-color: var(--primary);
}

.btn-dark {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline-dark {
  color: var(--primary-dark);
  border-color: var(--primary-dark);
}

.workflow-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 14px;
}

.workflow-column {
  min-width: 260px;
  background: #e8f8f5;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid #d2ece6;
}

.workflow-column header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #0f4b47;
  padding: 6px;
}

.workflow-column header span {
  background: #fff;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
}

.patient-card {
  display: block;
  text-decoration: none;
  color: #114541;
  background: #fff;
  border: 1px solid #d4e8e3;
  border-radius: 10px;
  padding: 12px;
  margin: 10px 2px;
}

.patient-card:hover {
  border-color: #8bcfc4;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(430px, 94vw);
  background: #fff;
  border-radius: 18px;
  padding: 36px;
  box-shadow: 0 20px 50px rgba(15, 118, 110, 0.18);
  color: #134e4a;
}

.brand {
  font-size: 25px;
  line-height: 1.05;
  font-weight: 700;
}

.brand small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 120;
}

.mobile-overlay.open {
  display: block;
}

@media (max-width: 1000px) {
  .topbar {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .topbar .actions {
    width: 100%;
  }

  .topbar .actions .btn-like,
  .topbar .actions button {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 840px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-shell {
    margin-left: 0;
  }

  .content-shell {
    margin: 12px;
    padding: 12px;
  }

  .alert {
    margin: 0 12px;
  }
}

.finance-page .finance-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.finance-page .finance-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.finance-page .finance-nav-item {
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #0f4c48;
  font-size: 13px;
}

.finance-page .finance-nav-item.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kpi-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  border-top-width: 3px;
}

.kpi-card.income {
  border-top-color: #10b981;
}

.kpi-card.expense {
  border-top-color: #ef4444;
}

.kpi-card.profit {
  border-top-color: #0d9488;
}

.kpi-card.pending {
  border-top-color: #f59e0b;
}

.report-selector .report-card {
  display: flex;
  flex-direction: column;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  text-decoration: none;
}

.report-selector .report-card:hover,
.report-selector .report-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.16);
  transform: translateY(-2px);
}

.report-card-value {
  display: block;
  margin-top: auto;
  padding-top: 16px;
  font-size: 20px;
  font-weight: 700;
}

.report-detail {
  display: none;
}

.report-detail.is-visible {
  display: flex;
}

.report-detail.card.is-visible {
  display: block;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
}

.kpi-note {
  font-size: 12px;
  color: var(--muted);
}

.finance-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-height: 170px;
  padding-top: 8px;
}

.finance-bar-group {
  flex: 1;
  min-width: 42px;
  text-align: center;
}

.finance-bars {
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.finance-bars .bar {
  width: 14px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.finance-bars .bar.in {
  background: #10b981;
}

.finance-bars .bar.ex {
  background: #fca5a5;
}

.expense-row {
  margin-bottom: 10px;
}

.expense-progress {
  width: 100%;
  background: #ecf3f5;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}

.expense-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0d9488, #0284c7);
}

.status-paguar {
  background: #d1fae5;
  color: #065f46;
}

.status-ne-pritje,
.status-pjeserisht {
  background: #fef3c7;
  color: #92400e;
}

.status-me-vonese {
  background: #fee2e2;
  color: #991b1b;
}

.modal-backdrop.show {
  opacity: 0.5;
}

.modal .modal-content {
  background: #ffffff;
  color: #134e4a;
  border: 1px solid #dbe4ea;
  box-shadow: 0 24px 55px rgba(15, 118, 110, 0.2);
}

.modal .modal-header,
.modal .modal-footer {
  background: #f8fffe;
  border-color: #e2edf1;
}

.modal .modal-title {
  color: #0f4b47;
  font-weight: 700;
}

.modal .form-label {
  color: #0f4b47;
  font-weight: 600;
}

.task-template-shell .task-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.task-toolbar-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #cfe7e3;
  background: #f7fffd;
  color: #0f4c48;
  font-size: 12px;
  font-weight: 600;
}

.task-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.task-stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.task-stat-value {
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  color: #0f4c48;
}

.task-stat-label {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.task-list-card .card-header {
  background: #f8fffe;
}

.task-table thead th {
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5f7185;
}

.task-kanban {
  align-items: flex-start;
}

.task-kanban-col {
  background: #f8fafc;
  border: 1px solid #dbe4ea;
}

.task-column-header {
  border-bottom: 1px solid #dde8ee;
}

.task-column-header strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.task-col-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488, #0284c7);
  flex-shrink: 0;
}

.task-item-card {
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.06);
}

.task-empty-col {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 18px 10px;
}

.task-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.task-data-card {
  border: 1px solid #dbe4ea;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px;
}

.task-data-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.task-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #eef3f6;
  padding-top: 8px;
  margin-top: 8px;
  font-size: 13px;
}

.task-meta-line span:first-child {
  color: var(--muted);
}

.task-inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.task-inline-form .form-select {
  min-width: 140px;
}

@media (max-width: 840px) {
  .finance-page .finance-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .task-template-shell .task-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-inline-form {
    flex-direction: column;
    align-items: stretch;
  }
}
