  :root {
    --bg: #f3efe5;
    --bg-accent: #e6f1e8;
    --surface: rgba(255, 252, 247, 0.92);
    --surface-strong: #fffdfa;
    --line: #d8ddd4;
    --text: #1b2d23;
    --muted: #597062;
    --green: #1d6b4f;
    --green-strong: #15513c;
    --gold: #d7a84c;
    --shadow: 0 18px 40px rgba(27, 45, 35, 0.09);
    --radius: 22px;
    --portal-font-family: "Avenir Next", "Segoe UI", sans-serif;
    --portal-font-size: 16px;
    --portal-font-weight: 500;
    --portal-accent-color: #1d6b4f;
    --portal-text-color: #1b2d23;
    --sidebar-bg: rgba(24, 42, 33, 0.9);
    --sidebar-text: #f5f0e6;
    --sidebar-subtext: rgba(245, 240, 230, 0.72);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.12);
    --sidebar-hover-text: #ffffff;
    --sidebar-card-bg: rgba(255, 255, 255, 0.1);
    --sidebar-card-border: rgba(255, 255, 255, 0.12);
  }

  * {
    box-sizing: border-box;
  }

  body {
    margin: 0;
    font-family: var(--portal-font-family);
    font-size: var(--portal-font-size);
    font-weight: var(--portal-font-weight);
    color: var(--text);
    background:
      radial-gradient(circle at top left, rgba(215, 168, 76, 0.14), transparent 30%),
      radial-gradient(circle at top right, rgba(29, 107, 79, 0.12), transparent 28%),
      linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
  }

  body[data-theme="light"] {
    color-scheme: light;
  }

  body[data-theme="dark"] {
    --bg: #121816;
    --bg-accent: #1a231f;
    --surface: rgba(25, 31, 28, 0.94);
    --surface-strong: #1e2521;
    --line: #314037;
    --text: #edf4ee;
    --muted: #a8b8ae;
    --green: #6ab18a;
    --green-strong: #9ad8b9;
    --gold: #d7a84c;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }

  h1, h2, h3, p {
    margin: 0;
  }

  .app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sidebar {
    padding: 28px 22px;
    border-right: 1px solid var(--sidebar-card-border);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 14px;
  }

  .brand h1 {
    font-size: 22px;
    line-height: 1.1;
    color: var(--sidebar-text);
  }

  .brand p {
    color: var(--sidebar-subtext);
    font-size: 13px;
    margin-top: 4px;
  }

  .brand-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--button-bg, #d7a84c), var(--sidebar-hover-bg, #f5df98));
    color: var(--button-text, #203126);
    font-weight: 800;
    letter-spacing: 0.08em;
  }

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

  .nav-link {
    text-align: left;
    border: 0;
    border-radius: 16px;
    padding: 14px 16px;
    background: transparent;
    color: var(--sidebar-text);
    font-weight: 700;
    cursor: pointer;
  }

  .nav-link:hover,
  .nav-link.is-active {
    background: var(--sidebar-hover-bg, var(--button-bg, var(--sidebar-hover-bg)));
    color: var(--sidebar-hover-text, var(--button-text, var(--sidebar-text)));
  }

  .nav-link:focus-visible,
  button:focus-visible,
  .search-input:focus-visible,
  .select-input:focus-visible,
  input:focus-visible,
  textarea:focus-visible {
    outline: 2px solid var(--button-bg, var(--green));
    outline-offset: 2px;
  }

  .sidebar-card {
    margin-top: auto;
    padding: 18px;
    border-radius: 18px;
    background: var(--sidebar-card-bg);
    border: 1px solid var(--sidebar-card-border);
  }

  .sidebar-card p {
    margin-top: 8px;
    color: var(--sidebar-subtext);
    line-height: 1.5;
    font-size: 14px;
  }

  .main-shell {
    padding: 26px;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 16px;
  }

  .topbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 6px;
  }

  .topbar-clock {
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--green-strong);
    white-space: nowrap;
  }

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

  .lang-picker {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }

  .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
  }

  .search-input,
  .select-input {
    border: 1px solid var(--field-border, var(--line));
    background: var(--field-bg, rgba(255, 255, 255, 0.88));
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text);
    min-height: 44px;
    min-width: 220px;
  }

  .field input[type="color"] {
    width: 100%;
    min-height: 44px;
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--field-border, var(--line));
    background: var(--field-bg, rgba(255, 255, 255, 0.88));
  }

  button {
    border: 0;
    border-radius: 999px;
    padding: 12px 16px;
    background: var(--button-bg, #dde7df);
    color: var(--button-text, var(--text));
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
  }

  button:hover {
    transform: translateY(-1px);
  }

  button.primary {
    background: var(--button-bg, var(--green));
    color: var(--button-text, #fff);
  }

  button.secondary {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--line);
  }

  button.danger {
    background: #a24635;
    color: #fff;
  }

  button.wide {
    width: 100%;
  }

  .status-banner {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--line);
    color: var(--text);
  }

  .status-banner.is-error {
    background: #fff0ec;
    border-color: #f0c1b3;
    color: #8b3624;
  }

  .status-banner.is-success {
    background: #edf8f0;
    border-color: #bed7c4;
    color: var(--green-strong);
  }

  .view-stack {
    display: block;
  }

  .view {
    display: none;
    animation: fadeIn 180ms ease;
  }

  .view.is-active {
    display: block;
  }

  .hero,
  .panel {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
  }

  .hero {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-end;
    margin-bottom: 18px;
  }

  .hero h3 {
    margin-top: 6px;
    font-size: 30px;
    line-height: 1.05;
  }

  .hero p {
    margin-top: 8px;
    max-width: 740px;
    color: var(--muted);
    line-height: 1.6;
  }

  .hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .stats-grid,
  .cases-grid {
    display: grid;
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
  }

  .stat-card {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    min-height: 132px;
    box-shadow: var(--shadow);
  }

  .stat-card .value {
    margin-top: 10px;
    font-size: 38px;
    font-weight: 800;
    line-height: 1;
  }

  .stat-card .subtext {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
  }

  .two-column {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 18px;
  }

  .panel {
    padding: 20px;
  }

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

  .toolbar-controls,
  .toolbar-group {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
  }

  .stack-list,
  .action-stack,
  .link-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .priority-item,
  .recent-item,
  .case-card,
  .progress-item,
  .reminder-item {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 18px;
  }

  .priority-item,
  .recent-item,
  .progress-item,
  .reminder-item {
    padding: 14px 16px;
  }

  .priority-item h4,
  .recent-item h4,
  .case-card h4 {
    margin: 0;
    font-size: 18px;
  }

  .muted,
  .meta-line,
  .inline-note,
  .panel-note {
    color: var(--muted);
  }

  .panel-note,
  .inline-note {
    line-height: 1.55;
  }

  .inline-note {
    margin-bottom: 14px;
  }

  .cases-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  }

  .case-card {
    padding: 18px;
  }

  .case-card-top,
  .case-card-meta,
  .mini-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .case-card-top {
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  .case-card-meta {
    margin: 12px 0;
  }

  .meta-chip,
  .status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 800;
  }

  .meta-chip {
    background: #edf3ee;
    color: var(--muted);
  }

  .status-pill {
    background: #f1ead4;
    color: #7a5a16;
  }

  .status-pill.status-assigned,
  .status-pill.status-confirmed,
  .status-pill.status-completed {
    background: #e5f4e8;
    color: #20603f;
  }

  .status-pill.status-waiting-for-responses,
  .status-pill.status-partially-assigned {
    background: #fff3df;
    color: #8a5d0a;
  }

  .progress-number {
    font-size: 28px;
    font-weight: 800;
    color: var(--green-strong);
    line-height: 1;
  }

  .progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e7ece6;
    overflow: hidden;
    margin: 10px 0;
  }

  .progress-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #d7a84c 0%, #2b7e5c 100%);
  }

  .reminder-item.reminder-urgent {
    border-color: #e5b2a7;
    background: #fff3ef;
  }

  .reminder-item.reminder-warning {
    border-color: #ead6a3;
    background: #fff9ea;
  }

  .reminder-item.reminder-info {
    border-color: #c9d8cf;
    background: #f7fbf8;
  }

  .case-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
  }

  .detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) 360px;
    gap: 18px;
  }

  .detail-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 18px;
  }

  .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
  }

  .workspace-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
  }

  .summary-chip {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: var(--surface-strong);
  }

  .summary-chip.is-highlight {
    background: linear-gradient(180deg, rgba(29, 107, 79, 0.10), rgba(29, 107, 79, 0.04));
    border-color: rgba(29, 107, 79, 0.28);
  }

  .summary-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
  }

  .summary-value {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    line-height: 1.45;
  }

  .label-count {
    margin-left: 8px;
    font-size: 12px;
    font-weight: 800;
    color: var(--green);
    text-transform: none;
    letter-spacing: normal;
  }

  .detail-block,
  .detail-section {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
  }

  .detail-section + .detail-section {
    margin-top: 12px;
  }

  .label {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
  }

  .value {
    line-height: 1.55;
  }

  .value-notes {
    white-space: pre-wrap;
  }

  .action-link {
    color: var(--green);
    text-decoration: none;
    font-weight: 700;
  }

  .link-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .empty-state {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow);
    border-radius: 24px;
    padding: 36px;
    text-align: center;
  }

  .empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 20px;
    display: grid;
    place-items: center;
    background: #e6f1e8;
    color: var(--green);
    font-size: 30px;
    font-weight: 800;
  }

  .simple-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.7;
  }

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

  .modal-shell {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
  }

  .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(16, 28, 22, 0.48);
    backdrop-filter: blur(4px);
  }

  .modal-card {
    position: relative;
    width: min(860px, 100%);
    max-height: calc(100vh - 48px);
    overflow: auto;
    background: var(--surface-strong);
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 28px;
    box-shadow: 0 30px 70px rgba(15, 29, 22, 0.24);
    padding: 22px;
  }

  .modal-head,
  .modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }

  .modal-actions {
    margin-top: 20px;
    justify-content: flex-end;
  }

  .login-overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 28px;
    background: rgba(10, 18, 14, 0.52);
    backdrop-filter: blur(6px);
  }

  .login-card {
    width: min(520px, 100%);
    padding: 28px;
    background: var(--surface-strong);
  }

  .login-card h3 {
    margin: 8px 0 6px;
    font-size: 28px;
  }

  .login-form {
    margin-top: 18px;
  }

  .icon-button {
    background: var(--field-bg, #edf3ee);
    color: var(--text);
  }

  .editor-form {
    margin-top: 18px;
  }

  .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
  }

  .field span {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
  }

  .field-help {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
  }

  .field input,
  .field textarea,
  .field select {
    width: 100%;
    border: 1px solid var(--field-border, var(--line));
    background: var(--field-bg, #fff);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text);
    font: inherit;
  }

  .checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .checkbox-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--field-border, var(--line));
    border-radius: 14px;
    background: var(--field-bg, rgba(255, 255, 255, 0.88));
    color: var(--text);
    font-size: 14px;
  }

  .checkbox-chip input {
    width: 16px;
    height: 16px;
    margin: 0;
  }

  .catalog-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .directory-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
  }

  .directory-category-card {
    border-radius: 20px;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(242,247,243,0.92));
    padding: 18px 16px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 126px;
    text-align: left;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  }

  .directory-category-card strong {
    font-size: 17px;
    line-height: 1.25;
  }

  .directory-card-subtitle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
  }

  .directory-category-card.is-active {
    background: linear-gradient(180deg, rgba(29,107,79,0.95), rgba(21,81,60,0.95));
    color: #fff;
    border-color: rgba(29,107,79,0.95);
    box-shadow: 0 14px 30px rgba(29, 107, 79, 0.18);
  }

  .directory-category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(27, 45, 35, 0.12);
  }

  .directory-category-card.is-active .eyebrow {
    color: rgba(255,255,255,0.76);
  }

  .sidebar-card .primary,
  .sidebar-card .secondary,
  .sidebar-card button {
    width: 100%;
  }

  .sidebar-card .primary {
    background: var(--button-bg, var(--green));
    color: var(--button-text, #fff);
  }

  .directory-editor-shell,
  .directory-reference-shell {
    margin-top: 16px;
  }

  .directory-toolbar {
    align-items: flex-end;
    gap: 12px;
  }

  .directory-select-field {
    min-width: 240px;
  }

  .directory-input-field {
    flex: 1;
  }

  .directory-toolbar.is-reference-mode {
    display: none;
  }

  .skeleton {
    position: relative;
    overflow: hidden;
  }

  .skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmer 1.3s infinite;
  }

  @keyframes shimmer {
    100% {
      transform: translateX(100%);
    }
  }

  @keyframes fadeIn {
    from {
      opacity: 0;
      transform: translateY(4px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

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

    .sidebar {
      position: static;
      height: auto;
    }

    .stats-grid,
    .two-column,
    .detail-layout {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 760px) {
    .main-shell,
    .sidebar {
      padding: 18px;
    }

    .hero,
    .topbar,
    .toolbar,
    .detail-header {
      flex-direction: column;
      align-items: stretch;
    }

    .search-input,
    .select-input {
      min-width: 0;
      width: 100%;
    }

    .cases-grid,
    .stats-grid,
    .detail-grid,
    .form-grid {
      grid-template-columns: 1fr;
    }
  }
