/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --ink: #14171f;
  --ink-soft: #1f2430;
  --paper: #f5f6f7;
  --surface: #ffffff;
  --accent: #c98a2c;
  --accent-dark: #a96f1c;
  --accent-soft: #f4e4c8;
  --border: #e4e4e2;
  --muted: #6b7280;
  --text: #1a1c22;
  --danger: #c4432e;
  --success: #2f8f5b;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --sidebar-w: 260px;
  --topbar-h: 68px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.06);
  --shadow-md: 0 6px 20px rgba(20, 23, 31, 0.08);
}

/* ============================================================
   Reset / base
   ============================================================ */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   App shell
   ============================================================ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar -------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: #c9cbd3;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar__brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}

.sidebar__scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px 24px;
}

.nav-group {
  margin-bottom: 22px;
}

.nav-group__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6d7180;
  padding: 0 10px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #c9cbd3;
  position: relative;
  margin-bottom: 2px;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--ink-soft);
  color: #fff;
}

.nav-link.is-active {
  background: var(--ink-soft);
  color: #fff;
  font-weight: 600;
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--ink) inset;
}

.nav-link.is-active::after {
  content: "";
  position: absolute;
  left: -11px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink);
}

/* ---- Topbar ---------------------------------------------------- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar__menu-btn {
  display: none;
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px;
  color: var(--ink);
}

.topbar__title {
  font-size: 20px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  width: 260px;
}

.search svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: var(--text);
  font-family: var(--font-body);
}

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink);
  padding: 6px;
  border-radius: 8px;
  position: relative;
}

.icon-btn:hover {
  background: var(--paper);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn__dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--surface);
}

.user-chip__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
}

.user-chip__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  font-family: var(--font-display);
}

.user-chip__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.user-chip__role {
  font-size: 11.5px;
  color: var(--muted);
}

/* ---- Main content ------------------------------------------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  padding: 28px 28px 60px;
}

/* ---- Stat cards (design preview) ------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.stat-card__label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-card__delta {
  font-size: 12.5px;
  margin-top: 8px;
  font-weight: 600;
}

.stat-card__delta.is-up {
  color: var(--success);
}

.stat-card__delta.is-down {
  color: var(--danger);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}

.panel__title {
  font-size: 16px;
  margin-bottom: 4px;
}

.panel__subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}

.placeholder-note {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--muted);
  font-size: 13px;
  background: var(--paper);
}

/* ---- Toolbar (page header row) --------------------------------- */
.toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar__title {
  font-size: 20px;
  margin-bottom: 4px;
}

.toolbar__subtitle {
  font-size: 13px;
  color: var(--muted);
}

/* ---- Buttons ---------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-body);
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.btn-outline:hover {
  border-color: var(--ink);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}

/* ---- Filter bar --------------------------------------------------- */
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters .search {
  width: 280px;
}

.field-select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-body);
  cursor: pointer;
}

/* ---- Badges --------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: capitalize;
  line-height: 1.6;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: #e6f3ec; color: var(--success); }
.badge-warning { background: #fbeed9; color: #a9711a; }
.badge-danger  { background: #f8e6e2; color: var(--danger); }
.badge-neutral { background: #eceef1; color: var(--muted); }
.badge-info    { background: #e5eef7; color: #2f6a9f; }

/* ---- Table ------------------------------------------------------ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--paper);
}

.cell-primary {
  font-weight: 600;
  color: var(--ink);
}

.cell-muted {
  color: var(--muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.row-actions .icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Pagination -------------------------------------------------- */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination button {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  font-family: var(--font-body);
}

.pagination button.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  font-weight: 600;
}

.pagination button:hover:not(.is-active) {
  border-color: var(--ink);
}

/* ---- Forms ------------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 20px;
}

.form-grid.is-single {
  grid-template-columns: 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.span-2 {
  grid-column: span 2;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.form-group .hint {
  font-size: 11.5px;
  color: var(--muted);
}

.form-control,
select.form-control {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-body);
  width: 100%;
}

.form-control:focus,
select.form-control:focus {
  border-color: var(--accent);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: var(--font-body);
}

.form-static {
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--muted);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---- Key/value read-only view ------------------------------------ */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px 24px;
}

.kv {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kv dt {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
}

/* ---- Page header (detail pages, with breadcrumb + status) --------- */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.breadcrumb a {
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--ink);
}

.page-head__title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-head__title h2 {
  font-size: 20px;
}

.page-head__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Stepper (recipe line editor, inline add-row) ------------------ */
.line-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.line-editor table input,
.line-editor table select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: var(--font-body);
  width: 100%;
  background: var(--surface);
}

