@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap');

:root {
  --sd-blue-700: #0d3bff;
  --sd-blue-600: #1460ff;
  --sd-blue-500: #1f74ff;
  --sd-blue-200: #cfe0ff;
  --sd-ink: #0f172a;
  --sd-muted: #64748b;
  --sd-bg: #f4f7fb;
  --sd-card: #ffffff;
  --sd-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  --sd-radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 15% 10%, #e8f0ff 0%, #f4f7fb 45%, #eef3ff 100%);
  color: var(--sd-ink);
}

.auth-body {
  background: radial-gradient(circle at 10% 10%, #1f74ff 0%, #0f4dbf 45%, #0a2f7a 100%);
  color: #0f172a;
}

.app-body {
  background: radial-gradient(circle at 15% 10%, #e8f0ff 0%, #f4f7fb 45%, #eef3ff 100%);
  color: var(--sd-ink);
}

.navbar-sd {
  background: linear-gradient(100deg, #0b3dd9 0%, #145bff 55%, #2b8bff 100%);
  box-shadow: 0 12px 30px rgba(13, 59, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.navbar-sd .navbar-brand {
  font-weight: 800;
  letter-spacing: 0.4px;
}

.navbar-sd .nav-link {
  color: rgba(255, 255, 255, 0.86);
  font-weight: 600;
  position: relative;
}

.navbar-sd .nav-link:hover,
.navbar-sd .nav-link:focus {
  color: #fff;
}

.navbar-sd .nav-link::after {
  content: '';
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.35rem;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}

.navbar-sd .nav-link:hover::after,
.navbar-sd .nav-link:focus::after {
  transform: scaleX(1);
}

.navbar-sd .dropdown-menu {
  border: none;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 0.5rem;
}

.navbar-sd .dropdown-item {
  border-radius: 10px;
  font-weight: 600;
}

.navbar-sd .dropdown-item:hover,
.navbar-sd .dropdown-item:focus {
  background: rgba(20, 96, 255, 0.12);
  color: #0b3dd9;
}

.brand-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 700;
  letter-spacing: 0.4px;
}

.page-shell {
  padding: 1.5rem 0 3rem;
}

.card-sd {
  background: var(--sd-card);
  border-radius: var(--sd-radius);
  border: none;
  box-shadow: var(--sd-shadow);
  overflow: visible !important;
}

.card-sd .card-body {
  padding: 2rem;
}

.btn-sd {
  background: linear-gradient(120deg, var(--sd-blue-600), var(--sd-blue-500));
  border: none;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(20, 96, 255, 0.35);
}

.btn-sd:hover,
.btn-sd:focus {
  background: linear-gradient(120deg, var(--sd-blue-700), var(--sd-blue-600));
  color: #fff;
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
}

.auth-shell {
  width: min(980px, 100%);
}

.auth-card-lg {
  display: grid;
  grid-template-columns: 1fr;
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(7, 20, 45, 0.35);
}

.auth-left {
  background: linear-gradient(135deg, #0b4aa8 0%, #0d3bff 55%, #2d8bff 100%);
  color: #fff;
  padding: 2.5rem 2.75rem;
  position: relative;
}

.auth-left::after {
  content: '';
  position: absolute;
  width: 240px;
  height: 240px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  right: -80px;
  top: -60px;
}

.auth-right {
  padding: 2.5rem 2.75rem;
  background: #ffffff;
}

.auth-badges {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.auth-logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.auth-brand {
  font-weight: 700;
  letter-spacing: 0.4px;
}

.auth-subbrand {
  font-size: 0.9rem;
  opacity: 0.8;
}

.auth-left h1 {
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.auth-left p {
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 1.5rem;
}

.auth-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem 0;
}

.auth-list li {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
  position: relative;
}

.auth-list li::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #cfe0ff;
  position: absolute;
  left: 0;
  top: 0.5rem;
}

.auth-icons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.auth-icons span {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.form-control,
.form-select {
  border-radius: 12px;
  border: 1px solid #d5deee;
  padding: 0.65rem 0.9rem;
}

.form-label {
  font-weight: 600;
}

.text-muted-sd {
  color: var(--sd-muted);
}

.stat-card {
  border-radius: 16px;
  border: 1px solid #e3ebf8;
  padding: 1.25rem 1.5rem;
  background: #ffffff;
}

.stat-title {
  font-size: 0.9rem;
  color: var(--sd-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  max-height: 220px;
  overflow: auto;
}

.search-dropdown .list-group-item {
  white-space: normal;
  line-height: 1.35;
}

.app-shell {
  display: grid;
  gap: 2rem;
}

.app-side {
  display: none;
}

.app-side-card {
  background: linear-gradient(135deg, #0b4aa8 0%, #0d3bff 55%, #2d8bff 100%);
  color: #fff;
  border-radius: 22px;
  padding: 2rem;
  box-shadow: 0 18px 40px rgba(7, 20, 45, 0.25);
  position: sticky;
  top: 1.5rem;
}

.app-side-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  margin-bottom: 1rem;
}

.app-side-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.app-side-subtitle {
  opacity: 0.8;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.app-side-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.app-side-list li {
  margin-bottom: 0.7rem;
  padding-left: 1.4rem;
  position: relative;
}

.app-side-list li::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #cfe0ff;
  position: absolute;
  left: 0;
  top: 0.5rem;
}

.app-side-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.app-side-tags span {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.35);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

@media (min-width: 992px) {
  .auth-card-lg {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .app-shell {
    grid-template-columns: 280px 1fr;
    align-items: start;
  }

  .app-side {
    display: block;
  }
}

.stat-card--primary {
  background: linear-gradient(135deg, #0b4aa8 0%, #0d3bff 55%, #2d8bff 100%);
  color: #fff;
  border: none;
}

.stat-card--primary .stat-title,
.stat-card--primary .text-muted-sd {
  color: rgba(255, 255, 255, 0.75);
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: end;
  height: 200px;
  padding-top: 0.5rem;
}

.trend-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.trend-bar .bar-fill {
  width: 100%;
  max-width: 26px;
  min-height: 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #0d3bff 0%, #7fb2ff 100%);
  box-shadow: 0 8px 18px rgba(13, 59, 255, 0.25);
}

.trend-bar .bar-label {
  font-size: 0.75rem;
  color: var(--sd-muted);
}

.donut {
  --value: 0;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: conic-gradient(var(--sd-blue-600) calc(var(--value) * 1%), #e5edff 0);
  position: relative;
  display: grid;
  place-items: center;
}

.donut::after {
  content: '';
  position: absolute;
  inset: 18%;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px #e3ebf8;
}

.donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
}

.donut-title {
  font-size: 0.8rem;
  color: var(--sd-muted);
}

.donut-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.donut-sub {
  font-size: 0.75rem;
  color: var(--sd-muted);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--sd-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot--paid {
  background: var(--sd-blue-600);
}

.legend-dot--outstanding {
  background: #e5edff;
  border: 1px solid #cfe0ff;
}

@media (max-width: 768px) {
  .trend-chart {
    height: 160px;
  }

  .donut {
    width: 190px;
    height: 190px;
  }

  .table#preorder-lines,
  .table#invoice-lines,
  .table#purchase-lines {
    display: block !important;
    width: 100% !important;
    table-layout: auto !important;
  }

  .table#preorder-lines thead,
  .table#invoice-lines thead,
  .table#purchase-lines thead {
    display: none !important;
  }

  .table#preorder-lines tbody,
  .table#invoice-lines tbody,
  .table#purchase-lines tbody {
    display: block !important;
    width: 100% !important;
  }

  .table-responsive {
    overflow-x: visible !important;
  }

  .table#preorder-lines tbody tr,
  .table#invoice-lines tbody tr,
  .table#purchase-lines tbody tr {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-areas:
      "item item"
      "qty cost"
      "price subtotal"
      "action action" !important;
    gap: 0.6rem !important;
    width: 100% !important;
    padding: 0.9rem 0 !important;
    border-bottom: 1px solid #e3ebf8 !important;
  }

  .table#preorder-lines tbody td,
  .table#invoice-lines tbody td,
  .table#purchase-lines tbody td {
    display: block !important;
    width: 100% !important;
    padding: 0 !important;
    border: none !important;
    text-align: left !important;
  }

  .table#preorder-lines tbody td:nth-child(1),
  .table#invoice-lines tbody td:nth-child(1),
  .table#purchase-lines tbody td:nth-child(1) {
    grid-area: item !important;
  }

  .table#preorder-lines tbody td:nth-child(2),
  .table#invoice-lines tbody td:nth-child(2),
  .table#purchase-lines tbody td:nth-child(2) {
    grid-area: qty !important;
  }

  .table#preorder-lines tbody td:nth-child(3),
  .table#invoice-lines tbody td:nth-child(3),
  .table#purchase-lines tbody td:nth-child(3) {
    grid-area: cost !important;
  }

  .table#preorder-lines tbody td:nth-child(4),
  .table#invoice-lines tbody td:nth-child(4),
  .table#purchase-lines tbody td:nth-child(4) {
    grid-area: price !important;
  }

  .table#preorder-lines tbody td:nth-child(5),
  .table#invoice-lines tbody td:nth-child(5),
  .table#purchase-lines tbody td:nth-child(5) {
    grid-area: subtotal !important;
    text-align: right !important;
  }

  .table#preorder-lines tbody td:nth-child(6),
  .table#invoice-lines tbody td:nth-child(6),
  .table#purchase-lines tbody td:nth-child(6) {
    grid-area: action !important;
  }

  #preorder-lines tbody td:last-child,
  #invoice-lines tbody td:last-child,
  #purchase-lines tbody td:last-child {
    padding-bottom: 0;
  }

  .table#preorder-lines input,
  .table#invoice-lines input,
  .table#purchase-lines input,
  .table#preorder-lines .btn,
  .table#invoice-lines .btn,
  .table#purchase-lines .btn {
    width: 100% !important;
  }

  #preorder-lines .line-total,
  #invoice-lines .line-total,
  #purchase-lines .line-total {
    display: inline-block;
    font-weight: 600;
    font-size: 1rem;
  }
}

.table-responsive {
  overflow: visible !important;
}

#invoice-lines-wrapper, #preorder-lines-wrapper, #purchase-lines-wrapper {
  padding-bottom: 200px;
  margin-bottom: -200px;
}
