/* app.css extracted from app_shell.html; keep selectors stable */
    :root {
      --bg: #111827;
      --panel: #1f2937;
      --line: #374151;
      --text: #e5e7eb;
      --muted: #9ca3af;
      --accent: #3b82f6;
      --hover: #334155;
      --left-bg-a: #1f2937;
      --left-bg-b: #111827;
      --folder-active-a: #1e3a8a;
      --folder-active-b: #1d4ed8;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--text);
      font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
      height: 100vh;
      overflow: hidden;
    }
    header {
      height: 56px;
      border-bottom: 1px solid #111827;
      background: #1f2937;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 0 16px;
      font-size: 14px;
      color: #f8fafc;
    }
    .header-left,
    .header-right {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .header-left {
      flex: 1 1 auto;
      overflow: auto;
    }
    .header-logo-link {
      display: inline-flex;
      align-items: center;
      flex: 0 0 auto;
    }
    .header-logo {
      display: block;
      height: 30px;
      width: auto;
      object-fit: contain;
    }
    .header-right {
      flex: 0 0 auto;
      justify-content: flex-end;
    }
    .readonly { color: #0b7a2a; font-weight: 600; }
    header .readonly { color: #93c5fd; }
    header .meta { color: #e5e7eb; }
    header .ctrl-btn {
      border-color: #475569;
      background: #334155;
      color: #f8fafc;
    }
    header .ctrl-btn:hover {
      background: #3b4b60;
      border-color: #64748b;
    }
    header .ctrl-btn.is-active {
      background: #1d4ed8;
      border-color: #1e40af;
      color: #fff;
    }
    .layout {
      height: calc(100vh - 52px);
      display: grid;
      grid-template-columns: 230px 420px 1fr;
      gap: 0;
    }
    .panel {
      background: var(--panel);
      border-right: 1px solid var(--line);
      overflow: auto;
    }
    .auth-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.5);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 120;
    }
    .auth-card {
      width: min(420px, 92vw);
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 14px;
      box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
      padding: 16px;
    }
    #foldersPanel {
      background: linear-gradient(160deg, var(--left-bg-a), var(--left-bg-b));
      padding: 8px;
    }
    .section {
      padding: 8px 8px 3px;
      font-weight: 700;
      font-size: 11px;
      text-transform: uppercase;
      color: #cbd5e1;
    }
    .account-toggle {
      width: 100%;
      border: 0;
      background: rgba(30, 41, 59, 0.8);
      text-align: left;
      padding: 8px 10px;
      font-weight: 700;
      font-size: 11px;
      text-transform: uppercase;
      color: #e5e7eb;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-radius: 12px;
      border: 1px solid #334155;
      margin: 5px 0;
      box-shadow: none;
    }
    .account-toggle:hover {
      background: #0f172a;
      border-color: #475569;
    }
    .account-caret {
      font-size: 10px;
      color: #cbd5e1;
      margin-left: 8px;
      flex: 0 0 auto;
    }
    .folder {
      width: 100%;
      border: 1px solid transparent;
      background: rgba(15, 23, 42, 0.6);
      text-align: left;
      padding: 7px 9px;
      cursor: pointer;
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #e5e7eb;
      border-radius: 10px;
      margin: 2px 0;
      transition: background-color 120ms ease, border-color 120ms ease, transform 120ms ease;
    }
    .folder:hover {
      background: #0f172a;
      border-color: #475569;
      transform: translateX(1px);
    }
    .folder.active {
      background: linear-gradient(135deg, var(--folder-active-a), var(--folder-active-b));
      border-color: #60a5fa;
      color: #f8fafc;
      font-weight: 600;
      box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35);
    }
    .folder-left {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      min-width: 0;
    }
    .folder-caret-toggle {
      width: 12px;
      display: inline-block;
      color: #cbd5e1;
      cursor: pointer;
      user-select: none;
      text-align: center;
      flex: 0 0 12px;
      font-size: 11px;
    }
    .list-header,
    .mail-header {
      position: sticky;
      top: 0;
      background: #0f172a;
      border-bottom: 1px solid #334155;
      padding: 10px 12px;
      z-index: 2;
      font-size: 13px;
      color: var(--muted);
    }
    #contentPanel .mail-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .list-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
    }
    .thread-toggle {
      display: flex;
      align-items: center;
      gap: 6px;
      color: var(--text);
      font-size: 12px;
    }
    .view-controls {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .mail-toolbar {
      display: flex;
      flex-direction: column;
      gap: 8px;
      width: 100%;
    }
    .mail-toolbar-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;
      flex-wrap: wrap;
    }
    .mail-toolbar-left,
    .mail-toolbar-right {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
    }
    .mail-toolbar-search {
      min-width: 220px;
      max-width: 360px;
      margin: 0;
      border: 1px solid #8fa0b8;
      border-radius: 8px;
      background: #1a2434;
      color: #e5e7eb;
      padding: 6px 10px;
      font-size: 12px;
    }
    .mail-toolbar-count {
      border: 1px solid #475569;
      border-radius: 999px;
      background: #0f172a;
      color: #cbd5e1;
      padding: 2px 10px;
      font-size: 11px;
      font-weight: 700;
      white-space: nowrap;
    }
    .ctrl-select {
      border: 1px solid #475569;
      border-radius: 8px;
      background: #0f172a;
      color: #e5e7eb;
      font-size: 12px;
      padding: 4px 8px;
    }
    .ctrl-btn {
      border: 1px solid #475569;
      border-radius: 8px;
      background: #1e293b;
      color: #e5e7eb;
      font-size: 12px;
      padding: 4px 8px;
      cursor: pointer;
    }
    .ctrl-btn:disabled {
      opacity: 0.45;
      cursor: not-allowed;
    }
    .ctrl-btn.is-active {
      background: #1b67c9;
      color: #fff;
      border-color: #1553a4;
    }
    .ctrl-btn.ctrl-btn-create-case {
      background: #1d4d1d;
      border-color: #22c55e;
      color: #dcfce7;
      font-weight: 700;
    }
    .ctrl-btn.ctrl-btn-create-case:hover {
      background: #166534;
      border-color: #4ade80;
      color: #ecfdf5;
    }
    .ctrl-btn.todo-has::after {
      content: attr(data-todo-count);
      margin-left: 6px;
      display: inline-block;
      min-width: 16px;
      height: 16px;
      line-height: 16px;
      text-align: center;
      border-radius: 999px;
      background: #f59e0b;
      color: #111827;
      font-size: 10px;
      font-weight: 700;
    }
    .local-badge {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      color: #bfdbfe;
      background: #1e3a8a;
      border: 1px solid #3b82f6;
      vertical-align: middle;
    }
    .mid-badge {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      color: #fed7aa;
      background: #7c2d12;
      border: 1px solid #fb923c;
      vertical-align: middle;
    }
    .att-badge {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      color: #0f5132;
      background: #d1fae5;
      border: 1px solid #86efac;
      vertical-align: middle;
    }
    .msg-chips {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      flex-wrap: wrap;
    }
    .mail-chip {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 2px 8px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .02em;
      line-height: 1.1;
      border: 1px solid #475569;
      background: #0f172a;
      color: #cbd5e1;
      vertical-align: middle;
      white-space: nowrap;
    }
    .mail-chip-att {
      border-color: #475569;
      background: #111827;
      color: #cbd5e1;
    }
    .mail-chip-case {
      border-color: #3b82f6;
      background: #1e3a8a;
      color: #dbeafe;
    }
    .mail-chip-client {
      border-color: #16a34a;
      background: #14532d;
      color: #dcfce7;
    }
    .mail-item.unread .subject,
    .thread-child.unread .subject {
      font-weight: 700;
    }
    .unread-icon {
      display: inline-block;
      margin-right: 6px;
      font-size: 12px;
      line-height: 1;
      color: #93c5fd;
      vertical-align: middle;
    }
    #analysisPanel {
      padding: 10px;
    }
    .analysis-folder {
      border: 1px solid #334155;
      border-radius: 10px;
      background: #111827;
      margin-bottom: 10px;
      overflow: hidden;
    }
    .analysis-folder-head {
      padding: 8px 10px;
      background: #0f172a;
      border-bottom: 1px solid #334155;
      font-weight: 600;
      font-size: 12px;
      color: #cbd5e1;
    }
    .analysis-item {
      border-top: 1px solid #334155;
      padding: 8px 10px;
      font-size: 12px;
    }
    .analysis-item:first-child { border-top: 0; }
    .analysis-subject {
      color: #93c5fd;
      font-weight: 600;
      cursor: pointer;
      text-decoration: underline;
      text-decoration-color: #60a5fa;
    }
    .analysis-chip {
      display: inline-block;
      margin: 3px 5px 0 0;
      padding: 2px 7px;
      border-radius: 999px;
      border: 1px solid #475569;
      background: #1e293b;
      color: #cbd5e1;
      cursor: pointer;
      font-size: 11px;
    }
    .candidate-box {
      margin-top: 8px;
      border: 1px solid #334155;
      border-radius: 8px;
      padding: 6px 8px;
      background: #0b1220;
    }
    .candidate-row {
      border-top: 1px solid #334155;
      padding: 6px 0;
      font-size: 12px;
    }
    .candidate-row:first-child { border-top: 0; }
    .entity-card {
      border: 1px solid #8fa0b8;
      border-radius: 12px;
      background: #1a2434;
      padding: 10px;
      margin: 10px 0;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
    }
    .entity-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 6px;
    }
    .bk-panel-dark {
      border: 1px solid #8fa0b8;
      border-radius: 8px;
      background: #1a2434;
    }
    .bk-section-head {
      border-bottom: 1px solid #334155;
      background: #0f172a;
    }
    .bk-section-subhead {
      border-bottom: 1px solid #334155;
      background: #0b1220;
    }
    .bk-input-light-border {
      border: 1px solid #93a4bc !important;
      border-radius: 8px;
      background: #0f172a;
      color: #e2e8f0;
    }
    .bk-input-unit {
      color: #cbd5e1;
      font-size: 12px;
    }
    .bk-file-input {
      border: 1px solid #93a4bc;
      border-radius: 8px;
      padding: 6px;
      background: #0f172a;
      color: #e2e8f0;
    }
    .candidate-row.todo-unhandled {
      border: 1px solid #7f1d1d;
      border-radius: 10px;
      padding: 8px;
      background: #2a1212;
      margin: 6px 0;
    }
    .candidate-row.todo-case-card {
      border: 1px solid #8fa0b8;
      border-radius: 12px;
      background: #1a2434;
      padding: 10px;
      margin: 10px 0;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    }
    .candidate-row.todo-case-card.todo-unhandled {
      border: 1px solid #b45309;
      background: #2b1f12;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
    }
    .todo-case-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 6px 8px;
      border: 1px solid #4b5f7a;
      border-radius: 8px;
      background: #0f172a;
      margin-bottom: 8px;
    }
    .todo-case-title {
      font-size: 13px;
      font-weight: 700;
      color: #e2e8f0;
      word-break: break-word;
    }
    .todo-case-meta-badges {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .todo-badge-new {
      display: inline-block;
      margin-left: 8px;
      padding: 1px 8px;
      border-radius: 999px;
      border: 1px solid #f87171;
      background: #7f1d1d;
      color: #fee2e2;
      font-size: 10px;
      font-weight: 700;
      vertical-align: middle;
    }
    .cand-badge {
      display: inline-block;
      margin-left: 6px;
      padding: 1px 6px;
      border-radius: 999px;
      font-size: 10px;
      border: 1px solid #3b82f6;
      background: #1e3a8a;
      color: #dbeafe;
    }
    .cand-warn {
      color: #fdba74;
      font-size: 11px;
      margin-left: 6px;
    }
    .client-section .card {
      border: 1px solid #334155;
      border-radius: 10px;
      background: #111827;
      padding: 10px;
      margin-bottom: 10px;
    }
    .client-section .card__header,
    .client-section .card__summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 8px;
    }
    .client-section .grid { display: grid; gap: 8px; }
    .client-section .grid--2 { grid-template-columns: 1fr 1fr; }
    .client-section .field label { display: block; color: #94a3b8; font-size: 12px; margin-bottom: 2px; }
    .client-section .value { font-size: 13px; color: #e2e8f0; }
    .client-section .badge {
      display: inline-block;
      padding: 2px 8px;
      border-radius: 999px;
      background: #1e3a8a;
      border: 1px solid #3b82f6;
      color: #dbeafe;
      font-size: 11px;
      font-weight: 600;
    }
    .client-section .muted { color: #94a3b8; font-size: 12px; }
    .client-section .sensitive .value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
    .modal-backdrop {
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
      display: none;
      align-items: center;
      justify-content: center;
      z-index: 50;
    }
    .modal-backdrop.modal-top {
      z-index: 80;
    }
    .modal {
      width: min(760px, 92vw);
      max-height: 84vh;
      overflow: auto;
      background: #0f172a;
      border: 1px solid #334155;
      border-radius: 14px;
      box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22);
      padding: 14px;
    }
    .modal-head {
      font-weight: 700;
      margin-bottom: 10px;
    }
    .modal-search {
      width: 100%;
      border: 1px solid #475569;
      border-radius: 8px;
      padding: 8px 10px;
      margin-bottom: 10px;
      font-size: 13px;
      background: #111827;
      color: #e5e7eb;
    }
    .modal-list {
      border: 1px solid #334155;
      border-radius: 10px;
      overflow: auto;
      max-height: 48vh;
      background: #111827;
    }
    .modal-item {
      width: 100%;
      border: 0;
      border-bottom: 1px solid #334155;
      background: transparent;
      text-align: left;
      padding: 8px 10px;
      cursor: pointer;
      font-size: 13px;
    }
    .modal-item:hover { background: #1e293b; }
    .modal-item.active { background: #1e3a8a; color: #e0f2fe; font-weight: 600; }
    .modal-foot {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 10px;
      margin-top: 10px;
    }
    .modal-picked { color: #cbd5e1; font-size: 12px; }
    /* Ensure high contrast inside "Znajdź pasujące maile" modal on dark theme. */
    #caseMatchModalBackdrop .modal {
      background: #0b1220;
      border-color: #334155;
      color: #e5e7eb;
    }
    #caseMatchModalBackdrop .modal-head,
    #caseMatchModalBackdrop label,
    #caseMatchModalBackdrop strong,
    #caseMatchModalBackdrop .candidate-row {
      color: #e5e7eb;
    }
    #caseMatchModalBackdrop .meta {
      color: #cbd5e1;
      white-space: normal;
      overflow: visible;
      text-overflow: clip;
    }
    #caseMatchModalBackdrop .modal-list {
      background: #0f172a;
      border-color: #334155;
    }
    #caseMatchModalBackdrop .candidate-row {
      border-top-color: #334155;
    }
    #caseMatchModalBackdrop .ctrl-select {
      background: #0f172a;
      color: #e5e7eb;
      border-color: #475569;
    }
    #caseDataModalBackdrop.case-drawer-backdrop {
      justify-content: flex-end;
      padding: 0;
      background: rgba(2, 6, 23, 0.58);
    }
    #caseDataModalBackdrop .case-drawer {
      width: min(980px, 96vw);
      height: 100vh;
      max-height: 100vh;
      overflow: hidden;
      background: #0b1220;
      border-left: 1px solid #334155;
      box-shadow: -18px 0 42px rgba(2, 6, 23, 0.55);
      display: grid;
      grid-template-rows: auto 1fr;
      border-radius: 0;
      padding: 0;
    }
    #caseDataModalBackdrop .case-drawer-head {
      position: sticky;
      top: 0;
      z-index: 2;
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      gap: 10px;
      padding: 14px 16px 12px;
      border-bottom: 1px solid #334155;
      background: linear-gradient(180deg, #0f172a, #0b1220);
    }
    #caseDataModalBackdrop .case-drawer-body {
      display: grid;
      grid-template-columns: 260px 1fr;
      min-height: 0;
    }
    #caseDataModalBackdrop .case-drawer-nav {
      border-right: 1px solid #334155;
      padding: 12px;
      overflow: auto;
      background: #0f172a;
      display: grid;
      gap: 6px;
      align-content: start;
    }
    #caseDataModalBackdrop .case-drawer-tab {
      width: 100%;
      text-align: left;
      justify-content: flex-start;
    }
    #caseDataModalBackdrop .case-drawer-tab.is-active {
      border-color: #60a5fa;
      background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
      color: #e0f2fe;
    }
    #caseDataModalBackdrop .case-drawer-divider {
      margin: 6px 0 2px;
      padding-top: 8px;
      border-top: 1px solid #334155;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.04em;
      color: #94a3b8;
      text-transform: uppercase;
    }
    #caseDataModalBackdrop .case-drawer-divider span {
      display: inline-block;
      padding: 0 2px;
    }
    #caseDataModalBackdrop .case-drawer-divider.is-head {
      margin-top: 0;
      padding-top: 0;
      border-top: 0;
    }
    #caseDataModalBackdrop .case-drawer-content {
      padding: 16px;
      overflow: auto;
      display: grid;
      gap: 12px;
      align-content: start;
      background: #0b1220;
    }
    #caseDataModalBackdrop .case-drawer-card {
      border: 1px solid #334155;
      border-radius: 12px;
      background: #111827;
      padding: 12px;
    }
    #caseDataModalBackdrop .case-drawer-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      align-items: center;
    }
    .thread-count {
      display: inline-block;
      min-width: 24px;
      text-align: center;
      padding: 1px 6px;
      border-radius: 999px;
      background: #334155;
      color: #bfdbfe;
      font-size: 11px;
      font-weight: 600;
      margin-left: 6px;
    }
    .mail-item {
      width: 100%;
      border: 1px solid #334155;
      background: #111827;
      text-align: left;
      padding: 10px;
      cursor: pointer;
      border-radius: 12px;
      margin: 6px 8px;
      box-shadow: 0 1px 2px rgba(2, 6, 23, 0.35);
      transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
    }
    .mail-item.entity-card {
      background: linear-gradient(160deg, #182334, #101a2a);
      border-color: #8fa0b8;
      box-shadow: 0 2px 8px rgba(2, 6, 23, 0.45);
    }
    .mail-item:hover {
      border-color: #475569;
      box-shadow: 0 6px 14px rgba(2, 6, 23, 0.45);
      transform: translateY(-1px);
    }
    .mail-item.entity-card:hover {
      border-color: #b7c4d8;
      box-shadow: 0 10px 18px rgba(2, 6, 23, 0.55);
    }
    .mail-item.active {
      background: linear-gradient(140deg, #1e3a8a, #1d4ed8);
      border-color: #60a5fa;
      box-shadow: 0 8px 18px rgba(30, 64, 175, 0.35);
    }
    .thread-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;
    }
    .thread-main-left {
      display: flex;
      align-items: center;
      gap: 6px;
      min-width: 0;
      flex: 1 1 auto;
    }
    .thread-caret {
      width: 14px;
      color: #9ca3af;
      flex: 0 0 14px;
      text-align: center;
      font-size: 10px;
    }
    .thread-children {
      margin: -2px 12px 8px 22px;
      padding: 4px 0 6px;
      border-left: 2px solid #334155;
      background: transparent;
    }
    .thread-child {
      width: 100%;
      border: 1px solid #334155;
      background: #0f172a;
      text-align: left;
      padding: 8px 10px 8px 14px;
      cursor: pointer;
      border-radius: 10px;
      margin: 4px 0 0 10px;
      font-size: 13px;
    }
    .thread-child.entity-card {
      background: linear-gradient(160deg, #141f30, #0f1726);
      border-color: #7f93ad;
    }
    .thread-child-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      width: 100%;
    }
    .thread-child:hover { background: #1e293b; border-color: #475569; }
    .thread-child.entity-card:hover { background: #1d2a3d; border-color: #aebed4; }
    .thread-child.active { background: #1e3a8a; border-color: #60a5fa; }
    .mail-item.in-case,
    .thread-child.in-case {
      border-left: 4px solid #16a34a;
      background: #052e1a;
    }
    .mail-item.in-case:hover,
    .thread-child.in-case:hover {
      background: #064e2a;
    }
    .pick-col {
      width: 24px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      margin-right: 6px;
      flex: 0 0 24px;
    }
    .subject {
      font-weight: 600;
      font-size: 14px;
      color: #f3f4f6;
      margin-bottom: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mail-from-line {
      font-size: 14px;
      font-weight: 700;
      color: #e5edf8;
      line-height: 1.25;
      margin-top: 2px;
      margin-bottom: 4px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mail-subject-line {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      margin-bottom: 4px;
    }
    .mail-subject-line .subject {
      font-size: 14px;
      font-weight: 700;
      margin: 0;
    }
    .mail-snippet-line {
      font-size: 12px;
      color: #9fb0c7;
      line-height: 1.3;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      white-space: normal;
    }
    .subject-row {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      margin-bottom: 4px;
    }
    .flag-dot {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      flex: 0 0 auto;
      border: 1px solid rgba(0, 0, 0, 0.15);
    }
    .flag-red { background: #e44747; }
    .flag-orange { background: #f59a2a; }
    .flag-yellow { background: #f2d549; }
    .flag-green { background: #40b36a; }
    .flag-blue { background: #4d88ff; }
    .flag-purple { background: #9b59b6; }
    .flag-gray { background: #8b96a3; }
    .meta {
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mail-content {
      padding: 14px;
      line-height: 1.45;
      white-space: pre-wrap;
      word-break: break-word;
      font-size: 14px;
    }
    #messages {
      padding: 4px 0 10px;
      background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
      min-height: calc(100% - 46px);
    }
    #contentPanel {
      background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
    }
    #content {
      margin: 10px;
      padding: 14px;
      border: 1px solid #334155;
      border-radius: 14px;
      background: #0f172a;
      box-shadow: 0 4px 14px rgba(2, 6, 23, 0.35);
    }
    .mail-view-wrap {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .mail-view-card {
      border: 1px solid #8fa0b8;
      border-radius: 12px;
      background: #1a2434;
      box-shadow: 0 2px 8px rgba(2, 6, 23, 0.35);
      overflow: hidden;
    }
    .mail-view-card-head {
      padding: 10px 12px;
      border-bottom: 1px solid #41546d;
      background: #223146;
      color: #dbe7f5;
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: .02em;
    }
    .mail-view-meta {
      padding: 10px 12px;
      display: grid;
      gap: 8px;
    }
    .mail-meta-row {
      display: grid;
      grid-template-columns: 56px 1fr;
      gap: 10px;
      align-items: start;
    }
    .mail-meta-label {
      color: #9fb0c7;
      font-size: 12px;
      font-weight: 700;
    }
    .mail-meta-value {
      color: #e6eef9;
      font-size: 13px;
      line-height: 1.35;
      word-break: break-word;
    }
    .mail-status-row {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-wrap: wrap;
      margin-top: 2px;
    }
    .mail-status-chip {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 2px 9px;
      border-radius: 999px;
      font-size: 10px;
      font-weight: 700;
      letter-spacing: .02em;
      border: 1px solid #55677e;
      background: #111b2b;
      color: #d3dfef;
      max-width: 260px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mail-status-chip-case {
      border-color: #3b82f6;
      background: #1e3a8a;
      color: #dbeafe;
    }
    .mail-status-chip-client {
      border-color: #16a34a;
      background: #14532d;
      color: #dcfce7;
    }
    .mail-status-chip-att {
      border-color: #64748b;
      background: #1f2937;
      color: #d1d5db;
    }
    .mail-status-chip-flag {
      border-color: #64748b;
      background: #0f172a;
      color: #cbd5e1;
    }
    .mail-status-chip-read {
      border-color: #0ea5e9;
      background: #0c4a6e;
      color: #e0f2fe;
    }
    .mail-status-chip-unread {
      border-color: #60a5fa;
      background: #1e3a8a;
      color: #dbeafe;
    }
    .mail-view-body {
      padding: 12px;
      background: #202c3f;
      color: #e6eef9;
      white-space: pre-wrap;
      word-break: break-word;
      line-height: 1.48;
      font-size: 14px;
      border-top: 1px solid #41546d;
    }
    .mail-html {
      border-top: 1px dashed #5a6d87;
      margin-top: 10px;
      padding-top: 10px;
    }
    .mail-html-card {
      margin-top: 8px;
      background: #ffffff;
      border: 1px solid #d1d5db;
      border-radius: 8px;
      padding: 8px;
      color: #111827;
    }
    .mail-html-title {
      color: #111827;
      margin-bottom: 6px;
      font-size: 13px;
      font-weight: 600;
    }
    .attachments {
      border-top: 1px dashed #5a6d87;
      margin-top: 10px;
      padding-top: 10px;
    }
    .thread-content-list {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .thread-content-item {
      border: 1px solid #3f5167;
      border-radius: 12px;
      background: #172131;
      padding: 10px;
    }
    .thread-content-item-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 6px;
      font-size: 12px;
      color: #9fb0c7;
    }
    .att-item {
      border: 1px solid #334155;
      border-radius: 10px;
      padding: 8px;
      margin: 8px 0;
      background: #111827;
    }
    .att-head {
      display: flex;
      justify-content: space-between;
      gap: 8px;
      align-items: center;
      font-size: 13px;
      margin-bottom: 6px;
    }
    .att-meta { color: var(--muted); font-size: 12px; }
    .att-preview-image {
      max-width: 100%;
      height: auto;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: block;
    }
    .att-preview-pdf {
      width: 100%;
      height: 520px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #111827;
    }
    .empty {
      padding: 14px;
      color: var(--muted);
      font-size: 14px;
    }
    #systemPanel {
      height: calc(100vh - 56px);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }
    #systemContent {
      flex: 1 1 auto;
      min-height: 0;
      overflow: auto;
      padding-bottom: 18px;
    }
    @media (max-width: 1100px) {
      .layout { grid-template-columns: 200px 320px 1fr; }
    }
    @media (max-width: 820px) {
      .layout { grid-template-columns: 1fr; }
      .panel { border-right: 0; border-bottom: 1px solid var(--line); height: 33vh; }
      .att-preview-pdf { height: 360px; }
      #systemPanel { height: calc(100vh - 56px); }
    }
