:root {
  --primary: #1d4ed8;
  --primary-soft: #eff6ff;
  --accent: #c69a33;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --body-bg: #f3f6fb;
  --card-bg: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --success-soft: #ecfdf3;
  --danger-soft: #fef2f2;
  --warning-soft: #fffbeb;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background:
    radial-gradient(circle at top right, rgba(198, 154, 51, 0.08), transparent 18%),
    linear-gradient(180deg, #f8fbff 0%, var(--body-bg) 100%);
  color: var(--text-main);
}

a {
  text-decoration: none;
}

.app-body {
  min-height: 100vh;
}

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

.sidebar {
  width: 280px;
  background: linear-gradient(180deg, #111827 0%, var(--sidebar-bg) 100%);
  color: #fff;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-close {
  align-self: flex-end;
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  box-shadow: 0 18px 30px rgba(29, 78, 216, 0.25);
  font-size: 1.25rem;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.85rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.4rem;
}

.sidebar-link,
.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.82);
  padding: 0.9rem 1rem;
  transition: 0.2s ease;
}

.sidebar-link:hover,
.sidebar-footer-link:hover,
.sidebar-link.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link i,
.sidebar-footer-link i {
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer-label {
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 700;
}

.app-content {
  flex: 1;
  min-width: 0;
}

.topbar {
  padding: 1.25rem 1.75rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.8rem 1rem;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--shadow-sm);
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(29, 78, 216, 0.15) 0%, rgba(198, 154, 51, 0.18) 100%);
  font-weight: 700;
  color: var(--primary);
}

.main-content {
  padding-bottom: 2rem;
}

.section-card,
.app-card {
  background: var(--card-bg);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.app-card {
  padding: 1.35rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  height: 100%;
  overflow: hidden;
  position: relative;
}

.metric-card-button {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.metric-card-button:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(29, 78, 216, 0.14);
}

.metric-card-button.is-active {
  border-color: rgba(29, 78, 216, 0.28);
  box-shadow: 0 0 0 1px rgba(29, 78, 216, 0.08), var(--shadow-md);
}

.metric-card-button:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.22rem rgba(29, 78, 216, 0.16), var(--shadow-md);
}

.metric-card::after {
  content: '';
  position: absolute;
  inset: auto -10% -35% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(29, 78, 216, 0.06);
}

.metric-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.metric-caption {
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-size: 0.92rem;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
}

.metric-icon.primary {
  background: rgba(29, 78, 216, 0.12);
  color: var(--primary);
}

.metric-icon.gold {
  background: rgba(198, 154, 51, 0.14);
  color: var(--accent);
}

.metric-icon.green {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.metric-icon.red {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

.card-soft {
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  background: var(--primary-soft);
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.table {
  --bs-table-striped-bg: #f8fafc;
  --bs-table-hover-bg: #f1f5f9;
  margin-bottom: 0;
}

.table-responsive .table:not(.responsive-table) {
  min-width: 680px;
}

.table thead th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  white-space: nowrap;
}

.table tbody td {
  vertical-align: middle;
}

.summary-stack {
  display: grid;
  gap: 1rem;
}

.summary-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.05rem;
  background: #fff;
}

.summary-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.summary-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.35rem;
}

.dashboard-detail-panel {
  scroll-margin-top: 120px;
}

