:root {
  --brand: #2f6b3a;
  --brand-dark: #24552d;
  --brand-soft: #eef5ec;
  --brand-line: #d7e6d3;
  --accent: #e8743b;
  --accent-soft: #fdeee5;
  --danger-soft: #fdecec;
  --info-soft: #e8f0fd;
  --ink: #1f2a22;
  --muted: #6b7570;
  --card-radius: 14px;
  --shadow: 0 4px 18px rgba(31, 42, 34, 0.06);
  --bs-body-color: var(--ink);
  --bs-body-font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --bs-link-color: var(--brand);
  --bs-link-color-rgb: 47, 107, 58;
  --bs-link-hover-color: var(--brand-dark);
  --bs-link-hover-color-rgb: 36, 85, 45;
  --bs-focus-ring-color: rgba(47, 107, 58, 0.25);
}

body { background: #f6f8f5; min-height: 100vh; display: flex; flex-direction: column; }
body.has-nav { padding-bottom: 72px; }
@media (min-width: 768px) { body.has-nav { padding-bottom: 0; } }
.app-main { flex: 1; }
.text-brand { color: var(--brand); }
.link-brand { color: var(--brand); text-decoration: none; font-weight: 500; }
.pre-line { white-space: pre-line; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* Buttons */
.btn-brand { --bs-btn-color: #fff; --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-disabled-bg: #8fb397; --bs-btn-disabled-border-color: #8fb397; font-weight: 500; }
.btn-outline-brand { --bs-btn-color: var(--ink); --bs-btn-border-color: #cfd8d1; --bs-btn-hover-color: var(--brand);
  --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-border-color: var(--brand); background: #fff; }
.btn-brand.htmx-request, .btn.htmx-request { opacity: .65; pointer-events: none; }

/* Header */
.app-header { background: #fff; border-bottom: 1px solid #e9eee8; height: 64px; display: flex; align-items: center; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand-name { font-weight: 700; font-size: .82rem; line-height: 1.05; }
.main-nav { gap: 1.75rem; }
.main-nav a { color: var(--ink); text-decoration: none; font-size: .92rem; position: relative; padding: 1.3rem 0; }
.main-nav a.active { color: var(--brand); font-weight: 600; }
.main-nav a.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 3px; background: var(--brand); }
.nav-badge { position: absolute; top: .55rem; right: -1rem; background: #d93025; color: #fff; border-radius: 999px; font-size: .65rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.icon-btn { position: relative; border: 0; background: none; color: var(--ink); font-size: 1.25rem; padding: .25rem; }
.icon-btn .nav-badge { top: -.2rem; right: -.45rem; }
.user-chip { align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); }
.user-chip .bi { font-size: 1.5rem; color: #b9c3bc; }

/* Bottom navigation (mobile) */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 64px; background: #fff; border-top: 1px solid #e3e9e2; display: flex; z-index: 30; }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: .68rem; position: relative; }
.bottom-nav a .bi { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--brand); font-weight: 600; }
.bottom-nav .nav-badge { top: .35rem; right: calc(50% - 1.4rem); }

/* Hero */
.hero { background: linear-gradient(100deg, #fff 40%, rgba(255, 255, 255, .55) 62%, rgba(255, 255, 255, 0) 80%), url('/static/img/hero.jpg') right center / auto 100% no-repeat, var(--brand-soft); padding: 2.2rem 0 4.5rem; }
@media (max-width: 767.98px) { .hero { background: linear-gradient(90deg, #fff 55%, rgba(255, 255, 255, .7)), url('/static/img/hero.jpg') right center / cover no-repeat; } }
.hero h1 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; }
.hero-sm { padding-bottom: 4.5rem; }
.lead-muted { color: var(--muted); max-width: 32rem; margin: .5rem 0 0; }
.stat-row { margin-top: -3rem; }

/* Cards */
.card-soft { background: #fff; border-radius: var(--card-radius); box-shadow: var(--shadow); border: 1px solid #eef1ed; }
.stat-card { background: #fff; border-radius: var(--card-radius); box-shadow: var(--shadow); padding: 1.1rem; display: flex; gap: .9rem; text-decoration: none; color: var(--ink); height: 100%; border: 1px solid #eef1ed; }
.stat-card:hover { border-color: var(--brand-line); }
.stat-icon { width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex: none; position: relative; }
.stat-icon .nav-badge { top: -4px; right: -6px; }
.icon-green { background: var(--brand-soft); color: var(--brand); }
.icon-orange { background: var(--accent-soft); color: var(--accent); }
.icon-red { background: var(--danger-soft); color: #d93025; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-title { font-weight: 600; font-size: .95rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.3; }
.stat-value small { font-size: .78rem; font-weight: 400; color: var(--muted); }
.stat-hint { font-size: .8rem; color: var(--muted); }
@media (max-width: 767.98px) {
  .stat-card { flex-direction: column; align-items: center; text-align: center; padding: .8rem .4rem; gap: .4rem; }
  .stat-title { font-size: .72rem; }
  .stat-value { font-size: 1.3rem; display: flex; flex-direction: column; }
  .stat-value small { font-size: .65rem; }
}
.section-title { font-size: 1.35rem; font-weight: 700; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.filter-search { flex: 1 1 260px; display: flex; align-items: center; gap: .5rem; background: #fff; border: 1px solid #dfe5de; border-radius: 10px; padding: 0 .9rem; min-height: 52px; }
.filter-search input { border: 0; outline: 0; flex: 1; background: transparent; }
.filter-select { flex: 0 1 170px; background: #fff; border: 1px solid #dfe5de; border-radius: 10px; padding: .35rem .75rem; display: flex; flex-direction: column; margin: 0; min-height: 52px; }
.filter-select span { font-size: .7rem; color: var(--muted); }
.filter-select select, .filter-select input { border: 0; outline: 0; background: transparent; padding: 0; font-size: .9rem; width: 100%; }
.filters-compact { margin-bottom: 0; }
.btn-reset { align-self: stretch; display: inline-flex; align-items: center; gap: .4rem; border-radius: 10px; background: #fff; }
@media (max-width: 767.98px) {
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
  .filter-search { grid-column: 1 / -1; min-height: 46px; }
  .filter-select { min-height: 46px; min-width: 0; }
  .btn-reset { justify-content: center; }
  .filters .filter-extra { display: none; }
  .filters.show-extra .filter-extra { display: flex; }
  .filters-toggle { border-radius: 10px; min-height: 46px; }
}
.card-title-link { color: var(--ink); text-decoration: none; }

/* Lot lists */
.lots-table thead th { background: #f4f6f3; font-size: .78rem; font-weight: 500; color: var(--muted); border: 0; padding: .8rem 1rem; }
.lots-table td { padding: .65rem 1rem; border-color: #f0f3ef; font-size: .9rem; }
.lots-table tbody tr:last-child td { border-bottom: 0; }
.lot-cell { display: flex; align-items: center; gap: .8rem; text-decoration: none; color: var(--ink); }
.lot-cell span { display: flex; flex-direction: column; }
.lot-cell small { color: var(--muted); font-size: .78rem; }
.lot-thumb { width: 52px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; }
.lot-thumb.lg { width: 76px; height: 64px; }
.lot-thumb.hero { width: 100%; height: 100%; min-height: 220px; border-radius: 12px; }
.placeholder-photo { background: linear-gradient(135deg, #e3eee0, #cfe2ca); display: flex; align-items: center; justify-content: center; color: #8cae86; font-size: 1.2rem; }
.lot-thumb.hero.placeholder-photo { font-size: 3rem; }
.lot-card-mobile { display: flex; gap: .8rem; align-items: center; background: #fff; border-radius: 12px; padding: .7rem; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.lot-card-mobile small { color: var(--muted); font-size: .78rem; }
.lot-card-mobile .bi { margin-right: .2rem; }

/* Status badges */
.status-badge { display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px; padding: .22rem .7rem; font-size: .76rem; font-weight: 500; white-space: nowrap; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge:has(.bi)::before { display: none; }
.badge-open { background: var(--brand-soft); color: var(--brand); }
.badge-soon { background: var(--info-soft); color: #2c63c9; }
.badge-warn { background: var(--accent-soft); color: #b8571f; }
.badge-red { background: var(--danger-soft); color: #c62828; }
.badge-muted { background: #eef0ee; color: var(--muted); }
.status-badge.floating { position: absolute; top: .8rem; left: .8rem; z-index: 2; background: #fff; box-shadow: var(--shadow); }

/* Lot card */
.lot-head { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: 1.2rem; }
@media (max-width: 767.98px) {
  .lot-head { grid-template-columns: 1fr; }
  .lot-thumb.hero { min-height: 0; height: 200px; }
  .lot-title { font-size: 1.35rem; }
  .breadcrumb a { text-decoration: none; }
}
.lot-photo { position: relative; }
.lot-title { font-size: 1.6rem; font-weight: 700; margin: .15rem 0; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; }
@media (max-width: 575.98px) { .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.info-grid > div { display: flex; gap: .55rem; align-items: flex-start; font-size: .9rem; font-weight: 500; }
.info-grid .bi { color: var(--brand); font-size: 1.15rem; margin-top: .15rem; }
.info-grid small { display: block; color: var(--muted); font-weight: 400; font-size: .75rem; }
.how-item { display: flex; gap: .7rem; margin-bottom: .9rem; }
.how-item .bi { color: var(--brand); font-size: 1.2rem; }
.how-item strong { display: block; font-size: .85rem; }
.how-item small { color: var(--muted); font-size: .75rem; line-height: 1.35; display: block; }
.doc-link { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid #f0f3ef; text-decoration: none; color: var(--ink); font-size: .85rem; }
.doc-link small { display: block; color: var(--muted); font-size: .72rem; }
.doc-link .bi:first-child { color: var(--brand); font-size: 1.2rem; }
.spec-list { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; font-size: .82rem; margin: .8rem 0 0; }
.spec-list dt { color: var(--muted); font-weight: 400; }
.spec-list dd { margin: 0; }

/* Bid panel */
.bid-panel { background: var(--brand-soft); border: 1px solid var(--brand-line); border-radius: var(--card-radius); padding: 1.2rem; }
.bid-state { display: grid; grid-template-columns: 1fr auto; gap: 1.2rem; align-items: start; padding-bottom: 1rem; border-bottom: 1px solid var(--brand-line); margin-bottom: 1rem; }
@media (max-width: 767.98px) { .bid-state { grid-template-columns: 1fr; } }
.timer-title { font-weight: 600; margin-bottom: .6rem; }
.timer-title .bi { color: var(--brand); margin-right: .3rem; }
.countdown { display: flex; align-items: center; gap: .45rem; }
.countdown > div { background: #fff; border-radius: 10px; padding: .45rem .3rem; min-width: 62px; text-align: center; box-shadow: var(--shadow); }
.countdown b { display: block; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.countdown small { font-size: .7rem; color: var(--muted); }
.countdown > span { font-weight: 700; color: var(--muted); }
.countdown.ending b { color: #c62828; }
.price-block { background: #fff; border-radius: 12px; padding: .9rem 1.1rem; min-width: 280px; }
.best-price { font-size: 2rem; font-weight: 700; display: flex; align-items: baseline; gap: .4rem; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.best-price small { font-size: 1rem; font-weight: 600; }
.pct-badge { font-size: .78rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .15rem .55rem; font-weight: 600; }
.leader-chip { margin-top: .6rem; font-size: .8rem; color: var(--muted); }
.leader-chip.is-leader { color: var(--brand); font-weight: 600; }
.bid-form-area { background: #fff; border-radius: 12px; padding: .9rem 1.1rem; }
.bid-form { display: grid; grid-template-columns: auto 1fr auto; gap: .5rem 1rem; align-items: center; }
@media (max-width: 767.98px) {
  .bid-form { grid-template-columns: 1fr; }
  .bid-form .btn { width: 100%; }
  .countdown > div { min-width: 0; flex: 1; }
  .price-block { min-width: 0; }
}
.bid-label { font-weight: 600; font-size: .9rem; }
.bid-input input { width: 100%; border: 1px solid #d5ddd4; border-radius: 10px; padding: .6rem .8rem; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.bid-input input:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.bid-input small { display: block; font-size: .72rem; margin-top: .2rem; }
.preview-line { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .85rem; background: #fff; border-radius: 10px; padding: .5rem .8rem; }
.bid-dialog { border: 0; border-radius: 16px; padding: 1.5rem; width: min(520px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.bid-dialog::backdrop { background: rgba(20, 30, 22, .45); }
.confirm-table th { font-weight: 400; color: var(--muted); }
.confirm-table td { text-align: right; }

/* Results */
.info-note { display: flex; gap: .8rem; background: #fff; border: 1px solid #e4ebe2; border-radius: 12px; padding: .9rem 1rem; font-size: .8rem; color: var(--muted); }
.info-note strong { color: var(--ink); }
.info-note .bi { color: var(--brand); font-size: 1.3rem; }

/* Staff area */
.role-chip { background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .1rem .55rem; font-size: .72rem; margin-left: .3rem; }
.copy-line { display: flex; gap: .4rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; padding: 1.4rem 0 1rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.sub-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.sub-tabs a { text-decoration: none; color: var(--ink); background: #fff; border: 1px solid #dfe5de; border-radius: 999px; padding: .3rem .85rem; font-size: .85rem; }
.sub-tabs a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.sub-tabs a .count { opacity: .7; margin-left: .25rem; }
.admin-table th { background: #f4f6f3; font-size: .78rem; font-weight: 500; color: var(--muted); }
.admin-table td { font-size: .88rem; vertical-align: middle; }
.section-card { background: #fff; border-radius: var(--card-radius); box-shadow: var(--shadow); border: 1px solid #eef1ed; padding: 1.1rem 1.2rem; }
.section-card > h2 { font-size: 1rem; font-weight: 600; margin-bottom: .9rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.inline-form .form-control, .inline-form .form-select { width: auto; flex: 1 1 160px; }
.form-label { font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; font-size: .88rem; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; }
.action-box summary { cursor: pointer; list-style: none; }
.action-box summary::-webkit-details-marker { display: none; }
.action-box[open] summary { margin-bottom: .6rem; }
.timeline div { border-left: 2px solid var(--brand-line); padding: 0 0 .6rem .8rem; font-size: .84rem; position: relative; }
.timeline div::before { content: ''; position: absolute; left: -5px; top: .35rem; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.protocol tr.invalid td { text-decoration: line-through; color: var(--muted); }
.protocol tr.best td { background: var(--brand-soft); font-weight: 600; }

/* Misc */
.empty-state { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty-state > .bi { font-size: 2.5rem; color: #b5c7b1; }
.notification.unread { border-left: 4px solid var(--brand); }
.feature-strip { background: #fff; border-top: 1px solid #e9eee8; margin-top: 3rem; padding: 1.2rem 0; }
.feature-strip .container-xl > div { display: flex; gap: .8rem; align-items: center; font-size: .85rem; }
.feature-strip .bi { font-size: 1.8rem; color: var(--brand); }
.feature-strip small { color: var(--muted); }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: linear-gradient(160deg, var(--brand-soft), #fff 60%); }
.auth-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); padding: 2rem; width: min(420px, 100%); }
.auth-card-wide { width: min(760px, 100%); }
.secret-box { background: var(--brand-soft); border-radius: 10px; padding: .6rem .8rem; }
.secret-box small { display: block; color: var(--muted); }
.secret-box code { font-size: 1rem; letter-spacing: .08em; color: var(--ink); word-break: break-all; }
.rules-box { background: #f6f8f5; border-radius: 10px; padding: .7rem .9rem; max-height: 280px; overflow: auto; }
.status-steps { display: grid; gap: .5rem; }
.status-steps div { color: var(--muted); }
.status-steps .current { color: var(--brand); font-weight: 600; }
.app-toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #2b2b2b; color: #fff; padding: .7rem 1.1rem; border-radius: 10px; font-size: .88rem; z-index: 100; max-width: 92vw; }
