
:root {
  --af-primary: #5b5bd6;
  --af-primary-hover: #4f4fc9;
  --af-primary-soft: #eeeefb;
  --af-primary-ring: rgba(91, 91, 214, 0.25);
  --af-danger: #dc2626;
  --af-danger-hover: #b91c1c;
  --af-danger-soft: #fdeaea;
  --af-success: #16a34a;
  --af-warning: #d97706;
  --af-bg: #f4f4f6;
  --af-surface: #ffffff;
  --af-surface-raised: #fafafb;
  --af-text: #18181b;
  --af-text-secondary: #3f3f46;
  --af-text-muted: #71717a;
  --af-border: #e4e4e7;
  --af-border-strong: #d4d4d8;
  --af-row-line: #f2f2f4;
  --af-header-bg: #fff;
  --af-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --af-font-mono: 'SF Mono', 'Cascadia Code', Monaco, Consolas, monospace;
  --af-grid-row-height: 36px;
  --af-radius: 6px;
  --af-radius-lg: 10px;
  --af-shadow-popover: 0 4px 6px -2px rgba(24, 24, 27, 0.06), 0 12px 24px -4px rgba(24, 24, 27, 0.12);
  --af-shadow-modal: 0 24px 48px -12px rgba(24, 24, 27, 0.25);
  --af-shadow-card: 0 1px 2px rgba(24, 24, 27, 0.04), 0 2px 6px rgba(24, 24, 27, 0.05);
  --af-focus-ring: 0 0 0 3px var(--af-primary-ring);
}

/* Toolbar — card header of a grid section */
.af-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--af-border); margin-bottom: 0;
  background: var(--af-surface);
}
.af-toolbar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--af-text); }
.af-toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* Buttons */
.af-btn {
  padding: 6px 14px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
  background: var(--af-surface); color: var(--af-text-secondary);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.05);
}
.af-btn:hover:not(:disabled) { background: var(--af-surface-raised); border-color: #bcbcc2; }
.af-btn:focus-visible { outline: none; box-shadow: var(--af-focus-ring); }
.af-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.af-btn-add, .af-btn-button, .af-btn-save, .af-btn-primary {
  background: var(--af-primary); color: #fff; border-color: var(--af-primary);
}
.af-btn-add:hover:not(:disabled), .af-btn-button:hover:not(:disabled),
.af-btn-save:hover:not(:disabled), .af-btn-primary:hover:not(:disabled) {
  background: var(--af-primary-hover); border-color: var(--af-primary-hover);
}
.af-btn-cancel { background: transparent; border-color: transparent; box-shadow: none; color: var(--af-text-muted); }
.af-btn-cancel:hover:not(:disabled) { background: var(--af-bg); border-color: transparent; color: var(--af-text); }
.af-btn-danger { background: var(--af-danger); color: #fff; border-color: var(--af-danger); }
.af-btn-danger:hover:not(:disabled) { background: var(--af-danger-hover); border-color: var(--af-danger-hover); }
.af-btn-delete { color: var(--af-danger); border-color: var(--af-border-strong); }
.af-btn-delete:hover:not(:disabled) { background: var(--af-danger-soft); border-color: var(--af-danger); }
.af-btn-close { border-color: transparent; box-shadow: none; color: var(--af-text-muted); padding: 6px 8px; }
.af-btn-close:hover:not(:disabled) { background: var(--af-bg); color: var(--af-text); }

/* Grid — a contained card: toolbar header, search band, flush table */
.af-grid-section {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--af-surface); border: 1px solid var(--af-border);
  border-radius: var(--af-radius-lg); box-shadow: var(--af-shadow-card);
}
.af-grid-wrapper { overflow: auto; flex: 1; min-height: 0; }
.af-grid { width: 100%; border-collapse: collapse; background: var(--af-surface); }
.af-grid-th {
  padding: 9px 12px; text-align: left; background: var(--af-surface-raised);
  box-shadow: inset 0 -1px 0 var(--af-border);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--af-text-muted); user-select: none;
  position: sticky; top: 0; z-index: 2;
}
.af-grid-th:first-child { padding-left: 16px; }
.af-grid-th:hover { color: var(--af-text-secondary); }
.af-grid-row { height: var(--af-grid-row-height); cursor: pointer; transition: background 0.1s; }
.af-grid-row:hover { background: var(--af-surface-raised); }
.af-grid-row.selected { background: var(--af-primary-soft); box-shadow: inset 2px 0 0 var(--af-primary); }
.af-grid-td {
  padding: 7px 12px; border-bottom: 1px solid var(--af-row-line);
  font-size: 13px; color: var(--af-text); font-variant-numeric: tabular-nums;
}
.af-grid-td:first-child { padding-left: 16px; font-weight: 500; }
.af-grid tbody tr:last-child .af-grid-td { border-bottom: none; }

