/**
 * MSWDO CMS — layout & theme (mockup-aligned)
 */

:root {
  --green-900: #1b4332;
  --green-800: #2d6a4f;
  --green-700: #40916c;
  --green-100: #d8f3dc;
  --green-50: #f1faef;
  --gold: #f5cb5c;
  --gold-soft: #fff3cd;
  --surface: #ffffff;
  --bg: #f8f9fa;
  --border: #e9ecef;
  --text: #212529;
  --muted: #6c757d;
  --blue-status: #4dabf7;
  --blue-soft: #e7f5ff;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.07);
  --sidebar-w: 252px;
  --workspace-radius: 1.5rem;
  --layout-pad: 1rem;
  --nav-scoop: 1.25rem;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Sidebar + mobile bar (green shell) — balanced MSWDO green */
  --nav-green-deep: #1b4332;
  --nav-green-mid: #2d6a4f;
  --nav-green-accent: #40916c;
  --nav-text: rgba(255, 255, 255, 0.94);
  --nav-text-muted: rgba(255, 255, 255, 0.72);
  --nav-edge: rgba(255, 255, 255, 0.18);
  --nav-hover: rgba(255, 255, 255, 0.12);
  --nav-active-bg: #ecfdf5;
  --nav-active-fg: #1b4332;
  /* Connected shell layout (sidebar + main panel) */
  --sidebar-shell-bg: #256b47;
  --layout-panel-bg: #ffffff;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ----- Shell ----- */
.appShell {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar (green shell) ----- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-shell-bg);
  border-right: none;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  position: relative;
  color: var(--nav-text);
}

.sidebar.collapsed {
  width: 72px;
}

.sidebar.collapsed .sidebar__text,
.sidebar.collapsed .sidebar__label {
  display: none;
}

.sidebar.collapsed .sidebar__link {
  justify-content: center;
}

.sidebar__collapse {
  align-self: flex-end;
  width: 32px;
  height: 32px;
  border: 1px solid var(--nav-edge);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  margin-bottom: -0.5rem;
  transition: background 0.15s, border-color 0.15s;
}

