:root {
  --primary-color: #1c4a8d;
  --primary-color-dark: #143569;
  --accent-color: #35c1cf;
  --text-color: #1f2341;
  --muted-color: #6c738d;
  --bg-soft: #f4f6fb;
  --card-bg: #ffffff;
  --shadow-elevated: 0 18px 45px rgba(28, 74, 141, 0.15);
  --sidebar-width: 250px;
  --sidebar-bg: #1f2a56;
  --sidebar-border: rgba(255, 255, 255, 0.08);
}

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-soft);
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.app-body {
  background: var(--bg-soft);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  gap: 1.5rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-sub {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-nav .nav-item {
  padding: 0.65rem 0.85rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-nav .nav-item.active,
.sidebar-nav .nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-nav .nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  box-shadow: 0 10px 30px rgba(12, 21, 47, 0.06);
  padding: 1.2rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.content {
  flex: 1;
  padding: 2rem 2.5rem;
  background: var(--bg-soft);
}

main {
  flex: 1;
}

/* Navigation */
.navbar {
  background: var(--card-bg);
  box-shadow: 0 6px 16px rgba(23, 44, 86, 0.08);
}

.navbar .navbar-brand {
  font-weight: 700;
  font-size: 1.35rem;
  color: var(--primary-color) !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar .nav-link {
  color: var(--muted-color) !important;
  font-weight: 500;
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
  transition: all 0.2s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus,
.navbar .nav-link.active {
  color: var(--primary-color) !important;
  background: rgba(28, 74, 141, 0.08);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border: none;
  box-shadow: 0 12px 24px rgba(28, 74, 141, 0.25);
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--primary-color-dark), var(--accent-color));
}

.btn-outline-primary {
  color: var(--primary-color);
  border-color: rgba(28, 74, 141, 0.4);
}

.btn-outline-primary:hover {
  color: #fff;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* Cards & Tables */
.card {
  border: none;
  border-radius: 1.25rem;
  box-shadow: 0 12px 32px rgba(23, 44, 86, 0.08);
  background: var(--card-bg);
}

.table {
  margin-bottom: 0;
  color: var(--text-color);
}

.table thead {
  background: rgba(28, 74, 141, 0.08);
  color: var(--primary-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.table tbody tr {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.table tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 18px rgba(23, 44, 86, 0.08);
}

.badge {
  font-weight: 600;
}

/* Page headers */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.35rem 0;
  color: var(--primary-color);
}

.page-header p {
  margin: 0;
  color: var(--muted-color);
}

.page-title-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.product-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.product-name {
  font-weight: 600;
  color: var(--text-color);
}

.product-code {
  min-width: 80px;
  padding: 0.25rem 0.6rem;
  border-radius: 0.65rem;
  background: rgba(28, 74, 141, 0.1);
  color: var(--primary-color);
  font-weight: 600;
  text-align: center;
  font-size: 0.85rem;
}

/* Forms */
.form-label {
  font-weight: 600;
  color: var(--text-color);
}

.form-control,
.form-select {
  border-radius: 0.75rem;
  border: 1px solid rgba(23, 44, 86, 0.18);
  padding: 0.75rem 0.95rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(28, 74, 141, 0.15);
}

/* Authentication layout */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #152041 0%, #1c4a8d 40%, #35c1cf 100%);
  position: relative;
}

.auth-overlay {
  position: absolute;
  inset: 0;
  background: url('https://images.unsplash.com/photo-1521791136064-7986c2920216?auto=format&fit=crop&w=1600&q=80') center/cover no-repeat;
  opacity: 0.12;
  mix-blend-mode: lighten;
}

.auth-container {
  position: relative;
  z-index: 2;
}

.auth-brand .brand-badge {
  width: 70px;
  height: 70px;
  margin: 0 auto;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  color: #fff;
  font-weight: 700;
  font-size: 1.3rem;
}

.auth-brand .brand-title {
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.auth-brand .brand-subtitle {
  color: rgba(255, 255, 255, 0.75);
  margin: 0;
}

.auth-card {
  border-radius: 1.5rem;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.95);
}

.auth-card h1,
.auth-card h2,
.auth-card h3 {
  color: var(--primary-color);
  font-weight: 700;
}

.auth-footer {
  font-size: 0.85rem;
}

/* Utility */
.shadow-lg {
  box-shadow: var(--shadow-elevated) !important;
}

.table-responsive {
  border-radius: 1rem;
}

.alert {
  border-radius: 1rem;
  border: none;
  box-shadow: 0 10px 24px rgba(230, 86, 107, 0.15);
}

footer.footer {
  background: transparent;
  border: none;
  color: var(--muted-color);
  padding: 1.5rem 0;
  margin-top: auto;
}

footer.footer a {
  color: var(--primary-color);
}

.thumb {
  border-radius: 0.75rem;
  overflow: hidden;
  display: inline-block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumb:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 24px rgba(23, 44, 86, 0.18);
}

.thumb img {
  display: block;
}

.search-form .input-group {
  background: #fff;
  border-radius: 0.9rem;
  box-shadow: 0 12px 30px rgba(23, 44, 86, 0.12);
  overflow: hidden;
  align-items: stretch;
  gap: 0;
}

.search-form .input-group.page-size-group .form-select {
  max-width: 90px;
  border: none;
  border-left: 1px solid rgba(23, 44, 86, 0.08);
  border-radius: 0;
}

.search-form .input-group .btn-outline-secondary {
  border: none;
  border-left: 1px solid rgba(23, 44, 86, 0.08);
}

.search-form .form-control {
  border: none;
  padding: 0.85rem 1.1rem;
  min-width: 240px;
}

.search-form .form-control:focus {
  box-shadow: none;
}

.search-form .input-group-text {
  background: transparent;
  border: none;
}

.search-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px var(--muted-color);
  position: relative;
}

.search-icon::after {
  content: '';
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 8px;
  height: 2px;
  background: var(--muted-color);
  transform: rotate(45deg);
  border-radius: 2px;
}

.pagination-wrapper {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.pagination .page-link {
  color: var(--primary-color);
  border-radius: 0.65rem !important;
  margin: 0 0.15rem;
}

.pagination .page-item.active .page-link {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-color: transparent;
}

.pagination .page-item.disabled .page-link {
  color: var(--muted-color);
}

.topbar .navbar-nav {
  margin: 0;
}

/* Mobile Responsive */
@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    height: 100vh;
    z-index: 1050;
    transition: left 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.sidebar-open {
    left: 0;
  }

  .main-column {
    width: 100%;
  }

  .content {
    padding: 1rem;
  }

  .topbar {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title-row {
    width: 100%;
    flex-wrap: wrap;
  }

  .search-form .form-control {
    min-width: auto;
    flex: 1;
  }

  .search-form .input-group {
    flex-wrap: wrap;
  }

  .search-form .input-group.page-size-group .form-select {
    max-width: 100%;
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(23, 44, 86, 0.08);
  }

  .table-responsive {
    font-size: 0.875rem;
  }

  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .card-body {
    padding: 1rem !important;
  }

  .product-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .product-code {
    min-width: auto;
  }
}

@media (max-width: 576px) {
  .auth-brand .brand-title {
    font-size: 1.6rem;
  }

  .auth-card {
    border-radius: 1.1rem;
  }

  .content {
    padding: 0.75rem;
  }

  .topbar {
    padding: 0.75rem;
    flex-wrap: wrap;
  }

  .topbar-title {
    font-size: 1rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .btn-lg {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .table {
    font-size: 0.8rem;
  }

  .table thead {
    display: none;
  }

  .table tbody tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid rgba(23, 44, 86, 0.1);
    border-radius: 0.75rem;
    padding: 1rem;
    background: #fff;
  }

  .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border: none;
    text-align: right;
  }

  .table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--primary-color);
    text-align: left;
    margin-right: 1rem;
  }

  .table tbody td:last-child {
    border-top: 1px solid rgba(23, 44, 86, 0.1);
    padding-top: 1rem;
    margin-top: 0.5rem;
  }

  .pagination-wrapper {
    justify-content: center;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .form-select[multiple] {
    min-height: 120px;
  }

  .auth-brand .brand-title {
    font-size: 1.6rem;
  }

  .auth-card {
    border-radius: 1.1rem;
  }
}