:root {
  --app-primary: #2563eb;
  --app-primary-dark: #1d4ed8;
  --app-bg: #f5f7fb;
  --app-surface: #ffffff;
  --app-text: #172033;
  --app-muted: #6b7280;
  --app-border: #e6eaf0;
  --app-sidebar: #111827;
  --app-sidebar-hover: #1f2937;
  --app-radius: 16px;
  --app-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.25rem); }

#sidebar-wrapper {
  flex-shrink: 0;
  width: 250px !important;
  min-height: 100vh;
  overflow: hidden;
  background: var(--app-sidebar) !important;
  transition: width .25s ease, min-width .25s ease;
}

#sidebar-wrapper .sidebar-heading {
  min-width: 250px;
  border-bottom-color: rgba(255,255,255,.1) !important;
  letter-spacing: -.03em;
}

#sidebar-wrapper .list-group-item {
  min-width: 250px;
  margin: 3px 12px;
  width: calc(100% - 24px);
  border-radius: 10px !important;
  color: #cbd5e1 !important;
  background: transparent !important;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}

#sidebar-wrapper .list-group-item:hover,
#sidebar-wrapper .list-group-item:focus {
  color: #fff !important;
  background: var(--app-sidebar-hover) !important;
  transform: translateX(2px);
}

#sidebar-wrapper .list-group-item.nav-active {
  color: #fff !important;
  background: linear-gradient(90deg, rgba(37,99,235,.95), rgba(59,130,246,.7)) !important;
  box-shadow: 0 5px 14px rgba(37,99,235,.2);
}

#sidebar-wrapper .list-group-item i {
  width: 22px;
  color: #93c5fd;
}

#page-content-wrapper {
  min-width: 0;
  background: var(--app-bg);
}

#page-content-wrapper > nav {
  min-height: 72px;
  background: rgba(255,255,255,.9) !important;
  border-bottom: 1px solid var(--app-border) !important;
  box-shadow: 0 2px 12px rgba(15,23,42,.03);
}

#page-content-wrapper > .container-fluid { max-width: 1600px; }

#sidebarToggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--app-primary);
  box-shadow: 0 4px 10px rgba(37,99,235,.25);
}

#sidebarToggle:hover { background: var(--app-primary-dark); }

#wrapper.sidebar-collapsed #sidebar-wrapper {
  width: 0 !important;
  min-width: 0 !important;
}

#wrapper.sidebar-collapsed #sidebar-wrapper > * { visibility: hidden; }

.card {
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.card-header {
  padding: 1rem 1.25rem;
  color: var(--app-text);
  background: transparent;
  border-bottom: 1px solid var(--app-border);
}

.card-body { padding: 1.25rem; }

.date-pill {
  padding: .6rem .9rem;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  color: var(--app-muted);
  background: #fff;
  font-size: .88rem;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 124px;
  padding: 1.2rem;
  border-radius: var(--app-radius);
  color: #fff;
  box-shadow: var(--app-shadow);
}

.metric-card > div:last-child { min-width: 0; }
.metric-card span, .metric-card small { display: block; opacity: .85; }
.metric-card span { font-size: .82rem; font-weight: 600; }
.metric-card strong { display: block; margin: .25rem 0; font-size: 1.45rem; line-height: 1.2; }
.metric-card small { font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric-icon { display: grid; width: 48px; height: 48px; flex: 0 0 48px; place-items: center; border-radius: 14px; background: rgba(255,255,255,.2); font-size: 1.35rem; }
.metric-blue { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.metric-green { background: linear-gradient(135deg, #059669, #10b981); }
.metric-orange { background: linear-gradient(135deg, #ea580c, #f59e0b); }
.metric-purple { background: linear-gradient(135deg, #7c3aed, #a855f7); }

.dashboard-chart-card { overflow: hidden; }
.dashboard-chart-card .card-header { padding: 1.15rem 1.25rem; }
.chart-container { position: relative; height: 290px; }

.btn {
  border-radius: 10px;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--app-primary); border-color: var(--app-primary); }
.btn-primary:hover { background: var(--app-primary-dark); border-color: var(--app-primary-dark); }

.form-control, .form-select {
  min-height: 44px;
  border-color: var(--app-border);
  border-radius: 10px;
  color: var(--app-text);
  background-color: #fff;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 .2rem rgba(37,99,235,.12);
}

.table { --bs-table-bg: transparent; }
.table thead th {
  padding-top: .9rem;
  padding-bottom: .9rem;
  color: var(--app-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.table tbody td { padding-top: .9rem; padding-bottom: .9rem; border-color: var(--app-border); }
.table-hover > tbody > tr:hover > * { --bs-table-accent-bg: #f8fafc; }

.alert { border: 0; border-radius: 12px; }
.badge { padding: .5em .7em; border-radius: 999px; }
.text-muted { color: var(--app-muted) !important; }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

@media (max-width: 767.98px) {
  #sidebar-wrapper { position: fixed; z-index: 1030; height: 100vh; }
  #wrapper:not(.sidebar-collapsed) #page-content-wrapper { margin-left: 250px; }
  #wrapper.sidebar-collapsed #page-content-wrapper { margin-left: 0; }
  #page-content-wrapper > .container-fluid { padding: 1rem !important; }
}