.sidebar__collapse:hover {
  background: var(--nav-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

.sidebar__collapse::before {
  content: "⟨";
  font-size: 1rem;
  color: var(--nav-text-muted);
}

.sidebar.collapsed .sidebar__collapse::before {
  content: "⟩";
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--nav-edge);
}

.sidebar__logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.sidebar__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.sidebar__title {
  display: block;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.3;
  color: #fff;
  letter-spacing: 0.01em;
}

.sidebar__subtitle {
  display: block;
  font-size: 0.78rem;
  color: var(--nav-text-muted);
  margin-top: 0.1rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--nav-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* display:flex above beats default [hidden]; keep User Management hidden for staff */
.sidebar__link[hidden] {
  display: none !important;
}

.sidebar__link:hover {
  background: var(--nav-hover);
}

.sidebar__link--active {
  font-weight: 600;
}

.sidebar__ico {
  display: flex;
  color: var(--nav-text-muted);
  flex-shrink: 0;
}

.sidebar__foot {
  margin-top: auto;
  padding: 0 0.5rem 0.25rem;
  border-top: 1px solid var(--nav-edge);
  padding-top: 0.85rem;
}

.sidebar__logout {
  width: 100%;
  justify-content: center;
}

.sidebar .sidebar__logout.btn--ghost {
  color: var(--nav-text);
  border: 1px solid var(--nav-edge);
  background: rgba(0, 0, 0, 0.15);
}

.sidebar .sidebar__logout.btn--ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
}

/* Desktop: reference-style connected nav + rounded main panel (green theme kept) */
@media (min-width: 769px) {
  body {
    background: var(--sidebar-shell-bg);
  }

  .appShell {
    align-items: stretch;
    padding: var(--layout-pad) var(--layout-pad) var(--layout-pad) 0;
    min-height: 100vh;
    box-sizing: border-box;
  }

  .sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    border-right: none;
    padding: 1.15rem 0 1.15rem 1rem;
    z-index: 2;
    background: var(--sidebar-shell-bg);
  }

  .sidebar__brand {
    margin-right: 0.35rem;
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--nav-edge);
  }

  .sidebar__nav {
    gap: 0.25rem;
    padding-right: 0;
  }

  .sidebar__link {
    border-radius: 0.85rem 0 0 0.85rem;
    padding: 0.8rem 1rem;
    margin-right: 0;
  }

  .sidebar__link:hover:not(.sidebar__link--active) {
    background: var(--nav-hover);
  }

  .sidebar__link--active {
    background: var(--layout-panel-bg);
    color: var(--nav-active-fg);
    font-weight: 600;
    box-shadow: none;
    border-radius: 0.9rem 0 0 0.9rem;
    position: relative;
    z-index: 12;
    padding-right: 1.1rem;
  }

  .sidebar__link--active .sidebar__ico {
    color: var(--nav-active-fg);
  }

  .sidebar__link--active::before,
  .sidebar__link--active::after {
    content: "";
    position: absolute;
    right: 0;
    width: var(--nav-scoop);
    height: var(--nav-scoop);
    pointer-events: none;
    z-index: 12;
  }

  .sidebar__link--active::before {
    top: calc(var(--nav-scoop) * -1);
    border-bottom-right-radius: var(--nav-scoop);
    box-shadow: calc(var(--nav-scoop) / 2) calc(var(--nav-scoop) / 2) 0 calc(var(--nav-scoop) / 2) var(--layout-panel-bg);
  }

  .sidebar__link--active::after {
    bottom: calc(var(--nav-scoop) * -1);
    border-top-right-radius: var(--nav-scoop);
    box-shadow: calc(var(--nav-scoop) / 2) calc(var(--nav-scoop) / -2) 0 calc(var(--nav-scoop) / 2) var(--layout-panel-bg);
  }

  .workspace {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--layout-panel-bg);
    border-radius: var(--workspace-radius);
    overflow: hidden;
    box-shadow:
      0 12px 40px rgba(0, 0, 0, 0.18),
      0 0 0 1px rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 1;
    min-height: calc(100vh - var(--layout-pad) * 2);
  }

  .workspace > .pageHeader:not([hidden]) {
    background: var(--layout-panel-bg);
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
  }

  .workspace > .main {
    flex: 1;
    min-height: 0;
    background: var(--bg);
  }

  .workspace > .appFooter {
    flex-shrink: 0;
    background: var(--layout-panel-bg);
    border-top: 1px solid var(--border);
  }

  .sidebar.collapsed {
    width: 72px;
    padding-left: 0.65rem;
  }

  .sidebar.collapsed .sidebar__link {
    border-radius: var(--radius-sm);
    padding: 0.7rem;
    justify-content: center;
  }

  .sidebar.collapsed .sidebar__link--active {
    background: var(--layout-panel-bg);
    color: var(--nav-active-fg);
    border-radius: var(--radius-sm);
    margin-right: 0.35rem;
  }

  .sidebar.collapsed .sidebar__link--active::before,
  .sidebar.collapsed .sidebar__link--active::after {
    display: none;
  }
}

