/* Magkraft brand theme + shared components.
   Colours from magkraftndt.com; layout from plan/reference-design.png.
   Modules should use these classes instead of writing their own CSS. */
:root {
  /* Brand */
  --gold: #a5761c;
  --gold-dark: #895f0e;
  --gold-soft: #f7f0e1;
  --gold-line: #ead9b5;
  --black: #000;
  --line: #424242;

  /* Surfaces */
  --sidebar: #0d0d0d;
  --sidebar-2: #171717;
  --sidebar-text: #b9b9b9;
  --bg: #f4f3ef;
  --card: #fff;
  --soft: #faf9f6;
  --border: #e7e4dc;
  --border-strong: #d6d2c7;

  /* Text */
  --text: #17171a;
  --muted: #6b6b70;
  --faint: #9a9aa0;

  /* Status: green = done, amber = pending, red = late / low stock */
  --green: #15803d;
  --green-soft: #e8f6ee;
  --amber: #f59e0b;
  --amber-text: #b45309;
  --amber-soft: #fff4de;
  --red: #dc2626;
  --red-soft: #fdecec;
  --blue: #2563eb;
  --blue-soft: #e8effd;
  --grey-soft: #efeeea;

  --font-head: "Bebas Neue", Impact, sans-serif;
  --font-body: "Urbanist", system-ui, sans-serif;
  --font-num: "Roboto", system-ui, sans-serif;

  /* Type scale. Bebas Neue is only for big titles (h1, hero, login, brand);
     everything else is Urbanist so small text stays easy to read. */
  --fs-xs: .75rem;      /* 12px  table heads, tags, captions */
  --fs-sm: .8125rem;    /* 13px  help text, badges, small buttons */
  --fs-base: .9375rem;  /* 15px  body, inputs, buttons */
  --fs-md: 1rem;        /* 16px  h3, emphasis */
  --fs-lg: 1.125rem;    /* 18px  h2 card titles */
  --fs-xl: 1.375rem;    /* 22px  section titles */
  --fs-h1: 2.25rem;     /* 36px  page titles (Bebas) */
  --track-caps: .06em;  /* letter-spacing for small uppercase labels */

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 18, 12, .05);
  --shadow: 0 1px 2px rgba(20, 18, 12, .04), 0 4px 14px rgba(20, 18, 12, .05);
  --shadow-lg: 0 12px 32px rgba(20, 18, 12, .12);
  --ring: 0 0 0 3px rgba(165, 118, 28, .22);
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); color: var(--text); background: var(--bg); font-size: var(--fs-base);
  font-weight: 500; line-height: 1.5; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html { font-size: 16px; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-dark); }
