:root {
  --navy: #0f2a43;
  --navy-2: #173a5c;
  --blue: #0f6fde;
  --blue-light: #4db8ff;
  --bg: #f4f6f8;
  --text: #243342;
  --muted: #6b7a8c;
  --border: #dde4ec;
  --danger: #c0392b;
  --green: #1e8e4e;
}

* { box-sizing: border-box; }
/* Kill the mobile tap-highlight box and the native image drag-ghost that
   could flash as a dark rectangle when tapping/dragging links and icons. */
* { -webkit-tap-highlight-color: transparent; }
img { -webkit-user-drag: none; user-drag: none; }
:focus:not(:focus-visible) { outline: none; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { min-height: 70vh; padding: 32px 20px 56px; }
h1 { color: var(--navy); margin: 0.4em 0 0.6em; }
h2 { color: var(--navy); margin: 1.2em 0 0.5em; font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mt { margin-top: 16px; }
.center { text-align: center; }

/* Header */
.site-header { background: var(--navy); }
.nav-wrap { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; flex-wrap: wrap; gap: 10px; }
.brand { font-size: 1.5rem; font-weight: 800; color: #fff; }
.brand span { color: var(--blue-light); }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: #d7e3f0; font-weight: 500; }
.nav a:hover { color: #fff; text-decoration: none; }
.nav-cta { background: var(--blue); color: #fff !important; padding: 7px 14px; border-radius: 6px; }
.nav-admin { background: #6c3fb5; color: #fff !important; padding: 7px 14px; border-radius: 6px; }

/* Footer */
.site-footer { background: var(--navy); color: #9fb3c8; padding: 22px 0; font-size: 0.9rem; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.flash-success { background: #e2f5e9; color: var(--green); border: 1px solid #b8e6c9; }
.flash-error { background: #fdebe9; color: var(--danger); border: 1px solid #f5c6c0; }

/* Buttons */
.btn { display: inline-block; padding: 9px 18px; border-radius: 7px; border: 1px solid transparent;
  font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-outline { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 0.92rem; padding: 0; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.inline-form { display: inline; }

/* Hero / home */
.hero { text-align: center; padding: 56px 0 36px; }
.hero h1 { font-size: 2.4rem; line-height: 1.2; }
.hero p { max-width: 620px; margin: 0 auto 26px; color: var(--muted); font-size: 1.1rem; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; margin: 36px 0; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 22px; }
.card h3 { margin-top: 0; color: var(--navy); }
.how { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 26px 30px; margin-bottom: 24px; }
.steps li { margin-bottom: 8px; }
.service-detail { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px 26px; margin-bottom: 16px; }
.cta-row { margin: 28px 0; }

/* Forms */
label { display: block; margin: 14px 0 6px; font-weight: 600; color: var(--navy); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--text); margin-top: 4px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-light); border-color: var(--blue); }
fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 16px 0; padding: 12px 16px; }
legend { font-weight: 600; color: var(--navy); padding: 0 6px; }
.check { font-weight: 400; margin: 8px 0; }
.check input { width: auto; margin-right: 8px; }
.form-actions { margin-top: 20px; display: flex; gap: 12px; }
.code-input { font-size: 1.6rem; letter-spacing: 10px; text-align: center; }

/* Auth box */
.auth-box { max-width: 440px; margin: 30px auto; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 30px 34px; }
.auth-box .btn { margin-top: 18px; }

/* Panels & layout */
.panel { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 22px 26px; margin-bottom: 20px; }
.panel.empty { color: var(--muted); text-align: center; padding: 34px; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin: 10px 0 20px; }
.table th { background: var(--navy); color: #fff; text-align: left; padding: 10px 12px; font-size: 0.88rem; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 0.95rem; }
.table tr:last-child td { border-bottom: none; }
.table .empty { text-align: center; color: var(--muted); padding: 26px; }
.table .num { text-align: right; }
.table input { margin-top: 0; }
.actions { white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.badge-new { background: #e3f0ff; color: var(--blue); }
.badge-pending { background: #fff4d6; color: #9a6b00; }
.badge-in_progress { background: #ece3ff; color: #6c3fb5; }
.badge-completed, .badge-paid { background: #e2f5e9; color: var(--green); }
.badge-cancelled, .badge-void { background: #f1f3f5; color: var(--muted); }
.badge-draft { background: #f1f3f5; color: var(--muted); }
.badge-sent { background: #e3f0ff; color: var(--blue); }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0 28px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px;
  text-align: center; color: var(--muted); font-size: 0.9rem; }
.stat:hover { text-decoration: none; border-color: var(--blue); }
.stat-active { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue) inset; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--blue); }
.sort-active { color: var(--blue); }
/* Fixed-width arrow slot keeps every header the same size regardless of sort. */
.sort-arrow { display: inline-block; width: 1em; text-align: center; }
.sort-arrow-idle { opacity: 0.3; }
.visitor-table th { white-space: nowrap; }
.stat-num { display: block; font-size: 1.7rem; font-weight: 800; color: var(--navy); }

/* Detail list */
.detail-list { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.detail-list dt { font-weight: 700; color: var(--navy); }
.detail-list dd { margin: 0; }
.admin-note { background: #fffbe8; border: 1px solid #f0e2a0; border-radius: 6px; padding: 10px 12px; }

/* Type picker */
.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 20px 0; }
.type-card { background: #fff; border: 2px solid var(--border); border-radius: 10px; padding: 20px;
  text-align: center; font-weight: 700; color: var(--navy); }
.type-card:hover { border-color: var(--blue); text-decoration: none; }
.type-card.active { border-color: var(--blue); background: #eaf3ff; }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; margin: 14px 0; align-items: center; }
.filter-bar select { width: auto; margin-top: 0; }

/* Invoice sheet */
.invoice-sheet { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 38px 44px; }
.invoice-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 20px; }
.brand-lg { font-size: 1.9rem; font-weight: 800; color: var(--navy); }
.brand-lg span { color: var(--blue); }
.invoice-meta { text-align: right; }
.invoice-meta h2 { margin: 0; }
.total-row td { font-weight: 800; color: var(--navy); font-size: 1.05rem; background: #f0f5fb; }

@media print {
  .site-header, .site-footer, .no-print, .flash { display: none !important; }
  body, .main { background: #fff; padding: 0; }
  .invoice-sheet { border: none; padding: 0; }
}

/* Apps showcase — linear stack, one app per row */
.lead { font-size: 1.12rem; color: var(--muted); max-width: 62ch; margin: 0 0 8px; }
.app-list { display: flex; flex-direction: column; gap: 18px; max-width: 760px; margin: 36px 0; }
.app-card { display: flex; gap: 18px; align-items: flex-start; }
.app-card .app-icon { flex: 0 0 auto; }
.app-card .app-icon img { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 1px 4px rgba(15,42,67,0.15); display: block; }
.app-body { flex: 1; min-width: 0; }
.app-body > :first-child { margin-top: 0; }
.app-body > :last-child { margin-bottom: 0; }
.app-card h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.app-tagline { font-weight: 600; color: var(--navy); margin: 0 0 8px; }
.app-disclaimer { font-size: 0.82rem; }
.store-badges { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.store-badge { display: inline-flex; align-items: center; background: #000; color: #fff; border-radius: 9px; padding: 8px 16px; }
.store-badge:hover { text-decoration: none; filter: brightness(1.25); }
.store-badge-line small { display: block; font-size: 0.66rem; line-height: 1.1; opacity: 0.85; }
.store-badge-line strong { display: block; font-size: 0.98rem; line-height: 1.15; font-weight: 700; }
@media (max-width: 480px) { .app-card { flex-direction: column; } }

/* Apps manager: letter avatar shown when an app has no icon */
.app-icon-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 16px; background: #0f2a43; color: #fff; font-size: 2rem; font-weight: 700; }
.app-icon-placeholder-sm { width: 40px; height: 40px; border-radius: 9px; font-size: 1.1rem; }

/* Mobile navigation (hamburger) */
.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; flex-direction: column; gap: 5px; }
.nav-toggle span { display: block; width: 26px; height: 3px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-wrap.nav-open .nav-toggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-wrap.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-wrap.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: flex-start; gap: 4px; padding-top: 8px; }
  .nav-wrap.nav-open .nav { display: flex; }
  .nav a, .nav .nav-cta, .nav .nav-admin { display: block; width: 100%; padding: 10px 4px; }
  .nav-cta, .nav-admin { border-radius: 6px; padding-left: 12px; }
  .lang-switch { margin: 6px 0 0; }
  .engage-grid { grid-template-columns: 1fr; }
}

/* Star ratings — display + pure-CSS input (row-reverse so :checked lights all prior) */
.stars { display: inline-flex; letter-spacing: 1px; color: #e0a800; }
.stars .star { color: #e0a800; }
.review-avg { display: flex; align-items: center; gap: .5rem; }
.reviews-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.field-label { margin: 0 0 .2rem; font-weight: 600; }
.star-rating { display: inline-flex; align-items: center; gap: 2px; margin: 0 0 .8rem; }
.star-rating .star { background: none; border: 0; padding: 0 3px; font-size: 2rem; line-height: 1; color: #cfd6de; cursor: pointer; transition: color .1s; }
.star-rating .star.on { color: #e0a800; }
.star-rating .star:focus-visible { outline: 2px solid var(--blue); border-radius: 3px; }
.star-rating-value { margin-left: .5rem; }

/* App detail: engagement (comments + feature requests) */
.app-detail .app-icon-placeholder { width: 96px; height: 96px; font-size: 2.6rem; }
.app-more { font-weight: 600; }
.engage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
@media (max-width: 720px) { .engage-grid { grid-template-columns: 1fr; } }
.post { padding: .6rem 0; border-bottom: 1px solid rgba(128,128,128,.18); }
.post:last-of-type { border-bottom: 0; }
.post-meta { margin: 0 0 .2rem; font-size: .9rem; }
.post-form { margin-top: 1rem; padding-top: 1rem; border-top: 2px solid rgba(128,128,128,.18); }
.post-form h3 { margin: 0 0 .6rem; }

/* Language switcher (flag + EN | FR) */
.lang-switch { margin-left: .6rem; white-space: nowrap; }
.lang-switch a { padding: .15rem .4rem; font-size: .82rem; opacity: .6; display: inline-flex; align-items: center; gap: .3em; }
.lang-switch a.active { opacity: 1; font-weight: 700; text-decoration: underline; }
.lang-switch a + a { border-left: 1px solid rgba(255,255,255,.25); }
.lang-switch img { display: inline-block; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,.25); }

/* Contact page banner (managed at /admin/settings) */
.contact-banner { margin: 0 0 1.2rem; }
.contact-banner img { display: block; width: 100%; height: auto; border-radius: 12px; }
.banner-preview img { display: block; max-width: 480px; width: 100%; height: auto; border-radius: 8px; }

/* Drag-to-reorder tables (admin) */
.js-drag-rows tbody tr[draggable] { cursor: grab; }
.js-drag-rows tbody tr.dragging { opacity: .45; }
.drag-handle { color: #9aa7b5; user-select: none; width: 1.6em; text-align: center; }
.hidden-form { display: none; }

/* Admin settings page */
.radio-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.radio-row input[type="radio"] { margin-top: 4px; }

/* Moved out of inline style= attributes so the CSP can forbid inline styles */
#items-table .col-desc { width: 55%; }
.visitor-filter { margin: 1rem 0; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.visitor-filter .filter-search { flex: 1; min-width: 220px; }
