:root {
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 70px;
  --header-height: 60px;
  --primary-color: #0d6efd;
  --sidebar-bg: #0b161c;
  --sidebar-text: #a2a3b7;
  --sidebar-active: #3699ff;
  --sidebar-hover-bg: #1b1b28;
  --body-bg: #f5f8fa;
  --body-text: #1f2937;
  --card-radius: 12px;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--body-bg);
  color: var(--body-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-body {
  background: var(--body-bg);
}

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

.sidebar {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  overflow: hidden;
  position: fixed;
  top: 0;
  transition: width .3s ease, transform .3s ease;
  width: var(--sidebar-width);
  z-index: 1030;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  display: flex;
  justify-content: space-between;
  min-height: 86px;
  overflow: hidden;
  padding: 20px 12px;
}

.sidebar-logo {
  align-items: center;
  color: #fff;
  display: flex;
  text-decoration: none;
}

.sidebar-logo-img {
  display: block;
  height: 42px;
  max-width: 146px;
  object-fit: contain;
}

.sidebar-logo span,
.nav-link span,
.sidebar-footer span {
  display: inline-block;
  overflow: hidden;
  transition: opacity .3s ease, width .3s ease;
  white-space: nowrap;
}

.brand-subtitle {
  color: rgba(255, 255, 255, .52);
  display: block;
  font-size: .68rem;
  letter-spacing: .04em;
  margin-left: 44px;
  margin-top: -12px;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo span,
.sidebar.collapsed .brand-subtitle,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer span {
  opacity: 0;
  width: 0 !important;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
}

.sidebar.collapsed .sidebar-logo-img {
  content: url("/assets/img/favicon.png");
  height: 38px;
  width: 38px;
}

.sidebar-toggle {
  background: transparent;
  border: 0;
  color: var(--sidebar-text);
  padding: 5px;
}

.sidebar-toggle:hover {
  color: #fff;
}

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

.nav-section {
  margin-bottom: 20px;
}

.nav-section-title {
  color: var(--sidebar-text);
  font-size: .72rem;
  letter-spacing: 1px;
  margin-bottom: 5px;
  padding: 10px 20px;
  text-transform: uppercase;
}

.sidebar.collapsed .nav-section-title {
  font-size: .58rem;
  overflow: hidden;
  padding: 10px 5px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  margin: 2px 10px;
}

.nav-link {
  align-items: center;
  border-radius: 8px;
  color: var(--sidebar-text);
  display: flex;
  font-size: .95rem;
  gap: 12px;
  padding: 12px 15px;
  text-decoration: none;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}

.nav-link i {
  flex: 0 0 24px;
  font-size: 1.18rem;
  text-align: center;
}

.nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.nav-link.active {
  background: linear-gradient(90deg, var(--sidebar-active), #1e88e5);
  box-shadow: 0 4px 15px rgba(54, 153, 255, .3);
  color: #fff;
}

.sidebar.collapsed .nav-link {
  gap: 0;
  justify-content: center;
  padding: 12px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .1);
  overflow: hidden;
  padding: 18px 10px;
  white-space: nowrap;
}

.sidebar-footer .nav-link {
  margin: 2px 0;
}

.main-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.main-header {
  align-items: center;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 15px 30px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-title {
  color: #333;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.content-area {
  flex: 1;
  padding: 30px;
}

.page-heading {
  margin-bottom: 24px;
}

.page-heading h1 {
  color: #1f2937;
  font-size: clamp(1.55rem, 1.2rem + 1vw, 2.1rem);
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
}

.page-heading p {
  color: #6b7280;
  margin: 6px 0 0;
}

.stats-card {
  background: #fff;
  border: 0;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
  padding: 24px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.stats-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, .1);
  transform: translateY(-2px);
}

.stats-label {
  color: #6b7280;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0;
  text-transform: uppercase;
}

.stats-value {
  color: #1f2937;
  font-size: 1.65rem;
  font-weight: 700;
  margin: 6px 0 0;
}

.icon-box {
  align-items: center;
  border-radius: 12px;
  color: #fff;
  display: inline-flex;
  font-size: 1.15rem;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.bg-gradient-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
}

.bg-gradient-success {
  background: linear-gradient(135deg, #11998e, #38ef7d);
}

.bg-gradient-warning {
  background: linear-gradient(135deg, #f093fb, #f5576c);
}

.bg-gradient-info {
  background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.surface-card,
.form-card,
.data-table {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .05);
}

.surface-card,
.form-card {
  padding: 24px;
}

.data-table {
  overflow: hidden;
}

.data-table .table {
  margin-bottom: 0;
}

.data-table .table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  color: #666;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 15px;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table .table tbody td {
  padding: 15px;
  vertical-align: middle;
}

.data-table .table tbody tr:hover {
  background: #f8f9fa;
}

.btn-action {
  align-items: center;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  height: 35px;
  justify-content: center;
  transition: background .2s ease, color .2s ease;
  width: 35px;
}

.btn-view {
  background: #e3f2fd;
  color: #1976d2;
}

.btn-view:hover {
  background: #1976d2;
  color: #fff;
}

.btn-edit {
  background: #fff8e1;
  color: #f57c00;
}

.btn-edit:hover {
  background: #f57c00;
  color: #fff;
}

.btn-delete {
  background: #ffebee;
  color: #d32f2f;
}

.btn-delete:hover {
  background: #d32f2f;
  color: #fff;
}

.empty-state {
  color: #6b7280;
  padding: 42px 20px;
  text-align: center;
}

.app-toast {
  max-width: min(420px, calc(100vw - 32px));
  position: fixed;
  right: 20px;
  top: 20px;
  z-index: 1080;
}

.switch-control {
  cursor: pointer;
}

.switch-control input + span {
  background: #d1d5db;
  border-radius: 999px;
  display: inline-block;
  height: 22px;
  position: relative;
  transition: background .2s ease;
  width: 42px;
}

.switch-control input + span::after {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  content: "";
  height: 18px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform .2s ease;
  width: 18px;
}

.switch-control input:checked + span {
  background: var(--sidebar-active);
}

.switch-control input:checked + span::after {
  transform: translateX(20px);
}

.app-chart-bar {
  background: rgba(13, 110, 253, .88);
  border-radius: 8px 8px 0 0;
  min-height: 8px;
}

#chartRevenueBySystem {
  min-height: 240px;
}

#chartPaymentStatus > div {
  align-items: center;
  display: flex;
  height: 190px;
  justify-content: center;
  width: 190px;
}

.app-donut-hole {
  align-items: center;
  display: flex;
  justify-content: center;
}

#chartMonthly .rounded {
  height: 9px;
}