/* ----- Login page (standalone login.php) ----- */
body.loginPage {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 14px;
  color: #374151;
  /* Photo + layered washes so the image reads softly and stays on-brand */
  background-color: #1a2f24;
  background-image: radial-gradient(ellipse 110% 90% at 50% -10%, rgba(255, 255, 255, 0.45) 0%, transparent 52%),
    radial-gradient(ellipse 85% 70% at 100% 100%, rgba(245, 203, 92, 0.22) 0%, transparent 55%),
    radial-gradient(ellipse 75% 65% at 0% 100%, rgba(27, 115, 57, 0.4) 0%, transparent 50%),
    linear-gradient(
      160deg,
      rgba(27, 67, 50, 0.78) 0%,
      rgba(27, 115, 57, 0.42) 42%,
      rgba(248, 249, 250, 0.55) 100%
    ),
    url("image/bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

@media (max-width: 768px) {
  body.loginPage {
    background-attachment: scroll;
  }
}

@media (max-width: 480px) {
  .loginShell {
    padding: 0.75rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    align-items: flex-start;
  }

  .loginCard {
    padding: 1.35rem 1.15rem 1.2rem;
    border-radius: 10px;
  }

  .loginCard__title {
    font-size: 1.35rem;
  }

  .loginCard__subtitle {
    font-size: 0.78rem;
  }

  /* 16px+ avoids iOS zoom on field focus */
  .loginInput {
    font-size: 16px;
  }

  .loginBtn {
    min-height: 48px;
    font-size: 1rem;
  }

  .loginShowPw {
    font-size: 0.8rem;
    min-height: 44px;
    padding: 0.25rem 0.5rem;
  }
}

.loginShell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.loginCard {
  --login-primary: #1b7339;
  width: 100%;
  max-width: 420px;
  padding: 2rem 2rem 1.5rem;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-top: 3px solid var(--login-primary);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(27, 115, 57, 0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.loginCard__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.loginCard__icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.loginCard__iconSvg {
  display: block;
}

.loginCard__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--login-primary);
  letter-spacing: -0.02em;
}

.loginCard__subtitle {
  margin: 0.4rem 0 0;
  font-size: 0.8125rem;
  color: #6b7280;
  line-height: 1.4;
}

.loginForm {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.loginField__label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4b5563;
}

.loginInput {
  width: 100%;
  box-sizing: border-box;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  color: #111827;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.loginInput::placeholder {
  color: #9ca3af;
}

.loginInput:hover {
  border-color: #d1d5db;
}

.loginInput:focus {
  outline: none;
  border-color: rgba(27, 115, 57, 0.45);
  box-shadow: 0 0 0 3px rgba(27, 115, 57, 0.12);
}

.loginPasswordWrap {
  position: relative;
}

.loginInput--withToggle {
  padding-right: 4.25rem;
}

.loginShowPw {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.35rem 0.4rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #1b7339;
  cursor: pointer;
  border-radius: 4px;
}

.loginShowPw:hover {
  text-decoration: underline;
}

.loginErr {
  margin: -0.25rem 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #c92a2a;
}

.loginBtn {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.8rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  background: #1b7339;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(27, 115, 57, 0.25);
  transition: background 0.15s, transform 0.05s;
}

.loginBtn:hover {
  background: #165a2e;
}

.loginBtn:active {
  transform: translateY(1px);
}

.loginForgot {
  margin: 1.25rem 0 0;
  text-align: center;
}

.loginForgot__link {
  font-size: 0.8125rem;
  color: #6b7280;
  text-decoration: none;
}

.loginForgot__link:hover {
  color: #1b7339;
  text-decoration: underline;
}

.loginFooter {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e5e7eb;
}

.loginFooter__copy {
  margin: 0;
  text-align: center;
  font-size: 0.7rem;
  color: #9ca3af;
  line-height: 1.45;
}

.btn--block {
  width: 100%;
  justify-content: center;
}

.appRoot {
  min-height: 100vh;
}

/* ----- Mobile navigation (hidden on large screens) ----- */
.navScrim,
.mobileBar {
  display: none;
}

.mobileBar {
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: linear-gradient(90deg, var(--nav-green-deep) 0%, var(--nav-green-mid) 55%, #15803d 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
  color: var(--nav-text);
}

.mobileBar__menuBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -0.25rem;
  margin-left: -0.35rem;
  padding: 0;
  border: 1px solid var(--nav-edge);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.mobileBar__menuBtn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
}

.mobileBar__menuBtn:focus-visible {
  outline: 2px solid rgba(190, 242, 100, 0.65);
  outline-offset: 2px;
}

.mobileBar__menuIcon {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  box-shadow: 0 6px 0 #fff, 0 -6px 0 #fff;
}

.mobileBar__brand {
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
  .navScrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1990;
    margin: 0;
    padding: 0;
    border: none;
    background: rgba(27, 67, 50, 0.5);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .appShell--navOpen .navScrim {
    opacity: 1;
    pointer-events: auto;
  }

  .mobileBar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }

  .appShell {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: min(288px, 88vw);
    max-width: 320px;
    z-index: 2000;
    transform: translateX(-105%);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: env(safe-area-inset-bottom);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .appShell--navOpen .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 36px rgba(0, 0, 0, 0.35);
  }

  /* Drawer always shows labels; ignore desktop collapsed width */
  .sidebar.collapsed {
    width: min(288px, 88vw);
  }

  .sidebar.collapsed .sidebar__text,
  .sidebar.collapsed .sidebar__label {
    display: block;
  }

  .sidebar.collapsed .sidebar__link {
    justify-content: flex-start;
  }

  .sidebar__collapse {
    display: none;
  }

  .sidebar__link--active {
    background: var(--nav-active-bg);
    color: var(--nav-active-fg);
    box-shadow: inset 3px 0 0 var(--nav-green-accent);
    border-radius: var(--radius-sm);
  }

  .sidebar__link--active .sidebar__ico {
    color: var(--nav-active-fg);
  }

  .sidebar__link--active::before,
  .sidebar__link--active::after {
    display: none;
  }

  body {
    background: var(--bg);
  }

  .appShell {
    padding: 0;
  }

  .workspace {
    width: 100%;
    min-width: 0;
    border-radius: 0;
    box-shadow: none;
    min-height: auto;
  }

  .pageHeader {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 1rem 1rem 0.9rem;
  }

  .pageHeader__title {
    font-size: 1.25rem;
    flex-wrap: wrap;
  }

  .pageHeader__actions,
  .pageHeader__right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
  }

  .pageHeader__right {
    margin-top: 0.25rem;
  }

  .main {
    padding: 1rem 1rem 1.5rem;
  }

  .searchField {
    min-width: 0;
    flex: 1 1 100%;
  }

  .searchRow {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbarCard__extra {
    flex-direction: column;
    align-items: stretch;
  }

  .select--filter {
    min-width: 0;
    width: 100%;
  }

  .statsRow {
    grid-template-columns: 1fr;
  }

  .statCard__value {
    font-size: 1.55rem;
  }

  .formFooter {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .formFooter .btn {
    width: 100%;
    justify-content: center;
  }

  .userManageForm__actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .userManageForm__actions .btn {
    width: 100%;
    justify-content: center;
  }

  .modal {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 2500;
  }

  .modal__dialog {
    max-height: min(92vh, 100dvh);
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0;
  }

  .modal__dialog--sm {
    max-width: 100%;
  }

  /* Case list: fit all columns on narrow screens */
  .caseTable__th--lg {
    display: none;
  }

  .caseTable__th--sm {
    display: inline;
  }

  #viewCasesList .toolbarCard {
    padding: 0.75rem 0.85rem;
  }

  #viewCasesList .panel--table {
    border-radius: var(--radius);
  }

  #viewCasesList .tableScroll {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  #caseTable.caseTable {
    table-layout: fixed;
    width: 100%;
    min-width: 0;
    font-size: 0.7rem;
  }

  #caseTable.caseTable th,
  #caseTable.caseTable td {
    padding: 0.32rem 0.25rem;
    vertical-align: middle;
  }

  #caseTable .caseTable__col--id {
    width: 13%;
  }

  #caseTable .caseTable__col--client {
    width: 21%;
  }

  #caseTable .caseTable__col--cat {
    width: 16%;
  }

  #caseTable .caseTable__col--status {
    width: 13%;
  }

  #caseTable .caseTable__col--days {
    width: 13%;
  }

  #caseTable .caseTable__col--files {
    width: 10%;
    text-align: center;
  }

  #caseTable .caseTable__cellFiles {
    text-align: center;
    font-variant-numeric: tabular-nums;
  }

  #caseTable .caseTable__col--act {
    width: 2.5rem;
    min-width: 2.5rem;
    max-width: 2.5rem;
    padding-left: 0.1rem;
    padding-right: 0.1rem;
    text-align: center;
  }

  #caseTable .caseTable__cellId,
  #caseTable .caseTable__cellClient {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #caseTable .caseTable__cellId strong,
  #caseTable .caseTable__cellClient strong {
    font-weight: 600;
  }

  #caseTable .caseTable__cellDays {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }

  #caseTable .catPill,
  #caseTable .statusPill {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.05rem 0.26rem;
    max-width: 100%;
    box-sizing: border-box;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  #caseTable .btnKebab {
    font-size: 1.05rem;
    line-height: 1;
    padding: 0.12rem 0.2rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
  }

  #caseTable.caseTable th {
    font-size: 0.6rem;
    letter-spacing: 0.03em;
    line-height: 1.15;
  }
}