.detail-kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.detail-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.detail-switcher .btn {
  flex: 1 1 180px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-actions > * {
  margin: 0 !important;
}

.form-actions,
.app-card form > .d-flex.justify-content-end,
.app-card form > .d-flex.justify-content-end.gap-2,
.app-card form > .d-flex.justify-content-end.mt-4,
.app-card form > .d-flex.justify-content-end.gap-2.mt-4 {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.app-card form > .d-flex.justify-content-between,
.app-card form > .d-flex.justify-content-between.gap-2,
.app-card form > .d-flex.justify-content-between.mt-4,
.app-card form > .d-flex.justify-content-between.gap-2.mt-4 {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
}

.input-group-text {
  white-space: nowrap;
}

.pagination {
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pagination .page-link {
  border-radius: 12px;
}

.auth-body {
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.auth-card {
  max-width: 460px;
  margin: 4rem auto;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.auth-header {
  padding: 2rem 2rem 0.5rem;
}

.auth-body-inner {
  padding: 1rem 2rem 2rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
  border-color: transparent;
  box-shadow: 0 16px 28px rgba(29, 78, 216, 0.2);
}

.btn-warning {
  background: linear-gradient(135deg, #c69a33 0%, #d6b15f 100%);
  border-color: transparent;
  color: #fff;
}

.form-control,
.form-select {
  border-radius: 14px;
  padding: 0.78rem 0.95rem;
  border-color: #dce3ee;
}

.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.22rem rgba(29, 78, 216, 0.12);
  border-color: rgba(29, 78, 216, 0.4);
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.months-filter-form {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.months-filter-field {
  min-width: 150px;
}

.months-filter-label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

.months-filter-select {
  min-width: 150px;
  padding-right: 2.75rem;
}

.months-filter-button {
  min-width: 112px;
}

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.badge-soft {
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.search-input {
  min-width: 240px;
}

.supplier-search-form {
  align-items: flex-start;
}

.supplier-search-box {
  flex: 1 1 320px;
  min-width: 280px;
}

.supplier-search-box .search-input {
  min-width: 100%;
}

.chart-wrap {
  min-height: 320px;
}

.day-link {
  font-weight: 700;
  color: var(--primary);
}

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

.list-clean li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.list-clean li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.sidebar-toggle {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.confirm-modal .modal-dialog {
  max-width: 560px;
}

.confirm-modal .modal-content {
  border: 0;
  border-radius: 28px;
  box-shadow: 0 34px 90px rgba(15, 23, 42, 0.22);
  background:
    radial-gradient(circle at top right, rgba(198, 154, 51, 0.12), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.confirm-modal-shell {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.confirm-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  background: rgba(29, 78, 216, 0.12);
  color: var(--primary);
}

.confirm-modal-icon.is-primary {
  background: rgba(29, 78, 216, 0.12);
  color: var(--primary);
}

.confirm-modal-icon.is-success {
  background: rgba(16, 185, 129, 0.14);
  color: #059669;
}

.confirm-modal-icon.is-warning {
  background: rgba(198, 154, 51, 0.16);
  color: #b7791f;
}

.confirm-modal-icon.is-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #dc2626;
}

.confirm-modal-kicker {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.confirm-modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.confirm-modal-text {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.confirm-modal-actions .btn {
  min-width: 130px;
  border-radius: 14px;
  padding-top: 0.78rem;
  padding-bottom: 0.78rem;
  font-weight: 700;
}

.summary-modal .modal-content {
  border: 0;
  border-radius: 26px;
  box-shadow: 0 32px 80px rgba(15, 23, 42, 0.18);
  background:
    radial-gradient(circle at top right, rgba(29, 78, 216, 0.06), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.summary-modal .modal-header,
.summary-modal .modal-footer {
  background: transparent;
}

.summary-modal .modal-dialog {
  position: relative;
  z-index: 2;
}

.summary-modal .modal-target-backdrop {
  display: none;
}

.summary-modal.modal-target-fallback:target {
  display: block;
  opacity: 1;
  background: rgba(15, 23, 42, 0.46);
}

.summary-modal.modal-target-fallback:target .modal-dialog {
  transform: none;
}

.summary-modal.modal-target-fallback:target .modal-target-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 1;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    width: min(86vw, 300px);
    max-width: 300px;
    left: 0;
    z-index: 1035;
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s ease, opacity 0.2s ease;
    height: 100dvh;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.36);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 1030;
  }

  .topbar {
    padding: 1rem;
  }

  .topbar-left,
  .topbar-right {
    flex-wrap: wrap;
  }

  .topbar-user {
    max-width: 100%;
  }

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

  .app-card {
    padding: 1.15rem;
  }

  .sidebar-brand {
    padding-right: 0.25rem;
  }

  .chart-wrap {
    min-height: 260px;
  }
}

@media (max-width: 767.98px) {
  .app-shell {
    display: block;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.95rem 1rem;
  }

  .confirm-modal-shell {
    flex-direction: column;
  }

  .confirm-modal-actions {
    flex-direction: column-reverse;
  }

  .confirm-modal-actions .btn {
    width: 100%;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .topbar-right {
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
  }

  .topbar-chip,
  .topbar .dropdown,
  .topbar-user {
    width: 100%;
  }

  .topbar-chip {
    justify-content: center;
  }

  .topbar-user {
    justify-content: space-between;
  }

  .topbar .dropdown-menu {
    width: 100%;
  }

  .card-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .card-title-row > .d-flex,
  .card-title-row > a,
  .card-title-row > .btn,
  .card-title-row > form {
    width: 100%;
  }

  .card-title-row > .d-flex {
    flex-direction: column;
    align-items: stretch;
  }

  .card-title-row > .d-flex > * {
    width: 100%;
  }

  .months-filter-form {
    width: 100%;
  }

  .months-filter-field,
  .months-filter-select,
  .months-filter-button {
    width: 100%;
  }

  .filters-bar {
    flex-direction: column;
  }

  .filters-bar > * {
    width: 100%;
  }

  .supplier-search-box {
    min-width: 100%;
  }

  .search-input {
    min-width: 100%;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .metric-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 1rem;
  }

  .summary-item {
    padding: 0.95rem;
  }

  .detail-actions,
  .form-actions,
  .app-card form > .d-flex.justify-content-end,
  .app-card form > .d-flex.justify-content-end.gap-2,
  .app-card form > .d-flex.justify-content-end.mt-4,
  .app-card form > .d-flex.justify-content-end.gap-2.mt-4,
  .app-card form > .d-flex.justify-content-between,
  .app-card form > .d-flex.justify-content-between.gap-2,
  .app-card form > .d-flex.justify-content-between.mt-4,
  .app-card form > .d-flex.justify-content-between.gap-2.mt-4 {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .detail-actions > *,
  .form-actions > *,
  .app-card form > .d-flex.justify-content-end > *,
  .app-card form > .d-flex.justify-content-end.gap-2 > *,
  .app-card form > .d-flex.justify-content-end.mt-4 > *,
  .app-card form > .d-flex.justify-content-end.gap-2.mt-4 > *,
  .app-card form > .d-flex.justify-content-between > *,
  .app-card form > .d-flex.justify-content-between.gap-2 > *,
  .app-card form > .d-flex.justify-content-between.mt-4 > *,
  .app-card form > .d-flex.justify-content-between.gap-2.mt-4 > * {
    width: 100%;
  }

  .app-card form > .d-flex.justify-content-between span:empty {
    display: none;
  }

  .detail-switcher .btn,
  .app-card form > .d-flex.justify-content-between > .d-flex {
    width: 100%;
  }

  .app-card form > .d-flex.justify-content-between > .d-flex {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem !important;
  }

  .app-card form > .d-flex.justify-content-between > .d-flex > * {
    width: 100%;
  }

  .list-clean li {
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start !important;
  }

  .table-actions > *,
  .table-actions a,
  .table-actions form,
  .table-actions .btn {
    width: 100%;
  }

  .table-responsive {
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    padding-left: 0.25rem;
    padding-right: 0.25rem;
  }

  .table-responsive .table:not(.responsive-table) {
    min-width: 620px;
  }

  .responsive-table {
    min-width: 100% !important;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 0.85rem;
  }

  .responsive-table tr {
    display: block;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    padding: 0.35rem 0.95rem;
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .responsive-table td {
    display: block;
    width: 100%;
    text-align: left !important;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  }

  .responsive-table td:last-child {
    border-bottom: 0;
    padding-bottom: 0.35rem;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
  }

  .responsive-table td[colspan]::before {
    display: none;
  }

  .pagination {
    justify-content: center !important;
  }

  .main-content .container-fluid {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .auth-header,
  .auth-body-inner {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}
