/* ACHAT — base styles (shared UI kit, app_welcome). Bump ?v= in base.html after edits. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1c2430;
  --muted: #6b7686;
  --border: #dde3ea;
  --accent: #1f5fae;
  --accent-600: #184d8f;
  --accent-50: #e8f0fb;
  --navy: #1f3a5f;
  --success: #1f8a4c;
  --warning: #b86e00;
  --danger: #c0392b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --navbar-h: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 600; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
[x-cloak] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.yes { color: var(--success); }
.nowrap { white-space: nowrap; }

/* --- navbar ------------------------------------------------------------------ */
.navbar { position: sticky; top: 0; z-index: 50; height: var(--navbar-h); display: flex; align-items: center;
  gap: 1rem; padding: 0 1rem; background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.navbar-brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; letter-spacing: .06em; }
.navbar-brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  background: #fff; color: var(--navy); font-weight: 800; }
.navbar-links { display: flex; list-style: none; margin: 0; padding: 0; gap: .1rem; flex: 1; overflow-x: auto; }
.navbar-links a { display: flex; align-items: center; gap: .35rem; color: rgba(255,255,255,.82); padding: .4rem .6rem;
  border-radius: 6px; white-space: nowrap; }
.navbar-links a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.navbar-links a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #e74c3c;
  color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 18px; }
.navbar-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.3rem; cursor: pointer; }
.navbar-user { position: relative; margin-left: auto; }
.navbar-user-btn { display: flex; align-items: center; gap: .45rem; background: none; border: 0; color: #fff;
  cursor: pointer; font: inherit; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .35rem 0; z-index: 60; }
.dropdown a, .dropdown-logout { display: block; padding: .45rem .9rem; color: var(--text); width: 100%; text-align: left;
  background: none; border: 0; font: inherit; cursor: pointer; }