/* ----- Admin: Statistics & reports ----- */
.statsReportsLayout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

.statsReportsSidebar {
  padding: 1.15rem 1.2rem;
}

.statsReportsSidebar__title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.statsReportsSidebar__hint {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.statsReportsSidebar__fields {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.statsReportsField .field__label {
  font-size: 0.78rem;
}

.statsReportsField--cases {
  grid-column: 1 / -1;
}

.statsCasesMulti {
  width: 100%;
  min-height: 10rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.82rem;
  line-height: 1.35;
}

.statsCasesMulti option {
  padding: 0.2rem 0.25rem;
}

.statsCasesMulti__hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.caseCategoryPanel__hint {
  margin: 0 0 0.75rem;
}

.caseCategoryChecklist {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8f9fa;
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

.caseCategoryNode {
  margin: 0.15rem 0;
}

.caseCategoryNode--depth0 {
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.caseCategoryNode--depth0:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.caseCategoryChildren {
  margin-left: 0.35rem;
  padding-left: 0.85rem;
  border-left: 2px solid rgba(45, 106, 79, 0.15);
}

.caseCategoryCheck {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.35;
  padding: 0.2rem 0;
}

.caseCategoryCheck--depth0 .caseCategoryCheck__label {
  font-weight: 700;
  color: var(--text);
}

.caseCategoryCheck__input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.caseCategoryCheck__code {
  font-weight: 600;
  color: var(--primary);
}

.caseCategoryCheck__label {
  font-weight: 500;
}

.caseCategoryOtherWrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem 1.6rem;
}

.caseCategoryOtherWrap--disabled {
  opacity: 0.55;
}

.caseCategoryOtherLabel {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.caseCategoryOtherInput {
  flex: 1;
  min-width: 0;
}

.caseTable__catPills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.caseTable__catPills .catPill {
  white-space: normal;
  text-align: left;
}

.caseCategoryDetail {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.caseCategoryDetail__empty {
  margin: 0;
  color: var(--muted);
}

.caseCategoryDetailGroup__head {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.caseCategoryDetailList {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text);
}

.caseCategoryDetailList li + li {
  margin-top: 0.2rem;
}

.statsReportsSidebar__actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.statsReportsSidebar__footnote {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.45;
}

.statsReportsMain {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.statsReportsTop {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.statsReportsCardsRow {
  display: grid;
  grid-template-columns: minmax(200px, 280px);
  gap: 1rem;
}

.statsReportsTotalCard {
  margin: 0;
}

.statsReportsSummaryBar {
  padding: 0.75rem 1rem;
}

.statsReportsCategoryTitle {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.statsReportsCount {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
}

.statsReportsTable th {
  white-space: nowrap;
}

.statsReportsTable tbody tr[data-case-id] {
  cursor: pointer;
}

.statsReportsTable tbody tr[data-case-id]:hover {
  background: #fafbfc;
}

@media (max-width: 960px) {
  .statsReportsLayout {
    grid-template-columns: 1fr;
  }
}

/* ----- User management ----- */
.usersAdminGrid {
  display: grid;
  grid-template-columns: minmax(280px, 380px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .usersAdminGrid {
    grid-template-columns: 1fr;
  }
}

.userManageForm {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.25rem;
}

.userManageForm__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.fieldInline--row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.fieldInline--row .field__label {
  margin-bottom: 0;
}

/* ----- Workspace ----- */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ----- Page headers ----- */
.pageHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

/* Any page header with [hidden] must hide — .pageHeader { display:flex } otherwise overrides UA [hidden] */
.pageHeader[hidden] {
  display: none !important;
}

.pageHeader--hidden[hidden] {
  display: none !important;
}

.pageHeader__left {
  min-width: 0;
  flex: 1 1 auto;
}

.pageHeader__right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.pageHeader__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pageHeader__icon {
  color: var(--green-800);
  display: flex;
}

.pageHeader__subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.pageHeader__subtitle--mono {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

.pageHeader__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green-800);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.userHeaderChip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  max-width: 100%;
  flex-shrink: 0;
  padding: 0;
  border: none;
  outline: none;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.userHeaderChip:hover,
.userHeaderChip:focus,
.userHeaderChip:focus-visible,
.userHeaderChip:active {
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
}

.userHeaderChip__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(45, 106, 79, 0.12);
  color: var(--green-800);
  flex-shrink: 0;
  box-shadow: none;
}

.userHeaderChip__icon svg {
  display: block;
}

.userHeaderChip__name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.25;
  max-width: min(22rem, 100%);
  word-break: break-word;
}

/* ----- App footer ----- */
.appFooter {
  margin-top: auto;
  padding: 0.75rem 1.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.appFooter__copy {
  margin: 0;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.45;
}

/* ----- Main ----- */
.main {
  padding: 1.25rem 1.75rem 2rem;
  flex: 1;
}

.view[hidden] {
  display: none !important;
}

.view--active {
  display: block;
}

/* ----- Dashboard filters ----- */
.dashboardFilters {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.dashboardFilters__hint {
  margin: 0 0 0.65rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.dashboardFilters__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
}

.dashboardFilters__field {
  min-width: 10rem;
  margin: 0;
}

.dashboardFilters__field .select {
  min-width: 9rem;
}

/* ----- Stats ----- */
.statsRow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.statCard {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.statCard__body {
  min-width: 0;
}

.statCard__label {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.statCard__value {
  margin: 0.2rem 0 0;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.statCard__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.statCard--total .statCard__icon {
  background: var(--green-100);
}
.statCard--active .statCard__icon {
  background: #fff4e6;
}
.statCard--terminated .statCard__icon {
  background: var(--blue-soft);
}

.statCard__icon--total::before {
  content: "";
  display: block;
  width: 18px;
  height: 13px;
  border: 2px solid var(--green-800);
  border-radius: 2px;
}

.statCard__icon--active::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 12px solid #d9480f;
}

.statCard__icon--terminated::before {
  content: "";
  display: block;
  width: 10px;
  height: 5px;
  border-left: 3px solid var(--green-800);
  border-bottom: 3px solid var(--green-800);
  transform: rotate(-45deg);
  margin-top: -2px;
}

.urgentMark {
  color: #c92a2a;
  font-weight: 700;
  font-size: 0.85em;
}

.btnKebab__dots {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 -6px 0 currentColor, 0 6px 0 currentColor;
}

/* ----- Charts ----- */
.chartsRow {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .chartsRow {
    grid-template-columns: 1fr;
  }
}

.dashboardOverduePanel {
  margin-top: 1.25rem;
  border-left: 4px solid #f59e0b;
}

tr.dashboardOverdueRow {
  cursor: pointer;
}

tr.dashboardOverdueRow:hover {
  background: #f3f4f6;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.panel--chart .panel__head {
  margin-bottom: 1rem;
}

.panel__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.panel__desc {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.chartBox {
  position: relative;
}

.chartBox canvas {
  width: 100%;
  height: auto;
  display: block;
}

/* Stable layout box so Hi-DPI sizing reads correct CSS dimensions before draw */
#barChart {
  aspect-ratio: 720 / 300;
  width: 100%;
  max-height: 320px;
}

.chartBox--donut canvas {
  width: min(280px, 100%);
  aspect-ratio: 1 / 1;
  height: auto;
}

.chartBox--donut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  justify-content: center;
}

.donutLegend {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 140px;
}

.donutLegend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.donutLegend__dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ----- Toolbar / search ----- */
.toolbarCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.searchRow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.searchField {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.searchField__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: flex;
}

.searchField__input {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg);
}

.searchField__input:focus {
  outline: 2px solid rgba(45, 106, 79, 0.25);
  border-color: var(--green-700);
}

.filterGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.select--filter {
  min-width: 130px;
}

.toolbarCard__extra {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.fieldInline {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.fieldInline__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.fieldInline--compact {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

/* ----- Table ----- */
.panel--table {
  padding: 0;
  overflow: hidden;
}

.tableScroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.casePagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.casePagination[hidden] {
  display: none !important;
}

.casePagination__info {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.casePagination__nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.casePagination__pages {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  min-width: 6.5rem;
  text-align: center;
}

.dataTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.dataTable th,
.dataTable td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.dataTable th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg);
}

.dataTable tbody tr:hover {
  background: #fafbfc;
}

.dataTable__narrow {
  width: 48px;
  text-align: right;
}

/* Case list table: full labels on desktop, short on mobile */
.caseTable__th--sm {
  display: none;
}

.caseTable__th--lg {
  display: inline;
}

.dataTable--dense th,
.dataTable--dense td {
  padding: 0.45rem 0.5rem;
  font-size: 0.8rem;
}

.btnKebab {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.btnKebab:hover {
  background: var(--bg);
  color: var(--text);
}

.caseTable .caseTable__cellDays {
  font-variant-numeric: tabular-nums;
}

/* Category & status pills */
.catPill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--surface, #fff);
  color: var(--text);
  border: 1px solid var(--border, #dee2e6);
}

.statusPill {
  display: inline-flex;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.statusPill--Active {
  background: var(--blue-soft);
  color: #1971c2;
}
.statusPill--Terminated {
  background: var(--green-100);
  color: var(--green-900);
}

.emptyState {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.linkLike {
  background: none;
  border: none;
  color: var(--green-800);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* ----- Case form page layout (wrapper centers reliably; <form> margin:auto can be flaky) ----- */
.caseFormShell {
  width: min(100%, 1680px);
  margin-inline: auto;
  box-sizing: border-box;
}

.caseForm {
  width: 100%;
  max-width: none;
  margin: 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card--flush {
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.formToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__ui {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #ced4da;
  position: relative;
  transition: background 0.2s;
}

.toggle__ui::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
  box-shadow: var(--shadow);
}

.toggle input:checked + .toggle__ui {
  background: var(--green-800);
}

.toggle input:checked + .toggle__ui::after {
  transform: translateX(20px);
}

.toggle__text {
  font-size: 0.9rem;
  font-weight: 500;
}

.formTabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.formTabs__tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.formTabs__tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.formTabs__tab--active {
  background: var(--surface);
  color: var(--green-800);
  font-weight: 600;
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.tabPanels {
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.caseFilesLink {
  font-weight: 600;
  white-space: nowrap;
}

.attachmentsActivePanel {
  margin-top: 0.75rem;
}

.attachmentsUploadRow {
  margin-bottom: 0.5rem;
}

.attachmentsUploadActions {
  margin-bottom: 1rem;
}

.attachmentsList {
  list-style: none;
  margin: 0;
  padding: 0;
}

.attachmentsList__item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.attachmentsList__item:last-child {
  border-bottom: none;
}

.attachmentsList__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.attachmentsList__doc {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green-800);
}

.attachmentsList__name {
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
  color: var(--text);
}

.attachmentsList__dl {
  word-break: break-word;
}

.attachmentsList__meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.attachmentsList__empty,
.attachmentsList__none {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.attachmentsList__err {
  color: #c92a2a;
}

.attachmentsList--readonly .attachmentsList__item {
  justify-content: flex-start;
}

.attachmentsList--readonly .attachmentsList__item--detail {
  flex-direction: column;
  align-items: flex-start;
}

.attachmentsUploadRow input[type="file"] {
  padding: 0.45rem 0.5rem;
}

@media (max-width: 480px) {
  .attachmentsList__item {
    flex-direction: column;
    align-items: stretch;
  }
}

.tabPanel[hidden] {
  display: none !important;
}

.sectionHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.sectionHead__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.sectionHead__hint {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.formGrid {
  display: grid;
  gap: 1rem;
}

.formGrid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.formGrid--3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 900px) {
  .formGrid--3 {
    grid-template-columns: 1fr;
  }
  .formGrid--2 {
    grid-template-columns: 1fr;
  }
}

.field--span2 {
  grid-column: span 2;
}

@media (max-width: 900px) {
  .field--span2 {
    grid-column: span 1;
  }
}

.field__label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.input,
.select,
.textarea {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text);
}

.input--filled,
.select--filled,
.textarea--filled {
  background: var(--bg);
  border-color: var(--border);
}

.input--filled:focus,
.select--filled:focus,
.textarea--filled:focus {
  outline: 2px solid rgba(45, 106, 79, 0.2);
  border-color: var(--green-700);
}

.input--sm {
  padding: 0.45rem 0.55rem;
  font-size: 0.85rem;
}

.fieldHint {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.formFooter {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 0.5rem;
}

.btnRowDel {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  line-height: 1;
  border-radius: 4px;
  color: #e03131;
}

.btnRowDel:hover {
  background: #fff5f5;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.btn--primary {
  background: var(--green-800);
  color: #fff;
}

.btn--primary:hover {
  background: var(--green-900);
}

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

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

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--bg);
}

.btn--sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

.btn__icon {
  font-size: 1rem;
}

.btnIcon {
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.2rem;
}

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

.btnSvg {
  flex-shrink: 0;
}

.pageHeader .btn--primary .btnSvg,
.pageHeader .btn--outline .btnSvg {
  stroke: currentColor;
}

/* ----- Case detail (full page) ----- */
.caseDetailRoot {
  max-width: 1100px;
}

.caseDetailSummary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.caseDetailSummary__main {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.caseDetailSummary__id {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
}

.caseDetailSummary__meta {
  margin: 0;
  color: var(--text);
}

.caseDetailSummary__meta span {
  color: var(--muted);
  font-weight: 500;
  margin-right: 0.35rem;
}

.caseDetailSummary__meta--cats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.caseDetailSummary__catPills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.caseDetailSection {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.caseDetailSection__title {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--green-800);
}

.detailCols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem 1.5rem;
}

.detailKvGroup {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detailCols--wrap {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

@media (max-width: 900px) {
  .detailCols {
    grid-template-columns: 1fr;
  }
}

.detailKv {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detailKv__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.detailKv__value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.detailLongText {
  margin-bottom: 1rem;
}

.detailLongText:last-child {
  margin-bottom: 0;
}

.detailLongText .detailKv__label {
  margin-bottom: 0.35rem;
}

.detailLongText__body {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}

.sigGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 700px) {
  .sigGrid {
    grid-template-columns: 1fr;
  }
}

.sigBlock__name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.sigBlock__line {
  height: 1px;
  background: var(--text);
  opacity: 0.35;
  margin-bottom: 0.35rem;
}

.sigBlock__hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.caseDetailSection .dataTable {
  margin: 0;
}

/* ----- Modal ----- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal[hidden] {
  display: none !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 37, 41, 0.45);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.modal__dialog--sm {
  max-width: 400px;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  margin: 0;
  font-size: 1.1rem;
}

.modal__body {
  padding: 1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.attachmentModalPickerLabel {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.attachmentModalList {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.attachmentModalPreview {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8f9fa;
  overflow: hidden;
}

.attachmentModalPreview__img {
  display: block;
  max-width: 100%;
  max-height: min(52vh, 480px);
  width: auto;
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.attachmentModalPreview__frame {
  display: block;
  width: 100%;
  min-height: 280px;
  height: min(52vh, 480px);
  border: 0;
  background: #fff;
}

.attachmentModalPreview__fallback {
  margin: 0;
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.attachmentModalMeta {
  margin: 0.75rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.attachmentsList--readonly .attachmentDetailView {
  margin-top: 0.35rem;
}

.detailBody section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detailBody h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--green-800);
}

.detailBody dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
  font-size: 0.88rem;
}

.detailBody dt {
  font-weight: 600;
  color: var(--muted);
}

.detailBody dd {
  margin: 0;
}

/* ----- Popover row menu ----- */
.popover {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-height: min(70vh, 320px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 0.35rem;
}

.popover[hidden] {
  display: none !important;
}

.popover__item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border: none;
  background: none;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text);
}

.popover__item:hover {
  background: var(--bg);
}

.popover__item--compact {
  padding-left: 2rem;
  font-size: 0.86rem;
}

.popover__ico {
  flex-shrink: 0;
  color: var(--muted);
}

.popover__item--danger {
  color: #c92a2a;
}

.popover__item--danger .popover__ico {
  color: #c92a2a;
}

.popover__sep {
  height: 1px;
  margin: 0.35rem 0.25rem;
  background: var(--border);
}

.popover--user {
  min-width: 180px;
}

.popover__userLabel {
  margin: 0;
  padding: 0.35rem 0.65rem 0.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

/* ----- Toast ----- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 400;
  padding: 0.75rem 1.15rem;
  background: var(--green-800);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

.toast--err {
  background: #c92a2a;
}

/* Screen / UI printing uses print-form.css (@media print hides .no-print). */
