/* ==========================================================================
   style.css — design tokens, base typography, app shell (sidebar / topbar), home page.
   Component styles (forms, tables, chips, modal ...) live in components.css.

   BRAND: these colours are a STAND-IN (bordeaux / brass / warm white). Exact venec.mk values could not
   be read from the build environment. To match the real brand, change ONLY the :root block below
   and drop the real logo into public/img/logo.svg (a light-on-dark version for the sidebar).
   ========================================================================== */

:root {
  --wine: #5b1a2c;
  --wine-dark: #431320;
  --wine-tint: #f4e9ec;
  --brass: #b08a4a;
  --brass-tint: #f6efe1;
  --bg: #ffffff;
  --surface: #ffffff;
  --tint: #f8f4ef;
  --ink: #2b2523;
  --muted: #6f6560;
  --line: #e4dcd2;
  --ok: #1f6b3a;
  --ok-tint: #e5f2e9;
  --warn: #8a5a00;
  --warn-tint: #fbf0d6;
  --danger: #9b2c2c;
  --danger-tint: #fbe9e9;

  --font-serif: Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 248px;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; color: var(--wine-dark); }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
a { color: var(--wine); }
img { max-width: 100%; height: auto; }

:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--wine); color: #fff; padding: 10px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.main { padding: 28px 36px 64px; max-width: 1180px; width: 100%; }