.dropdown a:hover, .dropdown-logout:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-header { padding: .45rem .9rem .6rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; font-size: .85rem; }
.dropdown-lang { padding: .35rem .9rem; border-top: 1px solid var(--border); margin-top: .3rem; }
.linklike { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.linklike.active { font-weight: 700; color: var(--text); }

/* --- layout -------------------------------------------------------------------- */
.main { padding: 1.25rem 1.5rem 3rem; max-width: 1800px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.narrow { max-width: 640px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 1rem; }
.layout-sidebar { display: grid; grid-template-columns: 240px 1fr; gap: 1rem; align-items: start; }
.side-nav { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .35rem 0; }
.side-nav a { padding: .45rem .9rem; color: var(--text); }
.side-nav a.active { background: var(--accent-50); color: var(--accent-600); font-weight: 600; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.settings-card { color: var(--text); }
.settings-card:hover { border-color: var(--accent); text-decoration: none; }
.placeholder { text-align: center; padding: 3rem 1rem; }

/* resizable panels (spec §16): <div class="resizable-layout"><div class="panel-left">…</div>
   <div class="resize-handle panel-handle"></div><div class="panel-right">…</div></div> */
.resizable-layout { display: flex; align-items: stretch; min-height: 60vh; }
.resizable-layout > .panel-left { width: 320px; min-width: 160px; overflow: auto; }
.resizable-layout > .panel-right { flex: 1; min-width: 0; overflow: auto; }
.panel-handle { width: 5px; cursor: col-resize; background: var(--border); flex: 0 0 5px; }
.panel-handle:hover, .panel-handle.active { background: var(--accent); }

/* --- KPIs / dashboard ----------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { display: flex; flex-direction: column; gap: .2rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem .9rem; color: var(--text); box-shadow: var(--shadow); }
a.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-warning { border-color: var(--warning); }
.progress { display: block; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: .3rem; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li { display: flex; justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.action-list li:last-child { border-bottom: 0; }
.count { font-weight: 700; font-variant-numeric: tabular-nums; }
.progress-row { display: grid; grid-template-columns: 170px 1fr; gap: .75rem; align-items: center; margin-bottom: .45rem; }
.stacked { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.seg { display: inline-block; height: 100%; }
.legend .seg { width: 10px; height: 10px; border-radius: 2px; margin: 0 .2rem 0 .6rem; vertical-align: middle; }
.seg-described { background: #b8c4d4; } .seg-sourced { background: #7aa7dc; } .seg-requested { background: #3f7fcf; }
.seg-quoted { background: #f0a53a; } .seg-awarded { background: #2e9d5b; }
.activity { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.activity li { padding: .3rem 0; border-bottom: 1px dashed var(--border); }

/* --- buttons / forms ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .45rem .85rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); }
.btn-danger, .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .25rem .55rem; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled], .htmx-request.btn { opacity: .6; cursor: progress; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=date],
input[type=url], select, textarea { font: inherit; padding: .42rem .55rem; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
form > div { margin-bottom: .75rem; }
form label { display: block; font-weight: 550; margin-bottom: .2rem; }
form .helptext { display: block; color: var(--muted); font-size: .8rem; }
.form-group { margin-bottom: .9rem; }
.form-group input { width: 100%; }
.modal form input:not([type=checkbox]):not([type=radio]), .modal form select, .modal form textarea,
.card form input[type=text], .card form input[type=email], .card form input[type=number], .card form input[type=url],
.card form select, .card form textarea { width: 100%; max-width: 560px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 1rem; }
.form-errors, .errorlist { background: #fdecea; border: 1px solid #f5c2bd; color: #962d22; border-radius: 6px;
  padding: .5rem .75rem; margin: 0 0 .75rem; list-style: none; }
.field-error { color: var(--danger); font-size: .85rem; margin: .25rem 0 0; }
.notice { padding: .35rem .7rem; border-radius: 6px; font-size: .85rem; }
.notice-warning { background: #fff4e0; color: #7a4a00; border: 1px solid #f3d19c; }
.notice-info { background: var(--accent-50); color: var(--accent-600); }

/* --- badges (status) -------------------------------------------------------------- */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 10px; font-size: .76rem; font-weight: 600;
  background: #eef1f5; color: #3d4a5c; white-space: nowrap; }
.badge-active, .badge-validated, .badge-auto_validated, .badge-awarded, .badge-answered, .badge-compliant,
.badge-done, .badge-ok, .badge-imported { background: #e3f4ea; color: #1b6e3d; }
.badge-on_hold, .badge-to_review, .badge-reminded, .badge-partial, .badge-sourcing, .badge-candidate,
.badge-waiting_import, .badge-clarification_requested { background: #fff2dc; color: #8a5300; }
.badge-closed, .badge-cancelled, .badge-declined, .badge-expired, .badge-rejected, .badge-non_compliant,
.badge-blacklisted, .badge-bounced, .badge-error, .badge-no_offer { background: #fde8e6; color: #9b2c20; }
.badge-sent, .badge-rfq_sent, .badge-quoted, .badge-running, .badge-scheduled, .badge-in_progress { background: var(--accent-50); color: var(--accent-600); }

/* --- auth ------------------------------------------------------------------------- */
.auth-page .main { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-wrapper { width: 100%; max-width: 400px; }
.auth-card { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 2rem; }
.auth-brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; letter-spacing: .08em; color: var(--navy); margin-bottom: 1rem; }
.auth-brand .brand-mark { background: var(--navy); color: #fff; }
.auth-card h1 { margin-bottom: 1rem; }

/* --- modal ------------------------------------------------------------------------ */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45); display: flex;
  align-items: flex-start; justify-content: center; padding: 6vh 1rem; overflow: auto; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); width: min(720px, 100%); }
.modal-sm { width: min(420px, 100%); }
.modal-lg { width: min(1100px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); }
.modal-body { padding: 1rem 1.1rem; max-height: 70vh; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .75rem 1.1rem; border-top: 1px solid var(--border); }
.modal-footer:empty { display: none; }

/* --- toasts ----------------------------------------------------------------------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast { min-width: 260px; max-width: 420px; padding: .7rem .95rem; border-radius: 8px; color: #fff;
  box-shadow: var(--shadow-lg); cursor: pointer; background: var(--navy); }
.toast-success { background: var(--success); }
.toast-warning { background: var(--warning); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

.change { display: inline-block; margin-right: .5rem; }

@media (max-width: 1100px) {
  .navbar-toggle { display: block; }
  .navbar-links { display: none; position: absolute; top: var(--navbar-h); left: 0; right: 0; flex-direction: column;
    background: var(--navy); padding: .5rem; }
  .navbar-links.open { display: flex; }
  .navbar-user-name { display: none; }
  .layout-sidebar { grid-template-columns: 1fr; }
  .main { padding: 1rem; }
}

/* Plain data tables (non-smart), shared by every app (integration) */
.simple-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.simple-table th, .simple-table td { padding: .3rem .45rem; border-bottom: 1px solid var(--border); text-align: left; }
.simple-table th.num, .simple-table td.num, .simple-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-note { border-left: 3px solid var(--border); padding: .2rem .6rem; margin: .5rem 0; }