h1, h2, h3, h4 { margin: 0 0 .35em; color: var(--text); }
h1 { font-family: var(--font-head); font-weight: 400; font-size: var(--fs-h1); letter-spacing: .02em; line-height: 1.05; }
h2, h3, h4 { font-family: var(--font-body); font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
strong, b { font-weight: 700; }
p { margin: 0 0 .6em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, table td.num, .stat, .code { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.code { font-weight: 700; letter-spacing: 0; }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.icon { flex-shrink: 0; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber-text); }
.text-gold { color: var(--gold); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
::selection { background: var(--gold-soft); }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; color: var(--sidebar-text);
  background: linear-gradient(180deg, var(--sidebar-2) 0%, var(--sidebar) 40%);
  display: flex; flex-direction: column; padding: 18px 14px 16px;
  position: sticky; top: 0; height: 100vh; border-right: 1px solid #000;
}
.brand { display: flex; flex-direction: column; padding: 2px 8px 20px; color: #fff; }
.brand:hover { color: #fff; }
.brand-row { flex-direction: row; align-items: center; gap: 10px; }
.brand-mark { border-radius: 6px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-head); font-weight: 400; font-size: 1.6rem; line-height: 1; letter-spacing: 1px; }
.brand-accent { color: var(--gold); }
.brand-tag { font-size: .625rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #8d8d8d; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.nav-label { font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: #6d6d6d; font-weight: 700; padding: 14px 14px 6px; }
.nav-label:first-child { padding-top: 4px; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px;
  color: var(--sidebar-text); font-size: var(--fs-base); font-weight: 500; transition: background .15s, color .15s;
}
.nav-link .icon { opacity: .85; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active {
  background: linear-gradient(135deg, #b8862a 0%, var(--gold) 55%, var(--gold-dark) 100%); color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(165, 118, 28, .35), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.nav-link.active .icon { opacity: 1; }
.nav-sep { border: 0; border-top: 1px solid #262626; margin: 12px 8px; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 12px 10px;
  background: rgba(255, 255, 255, .04); border: 1px solid #222; border-radius: 12px;
}
.sidebar-user > div { min-width: 0; }
.sidebar-user-name { color: #fff; font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: var(--fs-xs); color: #8d8d8d; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: #2a2a2a; color: #fff; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .875rem;
}
.sidebar-user .avatar { background: var(--gold); }
.avatar-btn { border: 0; cursor: pointer; background: var(--black); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 28px; height: var(--topbar-h);
  background: rgba(255, 255, 255, .88); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.search {
  display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; flex: 0 1 440px; color: var(--faint); transition: border-color .15s, box-shadow .15s, background .15s;
}
.search:focus-within { border-color: var(--gold); box-shadow: var(--ring); background: #fff; }
.search input { border: 0; background: transparent; padding: 10px 0; font: inherit; width: 100%; outline: none; box-shadow: none; color: var(--text); }
.search input:focus { box-shadow: none; outline: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-right form { margin: 0; }
.icon-btn {
  position: relative; color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; border: 0; background: transparent;
}
.icon-btn:hover { background: var(--grey-soft); color: var(--gold); }
.icon-dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px #fff; }
.menu-btn { display: none; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; padding: 2px; gap: 2px; }
.lang-switch a { padding: 4px 10px; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; border-radius: 8px; }
.lang-switch a:hover { color: var(--text); background: var(--grey-soft); }
.lang-switch a.on { background: var(--gold); color: #fff; }

/* User menu (no JS: <details>) */
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; border-radius: 999px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary .avatar { background: var(--black); }
.user-menu[open] > summary .avatar, .user-menu > summary:hover .avatar { box-shadow: 0 0 0 3px var(--gold-soft); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 230px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; z-index: 30;
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head strong { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text); font: 500 .875rem var(--font-body); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--grey-soft); color: var(--text); }
.menu-item.danger { color: var(--red); }

.content { padding: 28px 32px 40px; width: 100%; max-width: 1480px; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; }
.page-head .muted:first-child { margin: 0 0 4px; font-size: var(--fs-sm); }
.page-head p.muted { font-size: var(--fs-base); }
.head-actions, .page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.head-actions form, .page-actions form { margin: 0; }
.crumbs { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--gold); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm);
}
a.card { transition: box-shadow .18s, border-color .18s, transform .18s; }
a.card:hover { border-color: var(--gold-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head a { font-weight: 600; font-size: .875rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 16px 20px 0; }
.card-foot { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; }
.note { background: var(--gold-soft); border: 1px solid var(--gold-line); border-radius: var(--radius-sm); padding: 12px 14px; }

/* Stat cards */
.stat { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { display: flex; gap: 14px; align-items: center; }
.stat-card .tile { margin: 0; }

/* Icon tiles */
.tile {
  width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; margin-bottom: 12px; background: var(--gold); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
}
.tile-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tile-orange { background: linear-gradient(135deg, #c08a2a, var(--gold)); }
.tile-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.tile-green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.tile-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.tile-indigo { background: linear-gradient(135deg, #6366f1, #3b4fd8); }
.tile-red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.tile-soft { background: var(--gold-soft); color: var(--gold); box-shadow: none; }
.tile-sm { width: 36px; height: 36px; border-radius: 10px; }
.tile-round { border-radius: 50%; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--gold);
  color: #fff; border: 1px solid transparent; border-radius: 10px; padding: 0 18px; min-height: 42px;
  font: 600 var(--fs-base) var(--font-body); letter-spacing: .005em; cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--gold-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); border-radius: 8px; gap: 6px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: var(--fs-md); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: var(--soft); color: var(--text); border-color: var(--gold); }
.btn-ghost { background: transparent; color: var(--text); box-shadow: none; }
.btn-ghost:hover { background: var(--grey-soft); color: var(--text); }
.btn-dark { background: var(--black); }
.btn-dark:hover { background: #262626; }
.btn-green { background: var(--green); }
.btn-green:hover { background: #116a33; }
.btn-red { background: var(--red); }
.btn-red:hover { background: #b91c1c; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: #f3c4c4; box-shadow: var(--shadow-sm); }
.btn-danger-outline:hover { background: var(--red-soft); color: var(--red); }
.link-btn { background: none; border: 0; color: var(--gold); cursor: pointer; font: inherit; font-weight: 600; padding: 0; }
.link-btn:hover { color: var(--gold-dark); }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: var(--fs-sm); color: #2b2b2f; }
input, select, textarea {
  font: inherit; font-size: var(--fs-base); font-weight: 500; color: var(--text); padding: 10px 12px; min-height: 42px;
  border: 1px solid var(--border-strong); border-radius: 10px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #bfb9aa; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
select[multiple] { background-image: none; padding-right: 12px; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 18px; height: 18px; padding: 0; accent-color: var(--gold); cursor: pointer; }
input[type="file"] { padding: 6px; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: 600 var(--fs-sm) var(--font-body); border: 1px solid var(--border-strong); background: var(--soft); color: var(--text);
  padding: 7px 14px; border-radius: 8px; margin-right: 12px; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--gold); }
input:disabled, select:disabled, textarea:disabled { background: var(--soft); color: var(--muted); }
.form-grid, .fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-grid .wide, .fields .wide { grid-column: 1 / -1; }
.form-actions, .form-foot { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.form-foot { justify-content: flex-end; }
.check, label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; font-size: var(--fs-base); }
.check input[type="checkbox"], .check input[type="radio"] { width: 20px; height: 20px; }
.help { font-weight: 500; color: var(--muted); font-size: var(--fs-sm); }
.field-error { color: var(--red); font-weight: 600; font-size: var(--fs-sm); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.req { color: var(--red); }
.toolbar, .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar { align-items: center; }
.toolbar .search-box { display: flex; gap: 8px; flex: 1 1 280px; }
.toolbar .search-box input { flex: 1; }
.filters label { min-width: 180px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { flex: 1 1 160px; }
.inline-input { width: 80px; padding: 6px 8px; min-height: 34px; }
.inline-select { padding: 6px 30px 6px 8px; min-height: 34px; background-position: right 8px center; }
.qty-box { width: 110px; text-align: right; font-family: var(--font-num); }
.tick { width: 26px; height: 26px; accent-color: var(--gold); }

/* ---------- Flash / toast ---------- */
.flash {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 500;
  border: 1px solid transparent; border-left-width: 4px; margin: 0 0 16px; animation: flash-in .25s ease-out;
}
.flash-error { background: var(--red-soft); color: #a61b1b; border-color: #f6caca; border-left-color: var(--red); }
.flash-ok { background: var(--green-soft); color: #13652f; border-color: #c4e8d2; border-left-color: var(--green); }
.flash-info { background: var(--gold-soft); color: var(--gold-dark); border-color: var(--gold-line); border-left-color: var(--gold); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  text-align: left; font-size: var(--fs-xs); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--muted); font-weight: 700;
  padding: 11px 12px; border-bottom: 1px solid var(--border); background: var(--soft); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .875rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #fcfaf5; }
td.num, th.num { text-align: right; white-space: nowrap; }
.card > table th:first-child, .table-wrap th:first-child, .table-wrap td:first-child { padding-left: 18px; }
.card > table th:last-child, .table-wrap th:last-child, .table-wrap td:last-child { padding-right: 18px; }
.card > table th:first-child { border-top-left-radius: 8px; }
.card > table th:last-child { border-top-right-radius: 8px; }
.table-wrap { overflow-x: auto; padding: 0; -webkit-overflow-scrolling: touch; }
.table-wrap td, .table-wrap th { white-space: nowrap; }
.table-wrap > table { min-width: 100%; }
.card.table-wrap > table th:first-child { border-top-left-radius: var(--radius); }
.card.table-wrap > table th:last-child { border-top-right-radius: var(--radius); }
.table-wrap.wrap td { white-space: normal; }
tr.low td, .row-short td { background: #fff8f8; }
tr.low:hover td, .row-short:hover td { background: #fff1f1; }
.totals td { font-weight: 700; border-top: 2px solid var(--border); background: var(--soft); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.row-actions form { margin: 0; }
td .row-actions { flex-wrap: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }
.qty-in { color: var(--green); font-weight: 600; } .qty-out { color: var(--red); font-weight: 600; }

/* ---------- Badges, dots, pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs);
  font-weight: 600; letter-spacing: .01em; line-height: 1.5; white-space: nowrap; background: var(--grey-soft); color: var(--muted);
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber-text); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gold { background: var(--gold-soft); color: var(--gold-dark); }
.badge-grey { background: var(--grey-soft); color: var(--muted); }
.badge-dark { background: #1d1d1f; color: #fff; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex-shrink: 0; background: var(--faint); }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-blue { background: var(--blue); }
.dot-gold { background: var(--gold); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pill {
  display: inline-flex; align-items: center; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: #fff; color: var(--text); font-weight: 600; font-size: .875rem; transition: all .15s;
}
.pill:hover { border-color: var(--gold); color: var(--text); }
.pill.on { background: var(--black); border-color: var(--black); color: #fff; }
.pill .count { font-family: var(--font-num); margin-left: 6px; opacity: .7; }
.pill.on .count { color: #e3c37f; opacity: 1; }
.lvl { display: inline-block; min-width: 26px; text-align: center; border-radius: 6px; background: var(--gold-soft); color: var(--gold-dark); font-weight: 700; font-size: var(--fs-xs); font-family: var(--font-num); padding: 2px 6px; }
.late { color: var(--red); font-weight: 600; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 14px; color: var(--muted); font-size: .875rem; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.on, .tabs a.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; flex: 1; }
.bar span { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.bar.done span, .bar-green span { background: var(--green); }
.bar-amber span { background: var(--amber); }
.bar-red span { background: var(--red); }
.bar-blue span { background: var(--blue); }

/* ---------- Layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .m0 { margin: 0; }
.info-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin: 16px 0 0; }
.info-row dt { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: var(--track-caps); }
.info-row dd { margin: 2px 0 0; font-weight: 600; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty p { margin: 0; color: var(--muted); max-width: 420px; }
.empty .btn { margin-top: 8px; }
.empty-icon {
  display: inline-flex; padding: 16px; border-radius: 50%; background: var(--gold-soft); color: var(--gold);
  box-shadow: 0 0 0 8px rgba(247, 240, 225, .5); margin-bottom: 8px;
}

/* ---------- Dashboard ---------- */
.hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: stretch;
  margin-bottom: 22px;
}
.hero-main {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 30px 32px; color: #fff;
  background:
    radial-gradient(600px 260px at 100% 0%, rgba(165, 118, 28, .55), transparent 60%),
    radial-gradient(500px 200px at 0% 120%, rgba(165, 118, 28, .25), transparent 60%),
    linear-gradient(135deg, #151515 0%, #0b0b0b 100%);
  box-shadow: var(--shadow);
}
.hero-main::after {
  content: ""; position: absolute; right: -40px; bottom: -60px; width: 260px; height: 260px; border-radius: 50%;
  border: 36px solid rgba(255, 255, 255, .04);
}
.hero-hello { color: #d8b56d; font-weight: 600; font-size: var(--fs-base); margin: 0 0 8px; }
.hero-title { font-size: 3.1rem; line-height: .95; letter-spacing: .02em; margin: 0; color: #fff; }
.hero-title .accent { color: var(--gold); display: block; background: linear-gradient(90deg, #d9a640, #a5761c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-size: var(--fs-md); font-weight: 500; color: #c9c9c9; margin: 12px 0 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-actions .btn-outline { background: rgba(255, 255, 255, .06); color: #fff; border-color: rgba(255, 255, 255, .2); box-shadow: none; }
.hero-actions .btn-outline:hover { background: rgba(255, 255, 255, .12); border-color: #fff; }
.highlights { display: flex; flex-direction: column; }
.highlights ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.highlights li { display: flex; align-items: flex-start; gap: 2px; font-size: .875rem; }
.highlights li .dot { margin-top: 6px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); gap: 14px; margin-bottom: 22px; }
.setup-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.module-card { color: var(--text); display: flex; flex-direction: column; padding: 18px; }
.module-card:hover { color: var(--text); }
.module-card h3 { margin-bottom: 2px; font-size: var(--fs-base); }
.module-card p { flex: 1; font-size: var(--fs-sm); margin: 2px 0 14px; line-height: 1.4; }
.module-card .stat { font-size: 1.625rem; }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
/* Role desks (dashboard/desk.html): two panels a row, wide ones take the full row */
.desk-kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.desk-kpis .stat { white-space: nowrap; }
a.stat-card { color: var(--text); }
.desk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.desk-grid > .wide, .desk-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.desk-grid td, .desk-grid th { padding: 9px 10px; }
.desk-grid td { white-space: nowrap; }
.desk-grid td:nth-child(2) { white-space: normal; }

/* "Login as": shown on every page while an Admin / Owner views the app as someone else */
.viewas-bar {
  position: sticky; top: 0; z-index: 25; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  background: var(--gold); color: #fff; padding: 8px 16px; font-weight: 600; font-size: var(--fs-sm);
}
.viewas-bar form { margin: 0; }
.viewas-bar .btn { background: #fff; color: var(--gold-dark); min-height: 32px; }
.viewas-bar .btn:hover { background: var(--black); color: #fff; }
.donut-wrap { display: flex; align-items: center; gap: 22px; }
.donut {
  --size: 150px; width: var(--size); height: var(--size); border-radius: 50%; flex-shrink: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.donut::before { content: ""; position: absolute; inset: 20px; background: #fff; border-radius: 50%; }
.donut-center { position: relative; text-align: center; line-height: 1.05; }
.donut-center .stat { font-size: 2rem; }
.legend { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; font-size: .875rem; }
.legend li { display: flex; align-items: center; }
.legend li .num { margin-left: auto; font-weight: 700; }
.load-row { display: grid; grid-template-columns: 96px 1fr 30px; align-items: center; gap: 12px; padding: 7px 0; font-size: .875rem; }
.load-row .num { text-align: right; font-weight: 700; }
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { display: flex; align-items: center; gap: 4px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .875rem; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .num { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.workflow { background: linear-gradient(135deg, #fbf6ea 0%, var(--gold-soft) 100%); border-color: var(--gold-line); }
.workflow-steps { list-style: none; padding: 0; margin: 18px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.workflow-steps li { display: flex; gap: 12px; align-items: flex-start; }
.workflow-steps strong { display: block; font-size: .875rem; }
.workflow-steps small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; display: block; }
.workflow-steps .tile { box-shadow: 0 6px 14px rgba(165, 118, 28, .25); }

/* Search results */
.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); }
.result-list li:last-child a { border-bottom: 0; }
.result-list li a:hover { background: #fcfaf5; }
.result-list .grow { flex: 1; min-width: 0; }
mark { background: #f8e7bf; color: inherit; padding: 0 2px; border-radius: 3px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-art {
  position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(700px 400px at 100% 0%, rgba(165, 118, 28, .5), transparent 60%),
    radial-gradient(600px 400px at 0% 100%, rgba(165, 118, 28, .25), transparent 60%),
    linear-gradient(160deg, #161616, #050505);
}
.login-art::after { content: ""; position: absolute; right: -120px; top: 30%; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255, 255, 255, .035); }
.login-art h2 { font-family: var(--font-head); font-weight: 400; letter-spacing: .02em; font-size: 3.4rem; line-height: .95; color: #fff; margin: 0 0 14px; position: relative; z-index: 1; }
.login-art h2 span { color: var(--gold); display: block; }
.login-art p { color: #c9c9c9; font-size: var(--fs-md); max-width: 420px; position: relative; z-index: 1; }
.login-points { list-style: none; padding: 0; margin: 24px 0 0; display: flex; flex-direction: column; gap: 10px; position: relative; z-index: 1; }
.login-points li { display: flex; gap: 10px; align-items: center; color: #e6e6e6; }
.login-points .icon { color: var(--gold); }
.login-side { display: flex; align-items: center; justify-content: center; padding: 32px 20px; background: var(--bg); }
.login-card {
  background: #fff; border-radius: 18px; padding: 36px 32px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.login-card h1 { margin: 4px 0 0; }
.login-logo { width: 200px; height: auto; margin-bottom: -6px; }
.lang-center { align-self: center; }

/* ---------- Print ---------- */
/* ---------- List pages: filter bar, bulk bar, pager (app/templates/_list.html) ---------- */
.list-filter { margin-bottom: 16px; }
.list-filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.list-filter-row .search-box { display: flex; gap: 8px; flex: 1 1 280px; max-width: 520px; }
.list-filter-row .search-box input { flex: 1; }
.list-filter-gap { flex: 1 1 0; }
.list-filter .btn.is-on { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-soft); }
.list-filter .btn .count, .btn .count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--gold); color: #fff; font-size: var(--fs-xs); font-weight: 700;
}
.filter-panel { margin-top: 12px; }
.filter-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.filter-panel .form-actions { margin-top: 16px; }
.export-btns { display: flex; gap: 6px; }
.bulk-bar {
  position: sticky; top: 8px; z-index: 5; display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--gold-line); border-radius: var(--radius-sm);
  background: var(--gold-soft); box-shadow: var(--shadow-sm, 0 2px 6px rgba(0,0,0,.06));
}
.bulk-bar[hidden] { display: none; }
.bulk-bar select { width: auto; min-width: 200px; min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
th.check-col, td.check-col { width: 40px; padding-right: 0; }
tr.is-picked td { background: #fbf5e8; }
.pager-bar { display: flex; gap: 12px 18px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-top: 14px; }
.pager-bar .pager { margin-top: 0; flex-wrap: wrap; }
.pager .is-current { pointer-events: none; }
.page-size { display: flex; gap: 8px; align-items: center; margin: 0; }
.inline-label { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); font-size: var(--fs-sm); }
.inline-label select { width: auto; }

/* Searchable select (app/static/js/app.js) */
.combo { position: relative; width: 100%; }
.combo-native { position: absolute !important; inset: 0; opacity: 0; pointer-events: none; }
.combo-input {
  width: 100%; padding-right: 36px; cursor: text;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.combo.is-invalid .combo-input { border-color: var(--red); }
.combo-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); max-height: 280px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 10px 28px rgba(0,0,0,.12);
}
.combo-list li { padding: 9px 10px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: var(--fs-base); }
.combo-list li:hover, .combo-list li.is-active { background: var(--gold-soft); color: var(--gold-dark); }
.combo-list li.is-selected { font-weight: 700; }
.combo-list li.combo-none { color: var(--muted); cursor: default; background: none; }

/* Import preview */
.import-steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
tr.row-bad td { background: #fff8f8; }

@media print {
  .sidebar, .topbar, .nav-backdrop, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1200px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid > :last-child { grid-column: 1 / -1; }
  .hero { grid-template-columns: 1fr; }
}

/* ---------- Phone / small tablet ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .nav-backdrop { display: block; }
  .nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; }
  .search { flex: 1 1 auto; }
  .content { padding: 18px 16px 32px; }
  h1 { font-size: 1.875rem; }
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions .btn, .page-actions .btn { flex: 1 1 auto; }
  .hero-main { padding: 24px 20px; }
  .hero-title { font-size: 2.4rem; }
  .grid-2, .grid-3, .dash-grid { grid-template-columns: 1fr; }
  .desk-grid { grid-template-columns: minmax(0, 1fr); }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .module-card { padding: 14px; }
  .module-card p { display: none; }
  .module-card .tile { width: 38px; height: 38px; margin-bottom: 8px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-row > .card { padding: 16px; }
  .filters label:not(.check) { min-width: 0; flex: 1 1 140px; }
  .filters input, .filters select { width: 100%; }
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }
}
@media (max-width: 520px) {
  .lang-switch a { padding: 4px 7px; }
  .search input::placeholder { color: transparent; }
  .donut-wrap { flex-direction: column; align-items: stretch; }
  .donut { align-self: center; }
}
