:root {
  --pf-ink: #171a1f;
  --pf-muted: #6c7480;
  --pf-border: #e2e7ed;
  --pf-surface: #ffffff;
  --pf-bg: #f5f7fa;
  --pf-brand: #0b8f50;
  --pf-brand-dark: #087342;
  --pf-brand-soft: #edf8f2;
  --pf-danger: #d72f2f;
  --pf-gold: #d8a400;
  --pf-radius: 16px;
  --pf-radius-sm: 10px;
  --pf-shadow: 0 10px 28px rgba(26, 35, 45, .07);
  --pf-shadow-hover: 0 16px 36px rgba(26, 35, 45, .11);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--pf-ink);
  background: var(--pf-bg);
  line-height: 1.5;
}

.app-main { padding: 1.5rem 1rem 2.5rem; }
.content-container { width: min(100%, 1680px); margin-inline: auto; }

/* Navigation */
.app-navbar {
  min-height: 70px;
  background: rgba(23, 26, 31, .98) !important;
  box-shadow: 0 6px 22px rgba(15, 19, 24, .16);
}
.app-navbar .container-fluid { width: min(100%, 1800px); margin-inline: auto; }
.app-navbar .navbar-brand { min-width: 180px; }
.app-navbar .navbar-nav { align-items: center; gap: .15rem; }
.app-navbar .nav-link {
  color: rgba(255,255,255,.78) !important;
  border-radius: 9px;
  padding: .55rem .72rem !important;
  font-weight: 600;
  font-size: .93rem;
  transition: background-color .18s ease, color .18s ease, transform .18s ease;
}
.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .nav-link.active {
  color: #fff !important;
  background: rgba(255,255,255,.10);
}
.app-navbar .dropdown-menu { border: 1px solid rgba(0,0,0,.06); border-radius: 12px; padding: .45rem; box-shadow: var(--pf-shadow-hover); }
.app-navbar .dropdown-item { border-radius: 8px; padding: .55rem .75rem; font-weight: 600; }
.app-navbar .dropdown-item:hover { background: var(--pf-brand-soft); color: var(--pf-brand-dark); }
.brand-logo {
  height: 46px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 3px;
  display: block;
}
.brand-text { color: #fff; font-weight: 700; letter-spacing: -.01em; }

/* General page rhythm */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem !important;
}
.page-header h1,
.page-header h2,
.page-header h3 { margin-bottom: .2rem; letter-spacing: -.02em; }
.page-header .text-muted,
.page-header .muted { color: var(--pf-muted) !important; }
.page-header > div:last-child,
.page-header .page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