.line-editor .mono-input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- Callout / info box ------------------------------------------- */
.callout {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 20px;
}

.callout svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: var(--accent-dark);
  margin-top: 1px;
}

.callout.is-warning {
  background: #fbeed9;
  border-color: #f0d8ab;
  color: #8a5c15;
}

.callout.is-warning svg {
  color: #a9711a;
}

/* ---- Tabs ---------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 4px;
  margin-right: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

@media (max-width: 720px) {
  .form-grid,
  .kv-grid {
    grid-template-columns: 1fr;
  }

  .form-group.span-2 {
    grid-column: span 1;
  }
}

/* ---- Overlay (mobile sidebar) --------------------------------- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 31, 0.4);
  z-index: 30;
}

.overlay.is-visible {
  display: block;
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 340px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 13px 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.is-leaving {
  animation: toast-out 0.15s ease forwards;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(4px); }
}

.toast__icon {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--accent);
}

.toast.is-error .toast__icon {
  color: #e17a63;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__message {
  font-size: 13px;
  line-height: 1.4;
}

.toast__action {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  margin-top: 6px;
}

.toast__close {
  background: none;
  border: none;
  color: #9a9ea8;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.toast__close svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ============================================================
   Confirm modal
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 31, 0.45);
  z-index: 90;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.is-visible {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 420px;
  max-width: 100%;
  padding: 24px;
  animation: modal-in 0.15s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal__icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #f8e6e2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.modal__icon.is-neutral {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.modal__icon svg {
  width: 19px;
  height: 19px;
}

.modal__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
}

.modal__body {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
  margin-bottom: 22px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}

.empty-state.is-visible {
  display: flex;
}

.empty-state__icon {
  width: 40px;
  height: 40px;
  color: var(--border);
  margin-bottom: 14px;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state__subtitle {
  font-size: 12.5px;
  max-width: 320px;
}

/* ============================================================
   Skeleton loading
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, #eeeeec 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: skeleton-pulse 1.4s ease infinite;
  border-radius: 5px;
  display: inline-block;
  height: 12px;
}

@keyframes skeleton-pulse {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ============================================================
   Checkboxes / bulk selection
   ============================================================ */
th.checkbox-col,
td.checkbox-col {
  width: 36px;
  padding-right: 0;
}

.row-checkbox,
.select-all-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.bulk-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.bulk-bar.is-visible {
  display: flex;
}

.bulk-bar__count {
  font-size: 13px;
  font-weight: 600;
}

.bulk-bar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bulk-bar .btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.bulk-bar .btn-outline:hover {
  border-color: #fff;
}

.bulk-bar__clear {
  background: none;
  border: none;
  color: #c9cbd3;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline;
}

/* ============================================================
   Button loading state
   ============================================================ */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(20, 23, 31, 0.3);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

.btn-primary.is-loading::after {
  border: 2px solid rgba(20, 23, 31, 0.35);
  border-top-color: var(--ink);
}

.btn-outline.is-loading::after {
  border: 2px solid rgba(20, 23, 31, 0.2);
  border-top-color: var(--muted);
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

.row-fade-out {
  animation: row-fade 0.25s ease forwards;
}

@keyframes row-fade {
  to { opacity: 0; transform: translateX(6px); }
}

/* ============================================================
   Auth pages (login / forgot password)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  padding: 24px;
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(720px circle at 12% 8%, rgba(201, 138, 44, 0.10), transparent 60%),
    radial-gradient(640px circle at 88% 92%, rgba(20, 23, 31, 0.06), transparent 55%);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: 400px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 36px 34px 30px;
}

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-card__brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  flex-shrink: 0;
}

.auth-card__brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.auth-card__title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.auth-card__subtitle {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 26px;
}

.auth-card .form-group {
  margin-bottom: 16px;
}

.auth-field-icon-wrap {
  position: relative;
}

.auth-field-icon-wrap .form-control {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px;
  border-radius: 6px;
  display: flex;
}

.password-toggle:hover {
  color: var(--ink);
}

.password-toggle svg {
  width: 16px;
  height: 16px;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 12.5px;
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.auth-checkbox input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.auth-link {
  color: var(--accent-dark);
  font-weight: 600;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
}

.auth-card__footer {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 22px;
}

.auth-sent {
  display: none;
  text-align: center;
}

.auth-sent.is-visible {
  display: block;
}

.auth-sent__icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.auth-sent__icon svg {
  width: 24px;
  height: 24px;
}

.auth-form.is-hidden {
  display: none;
}

/* ============================================================
   User menu dropdown (topbar)
   ============================================================ */
.user-chip {
  position: relative;
}

.user-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  padding: 8px;
  z-index: 50;
}