/* Search — subdued band between toolbar and table */
.af-search {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 0;
  background: var(--af-surface-raised); border-bottom: 1px solid var(--af-border);
}
.af-search-field, .af-search-operator {
  padding: 6px 8px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  font-size: 13px; font-family: inherit; background: var(--af-surface); color: var(--af-text);
}
.af-search-field { min-width: 140px; }
.af-search-operator { min-width: 100px; }
.af-search-value {
  padding: 6px 10px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  font-size: 13px; font-family: inherit; min-width: 150px; flex: 1; max-width: 250px;
  background: var(--af-surface); color: var(--af-text);
}
.af-search-field:focus, .af-search-operator:focus, .af-search-value:focus {
  border-color: var(--af-primary); outline: none; box-shadow: var(--af-focus-ring);
}
/* Type-ahead wrapper: takes over the value input's flex sizing in each
   context so wrapped and unwrapped search rows lay out identically */
.af-search-lookup-wrap { position: relative; display: inline-flex; min-width: 0; }
.af-search .af-search-lookup-wrap { flex: 1; min-width: 150px; max-width: 250px; }
.af-filter-row .af-search-lookup-wrap { flex: 1; }
.af-search-lookup-wrap > input { flex: 1; width: 100%; min-width: 0; max-width: none; }
.af-btn-search, .af-btn-search-clear {
  padding: 6px 10px; border: none; border-radius: var(--af-radius); cursor: pointer; font-size: 13px;
}
.af-btn-search { background: var(--af-primary); color: #fff; }
.af-btn-search:hover { background: var(--af-primary-hover); }
.af-btn-search-clear { background: transparent; color: var(--af-text-muted); border: 1px solid var(--af-border-strong); }
.af-btn-search-clear:hover { background: var(--af-surface-raised); color: var(--af-text); }
.af-btn-filter {
  padding: 6px 10px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  cursor: pointer; font-size: 13px; background: transparent; color: var(--af-text-muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.af-btn-filter:hover { color: var(--af-text); background: var(--af-surface-raised); }
.af-btn-filter.active { background: var(--af-primary); color: #fff; border-color: var(--af-primary); }
.af-filter-count:empty { display: none; }
.af-filter-count {
  background: #fff; color: var(--af-primary); border-radius: 8px;
  font-size: 11px; font-weight: 600; padding: 0 5px; min-width: 16px; text-align: center;
}

/* Filter builder modal */
.af-filter-builder { max-width: 560px; }
.af-filter-logic { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; color: var(--af-text-secondary); }
.af-filter-logic select {
  padding: 6px 8px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  font-size: 13px; font-family: inherit; background: var(--af-surface); color: var(--af-text);
}
.af-filter-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.af-filter-row { display: flex; align-items: center; gap: 6px; }
.af-filter-row select, .af-filter-row input {
  padding: 6px 8px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  font-size: 13px; font-family: inherit; background: var(--af-surface); color: var(--af-text);
}
.af-filter-row select:focus, .af-filter-row input:focus {
  border-color: var(--af-primary); outline: none; box-shadow: var(--af-focus-ring);
}
.af-filter-row .af-filter-field { min-width: 140px; }
.af-filter-row .af-filter-op { min-width: 100px; }
.af-filter-row .af-filter-value { flex: 1; }
.af-filter-remove { background: transparent; border: none; box-shadow: none; color: var(--af-text-muted); cursor: pointer; padding: 6px; }
.af-filter-remove:hover { color: var(--af-danger); background: transparent; }
.af-btn-add-condition {
  background: transparent; border: 1px dashed var(--af-border-strong); color: var(--af-text-muted);
  padding: 6px 10px; border-radius: var(--af-radius); cursor: pointer; font-size: 13px; width: 100%;
  box-shadow: none; justify-content: center;
}
.af-btn-add-condition:hover:not(:disabled) { border-color: var(--af-primary); color: var(--af-primary); background: transparent; }
.af-filter-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Form */
.af-form { padding: 20px 0; }
.af-form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.af-form-fields.af-cols-1 { grid-template-columns: 1fr; }
.af-form-fields.af-cols-2 { grid-template-columns: 1fr 1fr; }
.af-form-fields.af-cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.af-form-fields.af-cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.af-form-group { display: flex; flex-direction: column; gap: 5px; }
.af-label { font-size: 12.5px; font-weight: 500; color: var(--af-text-secondary); }
.af-input, .af-select, .af-textarea {
  padding: 7px 10px; border: 1px solid var(--af-border-strong); border-radius: var(--af-radius);
  font-size: 13px; font-family: inherit; width: 100%; background: var(--af-surface); color: var(--af-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.af-input:focus, .af-select:focus, .af-textarea:focus {
  border-color: var(--af-primary); outline: none; box-shadow: var(--af-focus-ring);
}
.af-input[readonly], .af-textarea[readonly], .af-select:disabled {
  background: var(--af-surface-raised); color: var(--af-text-muted);
}
.af-input:invalid:not(:focus):not(:placeholder-shown),
.af-select:invalid:not(:focus),
.af-textarea:invalid:not(:focus):not(:placeholder-shown) {
  border-color: var(--af-danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.af-input::placeholder, .af-textarea::placeholder { color: #a0a0a8; }
.af-required { color: var(--af-danger); margin-left: 2px; }
.af-help { font-size: 11.5px; color: var(--af-text-muted); }
.af-form-actions { display: flex; gap: 8px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--af-border); }

/* Modal */
.af-modal-overlay {
  position: fixed; inset: 0; background: rgba(24, 24, 27, 0.45); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
}
.af-modal-content {
  background: var(--af-surface); border-radius: var(--af-radius-lg); width: 90%; max-width: 700px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--af-shadow-modal);
  padding: 24px;
}
.af-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.af-modal-header h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.af-modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--af-text-muted); padding: 4px 8px; border-radius: var(--af-radius); }
.af-modal-close:hover { color: var(--af-text); background: var(--af-bg); }

/* Filter Section — uses .af-form-fields and .af-form-actions from form styles */
.af-filter-section {
  padding: 16px; background: var(--af-surface); border: 1px solid var(--af-border);
  border-radius: var(--af-radius-lg); box-shadow: var(--af-shadow-card); margin-bottom: 16px;
}
.af-filter-section .af-form-fields { gap: 12px; }
.af-filter-section .af-form-actions { margin-top: 12px; padding-top: 12px; padding-bottom: 8px; }
.af-filter-select, .af-filter-input { min-width: 150px; }
.af-filter-section .af-btn-filter {
  background: var(--af-primary); color: #fff; border: none; border-radius: var(--af-radius);
  cursor: pointer; padding: 6px 16px;
}
.af-filter-section .af-btn-filter:hover { background: var(--af-primary-hover); }
.af-btn-clear {
  background: transparent; color: var(--af-text-muted); border: 1px solid var(--af-border-strong);
  border-radius: var(--af-radius); cursor: pointer; padding: 6px 16px;
}
.af-btn-clear:hover { background: var(--af-surface-raised); color: var(--af-text); }

/* Grid Modal (inline-editable popup) */
.af-modal-wide { max-width: 600px; }
.af-grid-modal-body { margin-top: 0; }
.af-inline-grid { width: 100%; border: 1px solid var(--af-border); border-radius: var(--af-radius); }
.af-inline-grid th { font-size: 11px; padding: 6px 8px; position: static; }
.af-inline-grid td { padding: 2px 4px; }
.af-inline-grid .af-grid-td:first-child { padding-left: 4px; font-weight: 400; }
.af-inline-grid .af-grid-th:first-child { padding-left: 8px; }
.af-inline-input {
  width: 100%; border: 1px solid transparent; background: transparent;
  padding: 4px 6px; font-size: 13px; font-family: inherit; border-radius: 4px;
}
.af-inline-input:focus {
  border-color: var(--af-primary); background: var(--af-surface); outline: none; box-shadow: var(--af-focus-ring);
}
.af-btn-icon {
  background: none; border: none; cursor: pointer; color: var(--af-text-muted);
  padding: 4px; font-size: 12px; border-radius: 4px;
}
.af-btn-icon:hover { color: var(--af-danger); }
.af-grid-modal-footer { padding: 8px 0 0; }

/* Lookup */
.af-lookup-wrapper { position: relative; }
.af-lookup-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--af-surface);
  border: 1px solid var(--af-border); border-radius: 8px;
  box-shadow: var(--af-shadow-popover); z-index: 100; max-height: 200px; overflow-y: auto;
}
.af-lookup-results:empty { display: none; }
.af-lookup-option { padding: 7px 12px; cursor: pointer; font-size: 13px; }
.af-lookup-option:hover { background: var(--af-primary-soft); }
.af-lookup-empty { padding: 7px 12px; color: var(--af-text-muted); font-size: 13px; }

/* Toggle */
.af-toggle-label { display: inline-flex; align-items: center; cursor: pointer; }
.af-toggle { position: absolute; opacity: 0; pointer-events: none; }
.af-toggle-slider {
  width: 40px; height: 22px; background: var(--af-border-strong); border-radius: 11px;
  position: relative; transition: background 0.2s;
}
.af-toggle-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.2);
}
.af-toggle:checked + .af-toggle-slider { background: var(--af-primary); }
.af-toggle:checked + .af-toggle-slider::after { transform: translateX(18px); }
.af-toggle:focus-visible + .af-toggle-slider { box-shadow: var(--af-focus-ring); }

/* Checkbox */
.af-checkbox-label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.af-checkbox { width: 16px; height: 16px; accent-color: var(--af-primary); }

/* Assign section: heading rows over the rows they tick, a narrow tick column */
.af-assign-heading .af-grid-td { background: var(--af-surface-raised); font-weight: 600; }
.af-assign-heading ~ .af-assign-row > .af-grid-td:first-child:not(.af-assign-td-tick) { padding-left: 32px; }
.af-assign-th-tick, .af-assign-td-tick { width: 1%; text-align: center; }
.af-assign-tick { width: 16px; height: 16px; accent-color: var(--af-primary); cursor: pointer; vertical-align: middle; }
.af-assign-tick:disabled { cursor: progress; }

/* Money / percent / link / image cells */
.af-td-money, .af-td-percent, .af-th-money, .af-th-percent { text-align: right; }
.af-td-money, .af-td-percent { font-variant-numeric: tabular-nums; }
.af-td-href a { color: var(--af-primary); text-decoration: none; }
.af-td-href a:hover { text-decoration: underline; }
.af-cell-img { max-height: 24px; max-width: 80px; border-radius: 4px; display: block; }
.af-input-affix { display: flex; align-items: center; gap: 6px; }
.af-input-affix .af-input { flex: 1; min-width: 0; }
.af-affix { color: var(--af-text-muted); font-size: 13px; font-weight: 500; }
.af-image-field { display: flex; align-items: center; gap: 10px; }
.af-image-field .af-input { flex: 1; min-width: 0; }
.af-image-preview { max-height: 40px; max-width: 120px; border-radius: var(--af-radius); border: 1px solid var(--af-border); }

/* Code Editor */
.af-codeeditor-wrapper { border: 1px solid var(--af-border-strong); border-radius: var(--af-radius); overflow: hidden; }
.af-codeeditor { width: 100%; font-family: var(--af-font-mono); font-size: 13px; border: none; }

/* Master-Detail Layout */
.af-master-detail { display: flex; gap: 24px; min-height: 400px; }
.af-master-panel { flex: 1; min-width: 0; }
.af-detail-panel { flex: 1; min-width: 0; }
.af-detail-section {
  /* Flex column so the grid loaded into it can fill the height this wrapper
     carries (inline style from section_height); hidden overflow keeps a
     fixed-height section from spilling — the grid scrolls internally. */
  min-height: 200px; display: flex; flex-direction: column; overflow: hidden;
}
/* Tabbed detail content: extend the flex chain through the tab container so
   the grid's fill sizing works, and let each pane scroll — nested views
   opened into sibling tabs (af.openViewInTab) can exceed a fixed-height
   section and must scroll rather than clip. */
.af-detail-section > .af-tabs { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; margin-top: 0; }
.af-detail-section .af-tab-content { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.af-detail-section .af-tab-pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.af-detail-placeholder {
  display: flex; align-items: center; justify-content: center; height: 200px;
  color: var(--af-text-muted); font-size: 13px; border: 1px dashed var(--af-border-strong);
  border-radius: 8px; background: var(--af-surface-raised);
}
.af-master-row { cursor: pointer; }
.af-master-row:hover { background: var(--af-surface-raised); }
.af-master-row.selected { background: var(--af-primary-soft); box-shadow: inset 2px 0 0 var(--af-primary); }

/* Tabs */
.af-tabs { margin-top: 24px; }
.af-tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--af-border);
  margin-bottom: 16px;
}
.af-tab-btn {
  padding: 9px 16px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; color: var(--af-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.15s, border-color 0.15s;
}
.af-tab-btn:hover { color: var(--af-text); }
.af-tab-btn.active { color: var(--af-primary); border-bottom-color: var(--af-primary); font-weight: 600; }
.af-tab-close { margin-left: 8px; font-size: 15px; color: var(--af-text-muted); cursor: pointer; }
.af-tab-close:hover { color: var(--af-danger); }
.af-tab-content { min-height: 200px; }

/* Sort Icons */
.af-sort-icon { font-size: 10px; color: var(--af-primary); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---- Mobile Skin ---- */

/* Card-based grid */
.af-card-section { margin-bottom: 16px; }
.af-card-section .af-search { background: transparent; border-bottom: none; padding: 0 0 8px; }
.af-mobile-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; margin-bottom: 8px;
}
.af-mobile-toolbar .af-toolbar-title { font-size: 15px; font-weight: 600; }
.af-toolbar-actions { display: flex; gap: 8px; }
.af-mobile-toolbar .af-btn-icon {
  width: 40px; height: 40px; border: none; border-radius: 50%;
  background: var(--af-primary); color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(91, 91, 214, 0.35);
}
.af-mobile-toolbar .af-btn-icon:active { opacity: 0.85; transform: scale(0.95); }
.af-card-list { display: flex; flex-direction: column; gap: 8px; }
.af-card {
  background: var(--af-surface); border: 1px solid var(--af-border); border-radius: var(--af-radius-lg);
  padding: 14px 16px; cursor: pointer;
  transition: border-color 0.15s; box-shadow: inset 2px 0 0 transparent;
}
.af-card:active { border-color: var(--af-border-strong); }
.af-card.selected { box-shadow: inset 2px 0 0 var(--af-primary); background: var(--af-primary-soft); }
.af-card-field { display: flex; justify-content: space-between; padding: 3px 0; }
.af-card-field:first-child { font-weight: 600; font-size: 15px; }
.af-card-label { color: var(--af-text-muted); font-size: 12px; }
.af-card-value { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.af-master-card.selected { box-shadow: inset 2px 0 0 var(--af-primary); background: var(--af-primary-soft); }

/* Mobile form overlay */
.af-mobile-form-overlay {
  position: fixed; inset: 0; background: var(--af-surface); z-index: 1000;
  display: flex; flex-direction: column;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.af-mobile-form-panel { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.af-mobile-form-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  background: var(--af-surface); color: var(--af-text); position: sticky; top: 0;
  border-bottom: 1px solid var(--af-border);
}
.af-mobile-form-header h2 { font-size: 16px; font-weight: 600; }
.af-mobile-back { background: none; border: none; color: var(--af-text); font-size: 22px; cursor: pointer; padding: 4px; }
.af-mobile-form { padding: 16px; flex: 1; }
.af-mobile-form .af-input, .af-mobile-form .af-select, .af-mobile-form .af-textarea {
  padding: 12px; font-size: 16px;
}
.af-mobile-form .af-label { font-size: 12.5px; font-weight: 500; color: var(--af-text-secondary); }
.af-mobile-form-fields { display: flex; flex-direction: column; gap: 16px; }
.af-mobile-form-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; padding-bottom: 24px; }
.af-btn-full { width: 100%; padding: 13px; font-size: 15px; justify-content: center; }
.af-search-input {
  padding: 10px 12px; font-size: 15px; font-family: inherit; border: 1px solid var(--af-border-strong);
  border-radius: var(--af-radius); width: 100%; background: var(--af-surface); color: var(--af-text);
}
.af-search-input:focus { border-color: var(--af-primary); outline: none; box-shadow: var(--af-focus-ring); }

/* Mobile master-detail (stacked) */
.af-mobile-master-detail { display: flex; flex-direction: column; gap: 16px; }
.af-mobile-master { min-height: 0; }
.af-mobile-detail { min-height: 100px; }

/* Session expired: stays until a login in another tab resumes the session */
.af-session-expired {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10001;
  padding: 10px 16px; text-align: center; font-size: 14px; font-weight: 500;
  background: var(--af-danger); color: #fff;
}
.af-session-expired a { color: #fff; text-decoration: underline; font-weight: 600; }

:root {
  --af-bg: #f4f4f6;
  --af-border: #e4e4e7;
  --af-border-strong: #d4d4d8;
  --af-danger: #dc2626;
  --af-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --af-form-columns: 2;
  --af-grid-row-height: 36px;
  --af-header-bg: #fff;
  --af-modal-max-width: 700px;
  --af-primary: #5b5bd6;
  --af-primary-hover: #4f4fc9;
  --af-primary-ring: rgba(91, 91, 214, 0.25);
  --af-primary-soft: #eeeefb;
  --af-radius: 6px;
  --af-sidebar-active: #5b5bd6;
  --af-sidebar-bg: #191927;
  --af-sidebar-text: #a1a1b5;
  --af-success: #16a34a;
  --af-surface: #ffffff;
  --af-surface-raised: #fafafb;
  --af-text: #18181b;
  --af-text-muted: #71717a;
  --af-text-secondary: #3f3f46;
  --af-warning: #d97706;
}