/* Surfaces/cards */
.card {
  border: 1px solid var(--pf-border);
  border-radius: var(--pf-radius);
  box-shadow: var(--pf-shadow);
  background: var(--pf-surface);
}
.card.shadow-sm { box-shadow: var(--pf-shadow) !important; }
.card-body { padding: 1.25rem; }
.card.p-3 { padding: 1.25rem !important; }
.card.p-4 { padding: 1.5rem !important; }
.dashboard-card { min-height: 128px; display: flex; flex-direction: column; justify-content: center; }
.dashboard-card .metric { margin-top: .25rem; }
.metric {
  font-size: 1.85rem;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn { border-radius: 10px; font-weight: 700; }
.btn-primary { background: var(--pf-brand); border-color: var(--pf-brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--pf-brand-dark); border-color: var(--pf-brand-dark); }
.btn-success { background: var(--pf-brand); border-color: var(--pf-brand); }
.btn-success:hover, .btn-success:focus { background: var(--pf-brand-dark); border-color: var(--pf-brand-dark); }
.btn-outline-primary { color: var(--pf-brand-dark); border-color: rgba(11,143,80,.45); }
.btn-outline-primary:hover { background: var(--pf-brand); border-color: var(--pf-brand); }
.btn-outline-dark:hover { background: var(--pf-ink); }

/* Forms */
.form-label { font-weight: 700; color: #313842; margin-bottom: .45rem; }
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="url"],
input[type="date"],
textarea {
  min-height: 44px;
  border: 1px solid #d8dee6;
  border-radius: var(--pf-radius-sm);
  box-shadow: none;
  padding: .6rem .78rem;
  color: var(--pf-ink);
  background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus {
  border-color: rgba(11,143,80,.6);
  box-shadow: 0 0 0 .2rem rgba(11,143,80,.11);
}
.form-check-input { min-height: 1rem; }
.form-text { color: var(--pf-muted); }
.form-control::placeholder { color: #9aa3ad; }
form p { margin-bottom: 1rem; }
form p label { display: block; font-weight: 700; margin-bottom: .45rem; }

/* Search toolbars */
.page-header form,
.search-toolbar form { margin: 0; }
.page-header input[name="q"] { min-width: 280px; }
.page-header .btn { white-space: nowrap; }

/* Tables */
.table-responsive {
  border: 1px solid var(--pf-border);
  border-radius: 12px;
  background: #fff;
}
.table {
  margin-bottom: 0;
  --bs-table-border-color: #edf0f3;
}
.table > :not(caption) > * > * {
  padding: .8rem .85rem;
  vertical-align: middle;
}
.table thead th {
  background: #f7f9fb;
  color: #5d6672;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .055em;
  font-weight: 800;
  white-space: nowrap;
  border-bottom: 1px solid var(--pf-border);
}
.table tbody tr:hover { background: #fbfcfd; }
.table tbody td { color: #2e3640; }
.table a { color: var(--pf-brand-dark); font-weight: 700; text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* Badges / status */
.badge { border-radius: 999px; padding: .42em .7em; font-weight: 800; letter-spacing: .01em; }

/* Dashboard */
.dashboard-card:nth-child(1) { border-top: 3px solid var(--pf-brand); }
.dashboard-card:nth-child(2) { border-top: 3px solid #53739b; }
.dashboard-card:nth-child(3) { border-top: 3px solid #d8a400; }
.dashboard-card:nth-child(4) { border-top: 3px solid #8d65ad; }

/* Marketplace */
.market-hero {
  border: 1px solid #dcece2;
  background: radial-gradient(circle at 90% 15%, rgba(11,143,80,.09), transparent 30%), linear-gradient(135deg, #fff, #eef8f1);
  box-shadow: var(--pf-shadow);
}
.marketplace-logo { max-height: 220px; width: 100%; object-fit: contain; }
.product-card {
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--pf-shadow-hover) !important; border-color: #d5e1d9; }
.product-card .card-body { display: flex; flex-direction: column; }
.product-card .product-name { line-height: 1.28; min-height: 2.55em; }
.product-card .product-price { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.product-thumb { height: 235px; width: 100%; object-fit: cover; background: #eef1f4; }
.product-placeholder { display: flex; align-items: center; justify-content: center; height: 235px; background: #eef1f4; color: #7d8791; font-weight: 800; }
.product-gallery { width: 100%; height: 520px; object-fit: contain; background: #fff; border-radius: 12px; }
.gallery-placeholder { height: 520px; }
.category-card, .shop-card { border: 1px solid var(--pf-border); box-shadow: var(--pf-shadow) !important; transition: transform .18s ease, box-shadow .18s ease; }
.category-card:hover, .shop-card:hover { transform: translateY(-3px); box-shadow: var(--pf-shadow-hover) !important; }
.shop-banner { width: 100%; height: 280px; object-fit: cover; }
.shop-logo { width: 88px; height: 88px; object-fit: contain; border-radius: 16px; border: 1px solid var(--pf-border); background: #fff; padding: 5px; }
.cart-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #f0f2f4; }

.recent-product-slide { position: relative; height: 410px; background: #111; }
.recent-product-slide img { width: 100%; height: 410px; object-fit: cover; }
.recent-product-caption {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 4rem 1.5rem 1.25rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.84));
}
.recent-product-empty { min-height: 410px; display: flex; align-items: center; justify-content: center; padding: 2rem; text-align: center; background: #e9ecef; color: #6c757d; font-weight: 700; }

/* Login / activation */
.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at top right, rgba(11,143,80,.10), transparent 28%), linear-gradient(135deg, #f4f7fb, #ffffff);
}
.login-card { border: 1px solid rgba(11,143,80,.10); box-shadow: 0 20px 55px rgba(26,35,45,.12) !important; }
.login-logo { max-width: 290px; max-height: 120px; object-fit: contain; }

/* Tom Select */
.ts-wrapper { width: 100%; }
.ts-control { min-height: 44px; border-radius: var(--pf-radius-sm) !important; border-color: #d8dee6 !important; padding: .55rem .78rem !important; box-shadow: none !important; }
.ts-wrapper.focus .ts-control { border-color: rgba(11,143,80,.6) !important; box-shadow: 0 0 0 .2rem rgba(11,143,80,.11) !important; }
.ts-dropdown { border-radius: 12px; border-color: #dce2e8; box-shadow: var(--pf-shadow-hover); overflow: hidden; }

/* Calendar */
.date-picker-wrap { position: relative; display: flex; align-items: stretch; }
.date-picker-wrap .date-input { padding-right: 3.25rem; }
.date-picker-button { position: absolute; right: 0; top: 0; height: 100%; width: 2.9rem; border: 0; background: transparent; color: #495057; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 3; }
.date-picker-button:hover { background: rgba(0,0,0,.04); }
.date-picker-button:disabled { cursor: not-allowed; opacity: .5; }
.pf-calendar-popup { position: absolute; z-index: 3000; width: 294px; background: #fff; border: 1px solid rgba(0,0,0,.16); border-radius: .75rem; box-shadow: 0 .75rem 2rem rgba(0,0,0,.18); padding: .75rem; color: #212529; }
.pf-calendar-popup[hidden] { display: none !important; }
.pf-calendar-header { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: .25rem; margin-bottom: .5rem; }
.pf-calendar-nav, .pf-calendar-title { border: 0; background: transparent; border-radius: .5rem; }
.pf-calendar-nav { font-size: 1.5rem; height: 36px; line-height: 1; cursor: pointer; }
.pf-calendar-nav:hover, .pf-calendar-title:hover { background: #f1f3f5; }
.pf-calendar-title { font-weight: 700; height: 36px; cursor: pointer; }
.pf-calendar-weekdays, .pf-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.pf-calendar-weekdays { font-size: .75rem; color: #6c757d; text-align: center; margin-bottom: 2px; }
.pf-calendar-day { min-height: 34px; border: 0; background: #fff; border-radius: .5rem; cursor: pointer; }
.pf-calendar-day:hover { background: #e9ecef; }
.pf-calendar-day.selected { background: var(--pf-brand); color: #fff; font-weight: 800; }
.pf-calendar-day.today { outline: 2px solid #adb5bd; outline-offset: -2px; }
.pf-calendar-day.empty { cursor: default; background: transparent; }
.pf-calendar-footer { display: flex; justify-content: space-between; gap: .5rem; margin-top: .65rem; padding-top: .65rem; border-top: 1px solid #dee2e6; }

/* Print reports */
.print-only { display: none !important; }
.report-toolbar { min-height: 1px; }
.print-report-header { border-bottom: 2px solid #212529; padding-bottom: 10px; margin-bottom: 16px; }
.print-report-brand { display: flex; align-items: center; gap: 14px; }
.print-report-logo { height: 48px; width: auto; object-fit: contain; background: #fff; }
.print-report-org { font-size: 14pt; font-weight: 700; letter-spacing: .02em; }
.print-report-app { font-size: 11pt; font-weight: 600; }
.print-report-title { font-size: 16pt; font-weight: 700; margin-top: 2px; }
.print-report-generated { font-size: 9pt; color: #6c757d; margin-top: 2px; }


/* Form alignment */
.app-form-card { overflow: hidden; }
.app-form-card .card-header { border-bottom: 1px solid var(--pf-border) !important; }
.management-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.05rem 1.25rem; align-items: start; }
.form-field-block { min-width: 0; margin: 0; }
.form-field-block:has(textarea),
.form-field-block:has(input[type="file"]),
.form-field-block:has(.form-check),
.form-field-block:has(.django-ckeditor-widget) { grid-column: 1 / -1; }
.form-field-block .form-check { padding-top: .4rem; }
.form-actions { display: flex; align-items: center; justify-content: flex-start; padding-top: .35rem; }

/* Consistent headings and dividers */
main h1, main h2, main h3, main h4 { color: var(--pf-ink); }
main h2.h5 { font-weight: 800; }
hr { border-color: var(--pf-border); opacity: 1; }
.app-footer { color: #7a838e; border-top: 1px solid var(--pf-border); margin-top: 2rem; padding: 1.25rem 0; font-size: .82rem; }

/* Responsive alignment */
@media (max-width: 1199.98px) {
  .app-navbar .navbar-nav { align-items: stretch; }
  .app-navbar .navbar-brand { min-width: 0; }
  .page-header input[name="q"] { min-width: 220px; }
}
@media (max-width: 767.98px) {
  .management-form { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }
  .app-main { padding-inline: .75rem; }
  .page-header { align-items: stretch; }
  .page-header > div:last-child, .page-header .page-actions { justify-content: flex-start; }
  .page-header form { width: 100%; display: flex !important; }
  .page-header input[name="q"] { min-width: 0; flex: 1 1 auto; }
  .page-header .btn { flex: 0 0 auto; }
  .card-body { padding: 1rem; }
  .recent-product-slide, .recent-product-slide img, .recent-product-empty { height: 320px; min-height: 320px; }
  .shop-banner { height: 210px; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  html, body { background: #fff !important; color: #000 !important; }
  body { font-size: 10pt; }
  .app-navbar, .print-hide, .alert, .dropdown-menu, .modal, .toast, .btn-close { display: none !important; }
  .print-only { display: block !important; }
  .app-main { padding: 0 !important; margin: 0 !important; }
  .card, .dashboard-card { border: 1px solid #adb5bd !important; box-shadow: none !important; break-inside: avoid; }
  .table-responsive { overflow: visible !important; border: 0 !important; }
  table { width: 100% !important; border-collapse: collapse !important; }
  table thead { display: table-header-group; }
  table tfoot { display: table-footer-group; }
  th, td { border: 1px solid #adb5bd !important; padding: .32rem .42rem !important; vertical-align: top !important; }
  tr { break-inside: avoid; }
  a { color: #000 !important; text-decoration: none !important; }
  .page-header { margin-bottom: .75rem !important; }
  .page-header .btn, .page-header form { display: none !important; }
  input, select, textarea { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 0 !important; color: #000 !important; }
  .money-input { text-align: right !important; }
  .pf-calendar-popup { display: none !important; }
  .report-toolbar { display: none !important; }
  .text-muted, .muted, .small { color: #495057 !important; }
}

/* Navigation wrapping and management usability */
.marketplace-nav .navbar-nav,
.management-nav .navbar-nav { flex-wrap: wrap; }
.management-nav .navbar-nav { gap: .15rem; }
@media (max-width: 991.98px) {
  .marketplace-nav .navbar-nav,
  .management-nav .navbar-nav { align-items: stretch; }
}

/* Detail pages */
dl.row { row-gap: .55rem; }
dl.row dt { color: #69737f; font-weight: 700; }
dl.row dd { font-weight: 600; }