#statusChart {
  height: 14px;
}

#statusLegend .legend-dot,
.legend-dot {
  height: .65rem;
  width: .65rem;
}

.modal-shell {
  background: rgba(11, 22, 28, .55);
  z-index: 2000;
}

.modal-panel {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .22);
  max-height: calc(100vh - 48px);
  max-width: 960px;
  overflow: hidden;
}

.auth-page {
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(54, 153, 255, .35), transparent 60%),
    radial-gradient(900px 420px at 85% 0%, rgba(15, 118, 110, .28), transparent 60%),
    #071016;
  min-height: 100vh;
}

.auth-card {
  border: 0;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
  max-width: 440px;
}

.auth-brand-logo {
  display: block;
  height: auto;
  max-width: 220px;
  width: 72%;
}

.input-icon {
  left: 14px;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}

.input-icon + .form-control {
  padding-left: 2.5rem;
}

.sidebar-overlay {
  background: rgba(0, 0, 0, .5);
  bottom: 0;
  display: none;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1020;
}

.sidebar-overlay.show {
  display: block;
}

.mobile-toggle {
  display: none;
}

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

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

  .sidebar.collapsed {
    width: var(--sidebar-width);
  }

  .main-content,
  .sidebar.collapsed ~ .main-content {
    margin-left: 0;
  }

  .mobile-toggle {
    display: inline-flex;
  }
}

@media (max-width: 575.98px) {
  .content-area {
    padding: 18px;
  }

  .main-header {
    padding: 14px 16px;
  }

  .page-title {
    font-size: 1rem;
  }

  .header-actions .btn span:not(.visually-hidden),
  .header-actions .btn .label {
    display: none;
  }
}