.user-menu.is-open {
  display: block;
}

.user-menu__header {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.user-menu__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.user-menu__email {
  font-size: 11.5px;
  color: var(--muted);
}

.user-menu a,
.user-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}

.user-menu a:hover,
.user-menu button:hover {
  background: var(--paper);
}

.user-menu svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.user-menu__divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.user-menu .is-danger {
  color: var(--danger);
}

.user-menu .is-danger svg {
  color: var(--danger);
}

/* ============================================================
   Notification panel (topbar)
   ============================================================ */
.notif-wrap {
  position: relative;
}

.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 50;
  overflow: hidden;
}

.notif-wrap.is-open .notif-panel {
  display: block;
}

.notif-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.notif-panel__mark-all {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-body);
}

.notif-panel__list {
  max-height: 360px;
  overflow-y: auto;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--paper);
}

.notif-item__icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.notif-item__icon svg {
  width: 15px;
  height: 15px;
}

.notif-item__icon.is-success { background: #e6f3ec; color: var(--success); }
.notif-item__icon.is-warning { background: #fbeed9; color: #a9711a; }
.notif-item__icon.is-info    { background: #e5eef7; color: #2f6a9f; }
.notif-item__icon.is-neutral { background: #eceef1; color: var(--muted); }

.notif-item__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.notif-item__text {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
}

.notif-item__text strong {
  color: var(--ink);
}

.notif-item__time {
  font-size: 11px;
  color: var(--muted);
}

.notif-item.is-unread {
  position: relative;
  background: rgba(201, 138, 44, 0.04);
}

.notif-item.is-unread::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ============================================================
   Avatar upload (profile page)
   ============================================================ */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.avatar-lg {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  flex-shrink: 0;
}

.password-strength {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.password-strength__bar {
  height: 4px;
  flex: 1;
  border-radius: 2px;
  background: var(--border);
}

.password-strength__bar.is-filled {
  background: var(--success);
}

/* ============================================================
   Searchable select (combobox)
   ============================================================ */
.select2 {
  position: relative;
}

.select2__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.select2__trigger:hover {
  border-color: var(--ink);
}

.select2.is-open .select2__trigger {
  border-color: var(--accent);
}

.select2__trigger-label.is-placeholder {
  color: var(--muted);
}

.select2__trigger svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.select2.is-open .select2__trigger svg {
  transform: rotate(180deg);
}

.select2__panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 40;
  overflow: hidden;
}

.select2.is-open .select2__panel {
  display: block;
}

.select2__search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.select2__search-wrap svg {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.select2__search {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: var(--font-body);
  width: 100%;
  color: var(--text);
}

.select2__options {
  max-height: 220px;
  overflow-y: auto;
  padding: 6px;
}

.select2__option {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.select2__option:hover,
.select2__option.is-active {
  background: var(--paper);
}

.select2__option.is-selected {
  font-weight: 600;
  color: var(--ink);
}

.select2__option.is-selected svg {
  width: 14px;
  height: 14px;
  color: var(--accent-dark);
  flex-shrink: 0;
}

.select2__empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .topbar__menu-btn {
    display: inline-flex;
  }

  .search {
    display: none;
  }
}

@media (max-width: 560px) {
  .content {
    padding: 20px 16px 40px;
  }

  .topbar {
    padding: 0 16px;
  }

  .user-chip__name,
  .user-chip__role {
    display: none;
  }
}

/* Roles with view-only access to a module: hide the controls that would write. The server enforces it too. */
.read-only [data-db-action],
.read-only .write-only,
.read-only a[href*="new=1"] { display: none !important; }
.read-only .perm-note { display: block; }
.perm-note { display: none; margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; background: #fbeed9; color: #a9711a; font-size: 13px; }

/* ---- Brand logo: shown when /img/sicer-logo.png exists, otherwise the text brand stays ---- */
.brand-logo { display: none; }
.has-logo > .brand-logo { display: block; }
.has-logo > .sidebar__brand-mark, .has-logo > .sidebar__brand-name,
.has-logo > .auth-card__brand-mark, .has-logo > .auth-card__brand-name { display: none; }
.sidebar__brand.has-logo { padding: 18px 20px; }
.sidebar__brand.has-logo > .brand-logo {
  width: 100%; max-height: 60px; object-fit: contain; object-position: left center; box-sizing: border-box;
  filter: brightness(0) invert(1); opacity: 0.94;   /* the logo is grey with a transparent background: shown white on the dark sidebar */
}
.auth-card__brand.has-logo > .brand-logo { max-width: 230px; max-height: 64px; object-fit: contain; }
