/* =========================================================================
   SGAT-JEPMS (BARRANQUILLA) — FRAMED-SHEET JUDICIAL DESIGN SYSTEM
   Mode: Operate · Archetype: Tinted L-Frame, White Sheet · Zero AI-Slop
   ========================================================================= */

:root {
  --ground: #f9fbfc;
  --surface: #ffffff;
  --raised: #f4f6f8;
  --active: #ebedee;
  --border: #e8eaec;
  --rule: #f0f1f2;
  --control: #c6c9ce;
  --text: #131416;
  --muted: #52565b;
  --faint: #63676d;
  --primary: #131416;
  --accent: #1b6c80;
  --positive: #1e7b4f;
  --negative: #c4242a;
  --warning: #92400e;

  --pill-positive-bg: #dcfae5;
  --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea;
  --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fffbeb;
  --pill-warning-ink: #92400e;
  --pill-neutral-bg: #ebedee;
  --pill-neutral-ink: #2f3133;

  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-chip: 4px;
  --sheet-inset: 8px;

  --sidebar-width: 228px;
  --topbar-height: 48px;
  --row-height: 48px;
  --control-height: 36px;
  --gap: 24px;
  --pad: 24px;

  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-title: 22px;
  --fs-section: 16px;
  --fs-kpi: 28px;
  --fs-body: 14px;
  --fs-small: 12px;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

::selection {
  background: #d7ecf1;
  color: #0e3843;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--ground);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar temática discreta */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cfd3d8;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #aeb4bc;
}

a {
  color: inherit;
  text-decoration: none;
}

.mono, code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   1. SHELL: TINTED L-FRAME & WHITE SHEET
   ========================================================================= */
.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) minmax(calc(100vh - var(--topbar-height)), auto);
  min-height: 100vh;
  background: var(--ground);
}

.app-sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--ground);
  border-right: 1px solid var(--border);
  box-sizing: border-box;
  z-index: 20;
}

.app-sidebar-nav-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand-text-wrap {
  min-width: 0;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.brand-scope {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-group {
  margin-top: 12px;
}

.nav-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 10px 6px;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.nav-link-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.nav-link svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.6;
  flex: none;
}

.nav-link:hover {
  background: #eff2f4;
  color: var(--text);
}

.nav-link.is-active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-count {
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
  flex: none;
}

.nav-count.is-urgent {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

.sidebar-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--ground);
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

/* Topbar (Sin regla divisoria contra sidebar — L-Frame puro) */
.app-topbar {
  grid-column: 2;
  grid-row: 1;
  height: var(--topbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--ground);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-search {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 560px;
}

.topbar-search-inner {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
}

.topbar-search-inner .search-icon {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}

.topbar-search-inner input {
  width: 100%;
  height: 34px;
  padding: 0 30px 0 34px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

.topbar-search-inner input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(11, 87, 208, 0.12);
}

.search-clear-btn {
  position: absolute;
  right: 84px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
}

.search-clear-btn:hover {
  color: var(--text);
  background: var(--border);
}

.search-submit-btn {
  height: 34px;
  padding: 0 14px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  flex: none;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* White Sheet */
.app-sheet {
  grid-column: 2;
  grid-row: 2;
  margin: 0 var(--sheet-inset) var(--sheet-inset) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  padding: var(--pad);
  min-width: 0;
}

/* =========================================================================
   2. PAGE HEADER, TABS & DIVIDED KPI STRIP
   ========================================================================= */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
  line-height: 1.25;
}

.page-subline {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
  max-width: 72ch;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Divided KPI Strip (sin iconos en círculos ni sparklines — app-screens.md §5) */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  margin-bottom: var(--gap);
}

.kpi-cell {
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: var(--fs-kpi);
  font-weight: 400;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.kpi-value.is-urgent {
  color: var(--negative);
  font-weight: 500;
}

.kpi-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* Underline Tabs (framed-sheet 2px underline) */
.underline-tabs {
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-item {
  padding: 0 2px 10px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab-item:hover {
  color: var(--text);
}

.tab-item.is-active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--accent);
}

/* =========================================================================
   3. TABLES & SIGNATURE 10-DAY CONSTITUTIONAL TRACK
   ========================================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  height: 38px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  font-size: 14px;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

@media (hover: hover) and (pointer: fine) {
  .data-table tbody tr:hover {
    background-color: #fafbfc;
  }
}

.data-table tbody tr.row-urgent-art7 {
  background-color: #fff6f5;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

/* Elemento Firma: Barra Constitucional de 10 Días Hábiles */
.term-widget {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 158px;
}

.term-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.term-track {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  height: 6px;
}

.term-seg {
  border-radius: 1px;
  background: #e6e8eb;
}

.term-seg.is-green {
  background: var(--positive);
}

.term-seg.is-amber {
  background: #c8800e;
}

.term-seg.is-red {
  background: var(--negative);
}

/* =========================================================================
   4. PILLS, ALERTS & PANELS
   ========================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-chip);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
}

.pill-positive {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}

.pill-negative {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

.pill-warning {
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
}

.pill-neutral {
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--negative);
  animation: pulseDot 1.6s ease-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.88); }
}

.notice-bar {
  padding: 12px 16px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--raised);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.notice-bar.is-danger {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
  border-color: #f3c1be;
}

.notice-bar.is-warning {
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
  border-color: #fde68a;
}

.notice-bar.is-success {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
  border-color: #b7ebd0;
}

/* Panels & Split Layout for Triage / Procedibilidad */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
  gap: var(--gap);
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 20px;
  margin-bottom: 20px;
}

.panel-subtle {
  background: var(--raised);
  border-color: var(--border);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.panel-title {
  margin: 0;
  font-size: var(--fs-section);
  font-weight: 600;
  color: var(--text);
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.kv-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.kv-key {
  color: var(--muted);
  flex: none;
}

.kv-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

/* =========================================================================
   5. FORMS, PRESET CHIPS & BUTTONS
   ========================================================================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field-hint {
  font-size: 12px;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: border-color 140ms var(--ease-out);
}

input:not([type="checkbox"]):not([type="radio"]),
select {
  height: 38px;
}

textarea {
  min-height: 92px;
  line-height: 1.5;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* Buttons (emil-design-eng: scale(0.98) on :active, <160ms ease-out) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: var(--control-height);
  padding: 0 14px;
  border-radius: var(--radius-control);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 140ms var(--ease-out), background-color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}

.btn:active {
  transform: scale(0.98);
}

.btn svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.7;
  flex: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: #272a2e;
}

.btn-accent {
  background: var(--accent);
  color: #ffffff;
}

.btn-accent:hover {
  background: #155768;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--control);
}

.btn-secondary:hover {
  background: var(--raised);
}

.btn-danger-outline {
  background: var(--surface);
  color: var(--negative);
  border-color: #e6b3b5;
}

.btn-danger-outline:hover {
  background: var(--pill-negative-bg);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* Preset buttons strip */
.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.preset-chip:hover {
  background: var(--active);
  border-color: var(--control);
}

.preset-chip:active {
  transform: scale(0.98);
}

/* Gate Cards in Decision Trees */
.gate-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface);
}

.gate-box.is-failed {
  border-color: #eab6b8;
  background: #fffafa;
}

.doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  margin-bottom: 8px;
  background: var(--surface);
}

.doc-item-meta {
  min-width: 0;
}

.doc-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
}