.topbar, .sidebar-backdrop { display: none; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--wine); color: #f3e7df;
  padding: 22px 14px 16px;
}
.brand { display: block; text-decoration: none; color: inherit; padding: 0 8px 18px; border-bottom: 1px solid rgba(255,255,255,.14); margin-bottom: 14px; }
.brand-logo { display: block; width: 150px; height: auto; }
.brand-sub { display: block; margin-top: 8px; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: #d9c3a0; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 16px 10px 6px; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: #cdb08a; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: #f3e7df; text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.1); }
.nav-link.active { background: #f8f1e8; color: var(--wine-dark); font-weight: 700; }

.sidebar-foot { margin-top: auto; padding-top: 18px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid rgba(255,255,255,.14); }
.whoami { display: flex; flex-direction: column; color: #fff; text-decoration: none; padding: 4px 8px; border-radius: 8px; }
.whoami:hover { background: rgba(255,255,255,.08); }
.whoami strong { font-size: .95rem; overflow-wrap: anywhere; }
.whoami span { font-size: .8rem; color: #d9c3a0; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn { width: 100%; }

.lang-pill { display: inline-flex; align-self: flex-start; margin-left: 8px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; overflow: hidden; }
.lang-pill a { display: inline-flex; align-items: center; padding: 0 16px; min-height: 44px; color: #f3e7df; text-decoration: none; font-size: .8rem; font-weight: 700; letter-spacing: .06em; }
.lang-pill a.active { background: #f8f1e8; color: var(--wine-dark); }

/* ---------- Page heading + flash ---------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: .25em; }
.page-lede, .lede { color: var(--muted); max-width: 70ch; margin: 0; }
.crumb { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin-bottom: 4px; text-decoration: none; font-weight: 600; }
.crumb .icon { width: 18px; height: 18px; }

.flash { padding: 12px 16px; margin: 0 0 18px; border-radius: 10px; border: 1px solid var(--line); border-left-width: 5px; background: var(--tint); }
.flash-success { background: var(--ok-tint); border-color: #b7dcc3; border-left-color: var(--ok); color: #164f2b; }
.flash-error { background: var(--danger-tint); border-color: #efc3c3; border-left-color: var(--danger); color: #7a2020; }

/* ---------- Home ---------- */
.home-hero { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.home-tagline { font-family: var(--font-serif); font-style: italic; font-size: 1.15rem; color: var(--brass); margin: 0 0 .5em; }
.tile-section { margin-bottom: 30px; }
.tile-section h2 { font-size: .85rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-family: var(--font-sans); font-weight: 700; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: inherit; min-height: 44px; }
.tile:hover { border-color: var(--brass); box-shadow: 0 2px 10px rgba(91,26,44,.08); }
.tile-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--wine-tint); color: var(--wine); }
.tile-body { display: flex; flex-direction: column; gap: 2px; }
.tile-title { font-family: var(--font-serif); font-weight: 600; font-size: 1.05rem; color: var(--wine-dark); }
.tile-desc { font-size: .9rem; color: var(--muted); }


/* ---------- Pre-login pages (login, 2FA, recovery codes) + error page ---------- */
body.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 16px; background: var(--wine); }
.auth-card { width: min(420px, 100%); padding: 28px 26px; border-radius: 16px; background: var(--surface); box-shadow: 0 20px 50px rgba(30, 12, 18, .35); }
.auth-brand { display: block; width: 170px; margin: 0 auto 18px; }
.auth-brand img { display: block; width: 100%; height: auto; }
.auth-card h1 { font-size: 1.5rem; text-align: center; }
.auth-lede { color: var(--muted); text-align: center; margin: 0 0 18px; }
.auth-card .field { margin-bottom: 14px; }
.auth-note { margin: 16px 0 0; font-size: .88rem; color: var(--muted); text-align: center; }
.auth-lang { align-self: center; margin: 0; }
.btn-block { width: 100%; margin-top: 6px; }
.auth-steps { margin: 0 0 16px; padding-left: 20px; color: var(--ink); font-size: .95rem; }
.auth-steps li { margin-bottom: 4px; }

.totp-qr { display: flex; justify-content: center; margin: 4px 0 14px; }
.totp-qr img { width: 200px; max-width: 70vw; height: auto; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.totp-secret { margin: 6px 0 16px; padding: 10px 12px; border-radius: 10px; background: var(--tint); border: 1px solid var(--line); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; letter-spacing: .08em; text-align: center; word-break: break-all; }
.totp-field { margin-bottom: 14px; }
.totp-field .label { display: block; margin-bottom: 6px; font-weight: 600; font-size: .92rem; }
.totp-digits { display: flex; gap: 8px; }
.totp-digits[hidden] { display: none; }
.totp-digit { width: 100%; min-width: 0; height: 52px; padding: 0; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.5rem; }
.totp-plain[hidden] { display: none; }
.link-btn { min-height: 44px; padding: 0; border: 0; background: none; color: var(--wine); font: inherit; font-size: .9rem; font-weight: 600; text-decoration: underline; cursor: pointer; }
.link-btn[hidden] { display: none; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 16px; padding: 0; list-style: none; counter-reset: rc; }
.recovery-codes li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tint); text-align: center; }
.recovery-codes code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; letter-spacing: .06em; }

.error-card { text-align: center; }
.error-code { margin: 0; font-family: var(--font-serif); font-size: 3.4rem; font-weight: 700; line-height: 1; color: var(--brass); }
.error-card .form-actions { justify-content: center; }

/* In-app cards: re-auth and My account */
.narrow-card { max-width: 520px; }
.narrow-card .field { margin-bottom: 14px; }
.pending { margin: 0 0 18px; padding: 12px 14px; border-radius: 10px; border: 1px solid #e6d6b4; border-left: 5px solid var(--brass); background: var(--brass-tint); }
.pending .label { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--muted); }
.pending-delete { border-color: #efc3c3; border-left-color: var(--danger); background: var(--danger-tint); }

@media print {
  body.auth { background: #fff; display: block; }
  .auth-card { box-shadow: none; }
  .auth-card form .check, .auth-card .form-actions { display: none !important; }
}

/* ---------- Mobile shell: top bar + drawer ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 18px 16px 56px; }
  h1 { font-size: 1.45rem; }

  .topbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 30; height: 56px; padding: 0 8px;
    background: var(--wine); color: #fff;
  }
  .sidebar-toggle { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer; }
  .sidebar-toggle:hover { background: rgba(255,255,255,.12); }
  .topbar-brand { display: flex; align-items: center; min-height: 44px; padding: 0 4px; }
  .topbar-logo { display: block; height: 28px; width: auto; }

  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(84vw, 300px); height: auto;
    transform: translateX(-102%); transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(30,12,18,.5); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

@media print {
  .sidebar, .topbar, .sidebar-backdrop, .no-print, .skip-link { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
}