.doc-item-sub {
  font-size: 11px;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

/* =========================================================================
   5B. DIALOG MODAL, FORM SECTIONS & GROUP SCOPE BAR (DESIGN.MD FRAMED-SHEET)
   ========================================================================= */
.sgat-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  background: var(--surface);
  color: var(--text);
  overflow: auto;
}

.sgat-dialog::backdrop {
  background: rgba(19, 20, 22, 0.38);
}

.sgat-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.sgat-dialog-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.sgat-dialog-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.sgat-dialog-body {
  padding: 18px 20px;
}

.sgat-dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--raised);
}

.form-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  margin: 20px 0 14px;
  border-bottom: 1px solid var(--border);
}

.form-section-head:first-child {
  margin-top: 0;
}

.form-section-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-section-note {
  font-size: 12px;
  color: var(--muted);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.inline-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
  flex: none;
}

.scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--raised);
}

.scope-bar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.scope-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-right: 4px;
}

.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.scope-chip:hover {
  color: var(--text);
  border-color: var(--control);
}

.scope-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.responsibility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--raised);
  font-size: 13px;
}

.preset-chip.is-add-entity {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent);
}

.preset-chip.is-add-entity:hover {
  background: #edf6f8;
}

/* =========================================================================
   6. RESPONSIVE & ACCESSIBILITY (PREFERS-REDUCED-MOTION & PHONE FOLD)
   ========================================================================= */
@media (max-width: 1080px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-cell:nth-child(2) {
    border-right: none;
  }
  .kpi-cell:nth-child(1),
  .kpi-cell:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 820px) {
  .app-frame {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .app-sidebar {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .app-topbar {
    grid-column: 1;
    grid-row: 2;
    padding: 0 16px;
  }
  .app-sheet {
    grid-column: 1;
    grid-row: 3;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    padding: 16px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* User Actions Popover Dropdown */
.user-actions-dropdown {
  position: relative;
  display: inline-block;
  text-align: left;
}

.user-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 100;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
  padding: 6px 0;
  display: flex;
  flex-direction: column;
}

.user-menu-popover.is-hidden {
  display: none !important;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: background-color 120ms ease;
}

.user-menu-item:hover {
  background: var(--ground);
}

.user-menu-item svg {
  flex: none;
}

.user-menu-item.is-danger {
  color: var(--negative);
}

.user-menu-item.is-danger:hover {
  background: rgba(186, 26, 26, 0.08);
}

.user-menu-item.is-positive {
  color: #137333;
}
