:root {
      --bg: #f6f7f9;
      --panel: #ffffff;
      --line: #d8dde5;
      --text: #1f2933;
      --muted: #64748b;
      --accent: #0f766e;
      --danger: #b91c1c;
      --warn: #b45309;
      --ok: #166534;
      --chip: #eef2f7;
      --left-pane-width: 520px;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--text);
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      font-size: 14px;
    }
    .auth-screen {
      min-height: 100vh;
      display: grid;
      place-items: center;
      padding: 20px;
    }
    .auth-box {
      width: min(760px, 100%);
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 12px;
    }
    header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 14px 20px;
      border-bottom: 1px solid var(--line);
      background: #fff;
      position: sticky;
      top: 0;
      z-index: 5;
    }
    .header-left {
      display: grid;
      gap: 2px;
      min-width: 0;
    }
    .header-meta {
      font-size: 12px;
      color: var(--muted);
    }
    .header-badges {
      display: inline-flex;
      gap: 4px;
      align-items: center;
      flex-wrap: wrap;
    }
    .header-badges .badge {
      font-size: 11px;
      padding: 3px 8px;
      border-radius: 999px;
      font-weight: 600;
      white-space: nowrap;
    }
    .header-badges .badge.ok {
      background: #dcfce7;
      color: var(--ok);
    }
    .header-badges .badge.warn {
      background: #fef3c7;
      color: var(--warn);
    }
    .server-status-badge {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 3px 8px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 700;
      white-space: nowrap;
      background: #e2e8f0;
      color: #334155;
    }
    .server-status-badge.ok {
      background: #dcfce7;
      color: var(--ok);
    }
    .server-status-badge.warn {
      background: #fef3c7;
      color: var(--warn);
    }
    .server-status-badge.danger {
      background: #fee2e2;
      color: var(--danger);
    }
    .status-notice {
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 8px 10px;
      font-size: 12px;
      line-height: 1.35;
    }
    .status-notice-info {
      background: #eff6ff;
      color: #1d4ed8;
      border-color: #bfdbfe;
    }
    .status-notice-ok {
      background: #f0fdf4;
      color: var(--ok);
      border-color: #bbf7d0;
    }
    .status-notice-warn {
      background: #fffbeb;
      color: var(--warn);
      border-color: #fde68a;
    }
    .status-notice-danger {
      background: #fef2f2;
      color: var(--danger);
      border-color: #fecaca;
    }
    h1 { font-size: 18px; margin: 0; }
    h2 { font-size: 15px; margin: 0 0 12px; }
    main { padding: 18px 20px 28px; }
    .grid {
      display: grid;
      grid-template-columns: minmax(280px, var(--left-pane-width)) 10px minmax(0, 1fr);
      gap: 8px;
      align-items: start;
    }
    .pane-resizer {
      align-self: stretch;
      min-height: calc(100vh - 106px);
      border-radius: 8px;
      cursor: col-resize;
      position: sticky;
      top: 74px;
      display: grid;
      place-items: center;
      touch-action: none;
    }
    .pane-resizer::before {
      content: "";
      width: 3px;
      height: 42px;
      border-radius: 999px;
      background: #c8d0dc;
    }
    .pane-resizer:hover,
    .pane-resizer.dragging {
      background: #e8edf3;
    }
    body.resizing-pane {
      cursor: col-resize;
      user-select: none;
    }
    body.resizing-pane * {
      cursor: col-resize !important;
    }
    body.analysis-mode main.grid,
    body.admin-mode main.grid {
      grid-template-columns: minmax(0, 1fr);
      gap: 12px;
    }
    body.analysis-mode #paneResizer,
    body.admin-mode #paneResizer {
      display: none;
    }
    body.analysis-mode .tabs {
      display: none;
    }
    body.analysis-mode #tab-analysis {
      display: grid;
      grid-template-columns: repeat(5, minmax(150px, 1fr));
      gap: 10px;
      align-items: end;
    }
    body.analysis-mode #tab-analysis h2,
    body.analysis-mode #analysisMonthCaption,
    body.analysis-mode #analysisMonthButtons,
    body.analysis-mode #tab-analysis .notice {
      grid-column: 1 / -1;
    }
    body.analysis-mode .scroll,
    body.admin-mode .scroll {
      max-height: none;
    }
    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 14px;
      min-width: 0;
      overflow: hidden;
    }
    .stack { display: grid; gap: 12px; min-width: 0; }
    .form-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 8px;
    }
    label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
    .check-row { display: flex; align-items: center; gap: 6px; }
    .check-row input { width: auto; }
    input, select, button, textarea {
      font: inherit;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 8px 9px;
      background: #fff;
      color: var(--text);
      min-width: 0;
    }
    textarea { min-height: 68px; resize: vertical; }
    button {
      cursor: pointer;
      background: #fff;
      border-color: #b7c0ce;
    }
    button.primary {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    button.danger {
      color: var(--danger);
      border-color: #efb7b7;
    }
    button:disabled { opacity: .55; cursor: not-allowed; }
    .button-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    .button-row > button { flex: 1 1 auto; }
    header .button-row > button { flex: 0 0 auto; }
    .month-button-row {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center;
    }
    .month-button-row button {
      flex: 0 0 auto;
      min-width: 64px;
      padding: 8px 12px;
    }
    .month-button-row button.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .analysis-subtabs {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
      padding: 10px;
    }
    .analysis-subtabs button {
      flex: 0 0 auto;
      min-width: 120px;
    }
    .analysis-subtabs button.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .filter-caption {
      color: var(--text);
      font-weight: 700;
    }
    .tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
    .tab {
      border: 0;
      border-bottom: 2px solid transparent;
      border-radius: 0;
      padding: 8px 10px;
      background: transparent;
    }
    .tab.active { border-bottom-color: var(--accent); color: var(--accent); }
    .hidden { display: none !important; }
    .muted { color: var(--muted); }
    .notice {
      white-space: pre-wrap;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 8px;
      background: #fbfcfe;
      color: var(--muted);
      min-height: 37px;
    }
    .counts {
      display: grid;
      grid-template-columns: repeat(4, minmax(120px, 1fr));
      gap: 8px;
      margin-bottom: 12px;
    }
    .count {
      border: 1px solid var(--line);
      background: #fff;
      border-radius: 8px;
      padding: 10px;
    }
    .count b { display: block; font-size: 18px; margin-top: 4px; }
    .metric-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(150px, 1fr));
      gap: 8px;
    }
    .primary-metric-grid {
      display: grid;
      grid-template-columns: repeat(4, minmax(180px, 1fr));
      gap: 10px;
      margin-bottom: 10px;
    }
    .month-comparison-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(240px, 1fr));
      gap: 8px;
    }
    .panel-subtitle {
      margin: 2px 0 8px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .metric-card {
      border: 1px solid var(--line);
      background: #fff;
      border-radius: 8px;
      padding: 10px;
      min-width: 0;
    }
    .metric-card.primary-metric {
      padding: 16px;
      border-color: #b7d7ce;
      background: #f6fffc;
    }
    .metric-card span {
      display: block;
      color: var(--muted);
      font-size: 12px;
    }
    .metric-card b {
      display: block;
      margin-top: 5px;
      font-size: 18px;
    }
    .metric-card-clickable {
      cursor: pointer;
      transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    }
    .metric-card-clickable:hover,
    .metric-card-clickable:focus-visible {
      border-color: var(--accent);
      box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.16);
      outline: none;
      transform: translateY(-1px);
    }
    .metric-card.primary-metric b {
      font-size: 26px;
      line-height: 1.2;
    }
    .money-negative {
      color: var(--danger);
      font-weight: 600;
    }
    .money-positive {
      color: var(--ok);
      font-weight: 600;
    }
    .money-zero {
      color: var(--muted);
    }
    tr.zero-row {
      opacity: 0.45;
    }
    tr.zero-row:hover {
      opacity: 1;
    }
    .branch-card-grid {
      display: grid;
      grid-template-columns: repeat(5, minmax(180px, 1fr));
      gap: 10px;
    }
    .branch-card {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fff;
      padding: 12px;
      min-width: 0;
    }
    .branch-card h3 {
      margin: 0 0 10px;
      font-size: 15px;
    }
    .branch-card-primary {
      padding: 12px 0;
      border-bottom: 1px solid var(--line);
      margin-bottom: 8px;
    }
    .branch-card-primary-label {
      font-size: 11px;
      color: var(--muted);
    }
    .branch-card-primary-value {
      font-size: 22px;
      font-weight: 700;
      margin-top: 2px;
    }
    .branch-card-net-negative .branch-card-primary-value {
      color: var(--danger);
    }
    .branch-card-net-positive .branch-card-primary-value {
      color: var(--ok);
    }
    .branch-card-secondary {
      padding: 6px 0 10px;
      border-bottom: 1px solid var(--line);
    }
    .branch-card-secondary b {
      font-size: 15px;
    }
    .branch-card-tertiary {
      padding-top: 8px;
      font-size: 12px;
      color: var(--muted);
    }
    .branch-card-tertiary .summary-row {
      padding: 3px 0;
      border: 0;
    }
    .branch-card .summary-row {
      border: 0;
      border-top: 1px solid #edf1f5;
      padding: 7px 0;
      font-size: 13px;
    }
    .branch-card .summary-row:first-of-type {
      border-top: 0;
    }
    .branch-metric-link {
      width: 100%;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: inherit;
      cursor: pointer;
      font: inherit;
    }
    .branch-metric-link:hover {
      color: var(--accent);
      background: #f8fafc;
    }
    .analytics-table tr.clickable { cursor: pointer; }
    .analytics-table tr.clickable:hover td { background: #f8fafc; }
    .analytics-table tr.selected td { background: #ecfdf5; }
    .detail-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }
    .trend-branch-buttons {
      display: inline-flex;
      gap: 4px;
      flex-wrap: wrap;
      justify-content: flex-end;
    }
    .trend-branch-buttons button {
      flex: 0 0 auto;
      padding: 5px 9px;
      font-size: 12px;
    }
    .trend-branch-buttons button.active {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .chart-panel canvas {
      width: 100%;
      max-height: 260px;
    }
    .chart-empty {
      border: 1px dashed var(--line);
      border-radius: 8px;
      padding: 18px;
      text-align: center;
      color: var(--muted);
      background: #fafbfc;
    }
    .anomaly-card {
      display: flex;
      gap: 10px;
      padding: 8px 10px;
      border-radius: 6px;
      margin-bottom: 6px;
      align-items: flex-start;
    }
    .anomaly-danger {
      background: #fee2e2;
    }
    .anomaly-warn {
      background: #fef3c7;
    }
    .anomaly-info {
      background: #e0f2fe;
    }
    .anomaly-dot {
      width: 8px;
      height: 8px;
      border-radius: 50%;
      margin-top: 6px;
      flex-shrink: 0;
    }
    .anomaly-danger .anomaly-dot { background: var(--danger); }
    .anomaly-warn .anomaly-dot { background: var(--warn); }
    .anomaly-info .anomaly-dot { background: #0369a1; }
    .anomaly-title {
      font-weight: 600;
      font-size: 13px;
    }
    .anomaly-detail {
      font-size: 12px;
      color: #475569;
      margin-top: 2px;
    }
    .analysis-dashboard-page {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-rows: auto auto;
      gap: 10px;
      height: auto;
      min-height: 0;
    }
    .dashboard-panel {
      min-height: 0;
      overflow: visible;
      display: flex;
      flex-direction: column;
      padding: 10px;
    }
    .dashboard-summary-panel .primary-metric-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 7px;
      margin-bottom: 8px;
    }
    .dashboard-summary-panel .metric-card {
      padding: 9px;
    }
    .dashboard-summary-panel .metric-card.primary-metric {
      padding: 11px;
    }
    .dashboard-summary-panel .metric-card.primary-metric b {
      font-size: 21px;
    }
    .dashboard-summary-panel .month-comparison-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 7px;
    }
    .dashboard-chart-grid {
      display: grid;
      grid-template-rows: 132px 132px;
      gap: 6px;
      flex: 0 0 auto;
      height: 270px;
      min-height: 270px;
    }
    .chart-slot {
      height: 132px;
      min-height: 132px;
      display: flex;
      flex-direction: column;
      position: relative;
      border-top: 1px solid #edf1f5;
      padding-top: 4px;
    }
    .chart-slot:first-child {
      border-top: 0;
      padding-top: 0;
    }
    .chart-slot-title {
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
      margin-bottom: 2px;
    }
    .chart-slot canvas {
      flex: 0 0 108px;
      width: 100% !important;
      height: 108px !important;
      min-height: 108px;
      max-height: 108px;
    }
    .dashboard-branch-panel .branch-card-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
    }
    .dashboard-branch-panel .branch-card {
      padding: 8px;
    }
    .dashboard-branch-panel .branch-card h3 {
      margin-bottom: 5px;
      font-size: 13px;
    }
    .dashboard-branch-panel .branch-card-primary {
      padding: 5px 0;
      margin-bottom: 5px;
    }
    .dashboard-branch-panel .branch-card-primary-value {
      font-size: 16px;
    }
    .dashboard-branch-panel .branch-card-secondary {
      padding: 3px 0 5px;
    }
    .dashboard-branch-panel .branch-card-tertiary {
      padding-top: 5px;
      font-size: 11px;
    }
    .dashboard-anomaly-panel {
      margin-top: 0;
    }
    .dashboard-anomaly-panel .notice {
      padding: 0;
      border: 0;
      background: transparent;
    }
    .dashboard-table-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      flex: 1 1 auto;
      min-height: 0;
      align-items: stretch;
    }
    .dashboard-table-box {
      min-height: 0;
      display: flex;
      flex-direction: column;
      overflow: visible;
    }
    .dashboard-table-box h2 {
      margin-bottom: 7px;
    }
    .dashboard-table-box .scroll {
      flex: 1 1 auto;
      min-height: 0;
      overflow: visible;
      display: block;
      justify-content: initial;
    }
    .dashboard-table-box .analytics-compact-table {
      width: 100%;
      font-size: 11px;
    }
    .dashboard-table-box th,
    .dashboard-table-box td {
      padding: 5px 6px;
    }
    .dashboard-detail-tabs {
      display: none;
      margin-top: 0;
    }
    #analysisSupportPane {
      display: none;
    }
    .branch-balance-list {
      display: grid;
      gap: 6px;
      flex: 1 1 auto;
    }
    .branch-balance-row {
      display: grid;
      grid-template-columns: 84px minmax(0, 1fr);
      gap: 8px;
      align-items: center;
      padding: 7px 9px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      min-width: 0;
    }
    .branch-balance-row span {
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .branch-balance-row b {
      text-align: right;
      font-size: 16px;
      white-space: nowrap;
    }
    .branch-balance-row.total {
      background: #f6fffc;
      border-color: #b7d7ce;
    }
    .branch-balance-row.total span,
    .branch-balance-row.total b {
      color: var(--ok);
      font-weight: 700;
    }
    .balance-total-card {
      display: grid;
      align-content: center;
      gap: 6px;
      flex: 1 1 auto;
      min-height: 100%;
      padding: 14px;
      border: 1px solid #b7d7ce;
      border-radius: 7px;
      background: #f6fffc;
    }
    .balance-total-label {
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .balance-total-value {
      font-size: 28px;
      line-height: 1.12;
      font-weight: 800;
      color: var(--ok);
      text-align: right;
      white-space: nowrap;
    }
    .balance-total-note {
      color: var(--muted);
      font-size: 11px;
      text-align: right;
    }
    .balance-detail-button {
      justify-self: end;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      min-height: 30px;
      padding: 5px 10px;
      border-color: #8fbfb1;
      color: #0f6e56;
      background: #fff;
      font-weight: 700;
      white-space: nowrap;
    }
    .balance-detail-button:hover {
      background: #ecfdf5;
    }
    .balance-detail-icon {
      font-size: 14px;
      line-height: 1;
    }
    .balance-detail-page {
      width: 100%;
      max-width: none;
      margin: 0;
      padding: 10px 12px;
      box-sizing: border-box;
      min-height: calc(100vh - 145px);
      display: flex;
      flex-direction: column;
    }
    .balance-detail-page .detail-title {
      margin-bottom: 5px;
    }
    .balance-detail-table-wrap {
      flex: 1 1 auto;
      min-height: 0;
      overflow: hidden;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
    }
    .balance-detail-table {
      width: 100%;
      table-layout: fixed;
      border: 0;
      border-radius: 0;
      font-size: 13px;
    }
    .balance-detail-table th,
    .balance-detail-table td {
      text-align: center;
      vertical-align: middle;
      padding: 4px 7px;
      line-height: 1.2;
      border-bottom: 1px solid #e6edf5;
      white-space: nowrap;
    }
    .balance-detail-table th {
      background: #f3f6fa;
      color: #31445c;
      font-weight: 800;
    }
    .balance-detail-table th:not(:last-child),
    .balance-detail-table td:not(:last-child) {
      border-right: 1px solid #eef2f6;
    }
    .balance-detail-table tbody tr:nth-child(even) {
      background: #fbfcfe;
    }
    .balance-detail-table tbody tr:hover {
      background: #f4fbff;
    }
    .balance-detail-table th:nth-child(1),
    .balance-detail-table td:nth-child(1) {
      width: 7%;
    }
    .balance-detail-table th:nth-child(2),
    .balance-detail-table td:nth-child(2) {
      width: 8%;
    }
    .balance-detail-table th:nth-child(3),
    .balance-detail-table td:nth-child(3) {
      width: 23%;
      text-align: left;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .balance-detail-table th:nth-child(n+4),
    .balance-detail-table td:nth-child(n+4) {
      text-align: right;
    }
    .balance-detail-amount {
      color: var(--ok);
      font-weight: 800;
    }
    .balance-detail-table tfoot td {
      background: #eef8f4;
      border-top: 2px solid #99d6c2;
      border-bottom: 0;
      color: #0f172a;
      font-weight: 800;
      font-size: 13.5px;
    }
    .balance-detail-total-label {
      text-align: center !important;
      color: #0f6e56;
    }
    .subject-toolbar {
      display: flex;
      justify-content: flex-end;
      margin-bottom: 6px;
    }
    .subject-toolbar .check-row {
      color: var(--muted);
      cursor: pointer;
      font-size: 12px;
    }
    .analysis-support-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 8px;
      overflow: hidden;
    }
    th, td {
      border-bottom: 1px solid var(--line);
      padding: 8px;
      text-align: left;
      vertical-align: top;
    }
    th {
      background: #f1f4f8;
      color: #475569;
      font-size: 12px;
    }
    .analytics-table th,
    .analytics-table td {
      white-space: nowrap;
    }
    .analytics-compact-panel {
      width: min(100%, 1160px);
      margin-left: auto;
      margin-right: auto;
    }
    .account-balance-panel {
      width: min(100%, 980px);
    }
    .analytics-compact-panel .scroll {
      display: flex;
      justify-content: center;
    }
    .analytics-compact-table {
      width: auto;
      max-width: 100%;
      font-size: 12px;
    }
    .analytics-compact-table th,
    .analytics-compact-table td {
      padding: 4px 6px;
      vertical-align: middle;
      line-height: 1.25;
    }
    .subject-summary-table.analytics-compact-table {
      min-width: 940px;
    }
    .account-balance-table.analytics-compact-table {
      min-width: 760px;
    }
    .account-balance-table th,
    .account-balance-table td {
      text-align: right;
    }
    .account-balance-table th:nth-child(-n+3),
    .account-balance-table td:nth-child(-n+3) {
      text-align: center;
    }
    .account-balance-table td:nth-child(3) {
      text-align: left;
      font-weight: 700;
    }
    .clickable-row {
      cursor: pointer;
    }
    .clickable-row:hover {
      background: #f1f5f9;
    }
    .subject-summary-table th:nth-child(n+3),
    .subject-summary-table td:nth-child(n+3) {
      text-align: right;
    }
    .subject-summary-table td:nth-child(2) {
      font-weight: 700;
    }
    .subject-summary-table td:first-child,
    .subject-summary-table td:nth-child(6) {
      background: #fbfcfe;
      font-weight: 700;
      text-align: center;
      vertical-align: middle;
    }
    .subject-summary-table tr.group-start td {
      border-top: 2px solid #9aa6b2;
    }
    .subject-summary-table .memo-cell {
      text-align: left;
      min-width: 160px;
    }
    .subject-edit-table {
      width: 100%;
      min-width: 1080px;
      table-layout: fixed;
      border: 0;
      border-radius: 0;
    }
    .subject-edit-scroll {
      max-height: none;
      overflow-x: auto;
      overflow-y: visible;
    }
    .subject-edit-table th,
    .subject-edit-table td {
      padding: 3px 5px;
      line-height: 1.15;
      vertical-align: middle;
    }
    .subject-edit-table th:nth-child(1) { width: 58px; }
    .subject-edit-table th:nth-child(2) { width: 105px; }
    .subject-edit-table th:nth-child(3) { width: 150px; }
    .subject-edit-table th:nth-child(4) { width: 135px; }
    .subject-edit-table th:nth-child(5) { width: 180px; }
    .subject-edit-table th:nth-child(6) { width: 150px; }
    .subject-edit-table th:nth-child(7) { width: 205px; }
    .subject-edit-table th:nth-child(8) { width: 62px; }
    .subject-edit-table .subject-name-cell {
      font-size: 12px;
      word-break: keep-all;
    }
    .subject-edit-table input,
    .subject-edit-table select {
      width: 100%;
      min-height: 24px;
      padding: 3px 5px;
      font-size: 12px;
    }
    .subject-edit-table input[type="checkbox"] {
      width: auto;
      padding: 0;
      min-height: 0;
      margin: 0;
    }
    .subject-option-group {
      display: flex;
      align-items: center;
      gap: 7px;
      white-space: nowrap;
    }
    .subject-option-group label {
      display: inline-flex;
      align-items: center;
      gap: 3px;
      margin: 0;
      font-size: 11px;
      line-height: 1;
    }
    .subject-edit-table button {
      width: 100%;
      min-height: 24px;
      padding: 3px 6px;
    }
    .subject-edit-table tr.inactive {
      opacity: .55;
    }
    .analysis-detail-table th:nth-child(n+6),
    .analysis-detail-table td:nth-child(n+6) {
      text-align: right;
    }
    .analysis-detail-table th:last-child,
    .analysis-detail-table td:last-child {
      text-align: left;
    }
    tr:last-child td { border-bottom: 0; }
    .status {
      display: inline-block;
      padding: 3px 7px;
      border-radius: 999px;
      background: var(--chip);
      color: #334155;
      font-size: 12px;
      white-space: nowrap;
    }
    .status.matched, .status.approved, .status.confirmed { color: var(--ok); background: #dcfce7; }
    .status.invalid_subject, .status.needs_review, .status.suspicious_subject, .status.amount_mismatch, .status.duplicate { color: var(--warn); background: #fef3c7; }
    .status.missing_in_coded, .status.missing_in_raw, .status.parse_error, .status.column_error, .status.date_error, .status.amount_error, .status.balance_mismatch, .status.rejected { color: var(--danger); background: #fee2e2; }
    .scroll { overflow: auto; max-height: 68vh; border-radius: 8px; }
    .result-list {
      display: grid;
      gap: 10px;
      max-height: 68vh;
      overflow: auto;
      padding-right: 6px;
    }
    .result-card {
      background: #fff;
      border: 1px solid var(--line);
      border-left: 5px solid #cbd5e1;
      border-radius: 8px;
      padding: 12px;
      min-width: 0;
    }
    .result-card.matched { border-left-color: var(--ok); }
    .result-card.missing_in_coded,
    .result-card.missing_in_raw,
    .result-card.parse_error,
    .result-card.column_error,
    .result-card.date_error,
    .result-card.amount_error,
    .result-card.balance_mismatch { border-left-color: var(--danger); }
    .result-card.needs_review,
    .result-card.suspicious_subject,
    .result-card.amount_mismatch,
    .result-card.duplicate,
    .result-card.invalid_subject { border-left-color: var(--warn); }
    .result-head {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      align-items: flex-start;
      margin-bottom: 10px;
    }
    .bulk-exclude {
      display: flex;
      align-items: center;
      gap: 5px;
      color: var(--muted);
      white-space: nowrap;
      font-size: 12px;
    }
    .bulk-exclude input { padding: 0; }
    .result-title {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center;
    }
    .result-reason {
      margin-top: 6px;
      color: #334155;
      font-weight: 600;
    }
    .result-grid {
      display: grid;
      grid-template-columns: minmax(220px, 1.15fr) minmax(220px, 1.15fr) minmax(190px, .8fr) minmax(270px, .9fr);
      gap: 10px;
      align-items: start;
    }
    .txn-box,
    .subject-box,
    .review-box {
      border: 1px solid var(--line);
      border-radius: 7px;
      padding: 10px;
      background: #fbfcfe;
      min-width: 0;
    }
    .txn-box h3,
    .subject-box h3,
    .review-box h3 {
      margin: 0 0 8px;
      font-size: 13px;
      color: #334155;
    }
    .txn-row {
      display: flex;
      gap: 8px;
      justify-content: space-between;
      border-bottom: 1px solid #edf1f5;
      padding: 4px 0;
    }
    .txn-row:last-child { border-bottom: 0; }
    .txn-row span:first-child { color: var(--muted); white-space: nowrap; }
    .txn-row b,
    .txn-row span:last-child {
      text-align: right;
      overflow-wrap: anywhere;
    }
    .amount-row {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
      margin-top: 8px;
    }
    .amount-row span {
      border: 1px solid #e2e8f0;
      border-radius: 6px;
      padding: 6px;
      background: #fff;
      font-size: 12px;
      text-align: right;
      white-space: nowrap;
    }
    .coded-edit-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
    }
    .coded-edit-grid label {
      font-size: 11px;
      color: var(--muted);
    }
    .coded-edit-grid input {
      width: 100%;
      padding: 5px 6px;
      margin-top: 2px;
      font-size: 12px;
    }
    .coded-edit-grid .wide {
      grid-column: 1 / -1;
    }
    .coded-edit-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 6px;
      margin-top: 8px;
    }
    .coded-edit-actions button {
      padding: 7px 6px;
    }
    .review-box select,
    .review-box textarea {
      width: 100%;
      margin-bottom: 7px;
    }
    .review-box textarea { min-height: 52px; }
    .result-action-buttons {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 6px;
      margin-bottom: 7px;
    }
    .result-action-buttons button { padding: 8px 6px; }
    .force-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 6px;
      align-items: start;
    }
    details.issue-details {
      margin-top: 8px;
      color: var(--muted);
      font-size: 12px;
    }
    details:not([open]) > :not(summary) {
      display: none !important;
    }
    details.issue-details pre {
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      margin: 6px 0 0;
      padding: 7px;
      border-radius: 6px;
      background: #f8fafc;
    }
    .result-card-row > td {
      padding: 0 0 10px;
      border-bottom: 0;
      background: var(--bg);
    }
    table:has(#resultsBody) {
      display: block;
      border: 0;
      background: transparent;
    }
    table:has(#resultsBody) thead { display: none; }
    table:has(#resultsBody) tbody,
    table:has(#resultsBody) tr.result-card-row,
    table:has(#resultsBody) tr.result-card-row > td {
      display: block;
      width: 100%;
    }
    #resultsTable.results-table {
      display: table;
      width: 100%;
      min-width: 1360px;
      border: 1px solid var(--line);
      background: #fff;
      table-layout: fixed;
      font-size: 12px;
    }
    #resultsTable.results-table thead {
      display: table-header-group;
    }
    #resultsTable.results-table tbody {
      display: table-row-group;
    }
    #resultsTable.results-table tr {
      display: table-row;
    }
    #resultsTable.results-table th,
    #resultsTable.results-table td {
      display: table-cell;
      width: auto;
      padding: 5px 6px;
      vertical-align: top;
      border-bottom: 1px solid var(--line);
      line-height: 1.28;
    }
    #resultsTable.results-table th {
      position: sticky;
      top: 0;
      z-index: 2;
      background: #eef2f7;
      font-size: 12px;
    }
    #resultsTable.results-table th:nth-child(1) { width: 88px; }
    #resultsTable.results-table th:nth-child(2) { width: 230px; }
    #resultsTable.results-table th:nth-child(3) { width: 145px; }
    #resultsTable.results-table th:nth-child(4) { width: 78px; }
    #resultsTable.results-table th:nth-child(5),
    #resultsTable.results-table th:nth-child(6) { width: 16%; }
    #resultsTable.results-table th:nth-child(7) { width: 110px; }
    #resultsTable.results-table th:nth-child(8) { width: 150px; }
    #resultsTable.results-table th:nth-child(9) { width: 210px; }
    .result-scroll {
      max-height: 72vh;
      border: 1px solid var(--line);
      border-radius: 6px;
    }
    .result-toolbar-panel,
    .audit-panel {
      padding: 8px 10px;
    }
    .compact-filter-row {
      gap: 6px;
      align-items: end;
    }
    .compact-filter-row label {
      margin: 0;
      min-width: 130px;
    }
    .result-line {
      display: flex;
      justify-content: space-between;
      gap: 6px;
      border-bottom: 1px solid #edf1f5;
      padding: 2px 0;
    }
    .result-line:last-child { border-bottom: 0; }
    .result-line span:first-child {
      color: var(--muted);
      white-space: nowrap;
    }
    .result-line b {
      text-align: right;
      overflow-wrap: anywhere;
    }
    .result-action-compact {
      display: grid;
      grid-template-columns: 1fr 1fr 1fr;
      gap: 4px;
    }
    .result-action-compact select,
    .result-action-compact textarea {
      grid-column: 1 / -1;
      width: 100%;
      min-height: 0;
      padding: 5px 6px;
      font-size: 12px;
    }
    .result-action-compact textarea {
      height: 34px;
    }
    .result-action-compact button {
      padding: 5px 6px;
      font-size: 12px;
    }
    .force-compact {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 4px;
    }
    .force-compact textarea {
      grid-column: auto;
    }
    .nowrap { white-space: nowrap; }
    .cell-note { color: var(--muted); font-size: 12px; margin-top: 3px; }
    .subject-list {
      display: grid;
      gap: 8px;
      max-height: 360px;
      overflow: auto;
    }
    .account-list {
      display: block;
      max-height: 430px;
      overflow: auto;
      padding: 0;
    }
    .matching-toolbar {
      display: grid;
      grid-template-columns: repeat(4, minmax(150px, 1fr));
      gap: 8px;
      align-items: end;
    }
    .matching-new-account summary {
      cursor: pointer;
      color: var(--text);
    }
    .matching-new-account .matching-form {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
      margin-top: 10px;
    }
    .matching-new-account .matching-form .wide {
      grid-column: 1 / -1;
    }
    .matching-bulk-row {
      align-items: center;
    }
    .account-count {
      color: var(--muted);
      font-size: 12px;
      font-weight: 600;
      white-space: nowrap;
    }
    .account-match-table {
      width: 100%;
      min-width: 0;
      table-layout: fixed;
      border: 0;
      border-radius: 0;
    }
    #matchingAccountsList.account-list {
      max-height: none;
      overflow: visible;
    }
    .account-match-table th:nth-child(1) { width: 34px; }
    .account-match-table th:nth-child(2) { width: 132px; }
    .account-match-table th:nth-child(3) { width: 100px; }
    .account-match-table th:nth-child(4) { width: 115px; }
    .account-match-table th:nth-child(5) { width: 28%; }
    .account-match-table th:nth-child(6) { width: 210px; }
    .account-match-table th:nth-child(7) { width: 132px; }
    .account-match-table th {
      top: 0;
      position: sticky;
    }
    .account-match-table th,
    .account-match-table td {
      padding: 3px 5px;
      line-height: 1.15;
      vertical-align: middle;
    }
    .account-match-table input {
      width: 100%;
      min-height: 24px;
      padding: 3px 5px;
      font-size: 12px;
    }
    .account-match-table input[type="checkbox"] {
      width: auto;
      padding: 0;
      min-height: 0;
    }
    .account-match-actions {
      display: flex;
      gap: 4px;
      white-space: nowrap;
    }
    .account-match-actions button {
      min-height: 24px;
      padding: 3px 7px;
      font-size: 12px;
    }
    .account-sort-controls {
      display: grid;
      grid-template-columns: minmax(42px, 1fr) 28px 28px;
      gap: 3px;
      align-items: center;
    }
    .account-match-table .account-sort-input {
      min-width: 0;
      text-align: right;
    }
    .account-sort-controls button {
      min-height: 24px;
      padding: 3px 0;
      font-size: 11px;
    }
    .subject-item {
      display: grid;
      gap: 7px;
      border-bottom: 1px solid var(--line);
      padding: 8px 0;
      min-width: 0;
    }
    .subject-item:last-child { border-bottom: 0; }
    .subject-item.inactive { opacity: .58; }
    .subject-name {
      font-weight: 700;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .subject-controls {
      display: grid;
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      gap: 6px;
    }
    .subject-flags {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }
    .workflow {
      display: grid;
      grid-template-columns: repeat(4, minmax(0, 1fr));
      gap: 6px;
    }
    .step {
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 8px;
      background: #fbfcfe;
      min-height: 54px;
    }
    .step b {
      display: block;
      font-size: 12px;
      margin-bottom: 3px;
    }
    .step span {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.25;
    }
    .batch-overview-metrics {
      display: grid;
      grid-template-columns: repeat(6, minmax(120px, 1fr));
      gap: 4px;
      margin-bottom: 4px;
    }
    .batch-overview-card {
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      padding: 6px 8px;
      min-width: 0;
    }
    .batch-overview-card span {
      display: block;
      color: var(--muted);
      font-size: 11px;
      margin-bottom: 2px;
    }
    .batch-overview-card b {
      display: block;
      font-size: 17px;
      line-height: 1.1;
    }
    #batchOverviewList {
      padding: 0;
      min-height: 0;
      white-space: normal;
      overflow: visible;
      margin-top: 0;
    }
.batch-overview-table {
  min-width: 980px;
  border: 1px solid var(--line);
  border-radius: 6px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: #fff;
}
    .batch-overview-scroll {
      max-height: none;
      overflow: visible;
      border-radius: 6px;
    }
    .batch-overview-table th {
      position: sticky;
      top: 0;
      z-index: 1;
    }
.batch-overview-table th,
.batch-overview-table td {
  padding: 3px 5px;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid #e8edf3;
}
    .batch-overview-table th {
      background: #f3f6fa;
      color: #31445c;
      font-weight: 700;
    }
    .batch-overview-table th:not(:last-child),
    .batch-overview-table td:not(:last-child) {
      border-right: 1px solid #eef2f6;
    }
    .batch-overview-table tbody tr:nth-child(even) {
      background: #fbfcfe;
    }
    .batch-overview-table tbody tr:hover {
      background: #f6fbff;
    }
    .batch-overview-table tbody tr:last-child td {
      border-bottom: 0;
}
    .batch-overview-table th.sortable-th {
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }
    .batch-overview-table th.sortable-th:hover {
      background: #e2e8f0;
    }
    .batch-overview-filter-row th {
      top: 25px;
      background: #fff;
      padding: 2px 4px;
      z-index: 2;
    }
    .batch-overview-filter-row select,
    .batch-overview-filter-row input {
      width: 100%;
      min-width: 0;
      height: 25px;
      padding: 2px 5px;
      font-size: 11px;
    }
    .batch-overview-filter-row .compact-button {
      width: 100%;
      height: 25px;
      padding: 2px 5px;
      font-size: 11px;
    }
    .batch-overview-table tr.active td { background: #ecfeff; }
    .overview-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      min-width: 58px;
      padding: 2px 6px;
      border-radius: 999px;
      font-size: 11px;
      font-weight: 700;
      white-space: nowrap;
      background: var(--chip);
      color: #475569;
    }
    .overview-pill.overview-action {
      border: 0;
      cursor: pointer;
      font-family: inherit;
    }
    .overview-pill.overview-action:hover {
      filter: brightness(.96);
      text-decoration: underline;
    }
    .overview-pill.ok { color: var(--ok); background: #dcfce7; }
    .overview-pill.warn { color: #a16207; background: #fef3c7; }
    .overview-pill.danger { color: var(--danger); background: #fee2e2; }
    .overview-pill.muted { color: var(--muted); background: #f1f5f9; }
    .overview-file-note {
      margin-top: 1px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.15;
      max-width: 180px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .section-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-top: 4px;
    }
    .section-title h2 { margin: 0; }
    .summary-grid {
      display: grid;
      grid-template-columns: 1fr;
      gap: 6px;
    }
    .summary-row {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      border-bottom: 1px solid var(--line);
      padding: 5px 0;
    }
    .summary-row:last-child { border-bottom: 0; }
    .summary-row span:first-child { color: var(--muted); }
    .issue-list {
      display: grid;
      gap: 8px;
      white-space: normal;
    }
    .issue-item {
      border: 1px solid var(--line);
      border-left: 4px solid var(--warn);
      border-radius: 8px;
      background: #fff;
      padding: 10px;
    }
    .issue-item.critical { border-left-color: var(--danger); }
    .issue-item.critical .issue-title,
    .issue-item.critical .issue-detail { color: var(--danger); }
    .issue-item.ok { border-left-color: var(--ok); }
    .issue-title {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      font-weight: 700;
    }
    .issue-detail {
      margin-top: 5px;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.45;
    }
    .admin-issue-result-list {
      display: grid;
      gap: 10px;
      max-height: none;
      overflow: visible;
      padding-right: 0;
    }
    .issue-work-toolbar {
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 8px;
      flex-wrap: wrap;
    }
    .issue-work-toolbar label {
      max-width: 260px;
      margin: 0;
    }
    .issue-batch-line {
      color: var(--muted);
      font-size: 12px;
      margin-top: 4px;
    }
    .issue-summary-table,
    .issue-work-table {
      width: 100%;
      table-layout: fixed;
      border: 0;
      border-radius: 0;
      background: #fff;
    }
    .issue-summary-table th,
    .issue-summary-table td,
    .issue-work-table th,
    .issue-work-table td {
      padding: 5px 6px;
      line-height: 1.25;
      vertical-align: top;
      white-space: normal;
      word-break: keep-all;
    }
    .issue-summary-table th:nth-child(1) { width: 86px; }
    .issue-summary-table th:nth-child(2) { width: 130px; }
    .issue-summary-table th:nth-child(3) { width: 94px; }
    .issue-summary-table th:nth-child(4) { width: 22%; }
    .issue-summary-table th:nth-child(5) { width: 22%; }
    .issue-summary-table th:nth-child(6) { width: 24%; }
    .issue-summary-table th:nth-child(7) { width: 90px; }
    .issue-summary-table tr.issue-critical td {
      background: #fff7f7;
    }
    .issue-summary-table tr.issue-warn td {
      background: #fffdf5;
    }
    .issue-summary-table tr.issue-info td {
      background: #f8fbff;
    }
    .issue-summary-table button,
    .issue-work-table button {
      min-height: 24px;
      padding: 3px 7px;
      font-size: 12px;
    }
    .issue-work-table th:nth-child(1) { width: 102px; }
    .issue-work-table th:nth-child(2) { width: 190px; }
    .issue-work-table th:nth-child(3),
    .issue-work-table th:nth-child(4) { width: 18%; }
    .issue-work-table th:nth-child(5) { width: 20%; }
    .issue-work-table th:nth-child(6) { width: 230px; }
    .issue-work-table select,
    .issue-work-table textarea {
      width: 100%;
      min-height: 25px;
      padding: 4px 6px;
      font-size: 12px;
    }
    .issue-work-table textarea {
      min-height: 45px;
      resize: vertical;
    }
    .empty-row {
      padding: 28px;
      text-align: center;
      color: var(--muted);
    }
    /* Compact office dashboard layout */
    body {
      font-size: 13px;
      line-height: 1.35;
    }
    header {
      padding: 8px 14px;
    }
    h1 { font-size: 17px; }
    h2 {
      font-size: 14px;
      margin: 0 0 8px;
    }
    main {
      padding: 10px 12px 18px;
    }
    .grid {
      grid-template-columns: minmax(260px, var(--left-pane-width)) 8px minmax(0, 1fr);
      gap: 6px;
    }
    .pane-resizer {
      min-height: calc(100vh - 78px);
      top: 56px;
    }
    .panel {
      padding: 10px;
      border-radius: 7px;
    }
    .stack { gap: 8px; }
    .form-row,
    .button-row,
    .matching-toolbar,
    .matching-new-account .matching-form,
    .result-grid,
    .workflow,
    .counts,
    .metric-grid,
    .primary-metric-grid,
    .month-comparison-grid,
    .branch-card-grid,
    .batch-overview-metrics {
      gap: 6px;
    }
    label {
      gap: 3px;
      font-size: 11.5px;
    }
    input, select, button, textarea {
      padding: 6px 8px;
      border-radius: 5px;
    }
    textarea { min-height: 54px; }
    .tabs {
      gap: 4px;
      margin-bottom: 8px;
    }
    .tab {
      padding: 6px 8px;
    }
    .notice {
      padding: 6px;
      min-height: 30px;
    }
    .counts {
      margin-bottom: 8px;
    }
    .count,
    .metric-card,
    .batch-overview-card,
    .branch-card,
    .result-card,
    .txn-box,
    .subject-box,
    .review-box,
    .issue-item {
      padding: 8px;
      border-radius: 7px;
    }
    .metric-card.primary-metric {
      padding: 10px;
    }
    .count b,
    .metric-card b {
      font-size: 16px;
      margin-top: 3px;
    }
    .metric-card.primary-metric b {
      font-size: 21px;
    }
    .branch-card h3 {
      margin: 0 0 6px;
      font-size: 14px;
    }
    .summary-row,
    .branch-card .summary-row {
      padding: 4px 0;
    }
    th, td {
      padding: 5px 6px;
    }
    .status,
    .overview-pill {
      padding: 2px 6px;
      font-size: 11.5px;
    }
    .result-list,
    .admin-issue-result-list {
      gap: 7px;
      padding-right: 4px;
    }
    .result-head {
      gap: 7px;
      margin-bottom: 6px;
    }
    .result-reason {
      margin-top: 4px;
    }
    .txn-box h3,
    .subject-box h3,
    .review-box h3 {
      margin: 0 0 5px;
      font-size: 12px;
    }
    .txn-row {
      gap: 6px;
      padding: 3px 0;
    }
    .amount-row {
      gap: 4px;
      margin-top: 5px;
    }
    .amount-row span {
      padding: 4px;
    }
    .review-box select,
    .review-box textarea {
      margin-bottom: 5px;
    }
    .review-box textarea { min-height: 44px; }
    .result-action-buttons {
      gap: 4px;
      margin-bottom: 5px;
    }
    .result-action-buttons button {
      padding: 6px 5px;
    }
    .cell-note {
      font-size: 11.5px;
      margin-top: 2px;
    }
    .section-title {
      gap: 6px;
      margin-top: 2px;
    }
    #tab-batch.stack {
      gap: 4px;
    }
    #tab-batch .section-title {
      margin-top: 0;
    }
    #tab-batch .section-title h2 {
      margin: 0;
      line-height: 1.2;
    }
    #batchOverviewSummary {
      gap: 4px;
      margin-bottom: 0;
    }
    #batchOverviewSummary + #batchOverviewList {
      margin-top: -4px;
    }
    #batchOverviewSummary .batch-overview-card {
      padding: 5px 7px;
      border-radius: 6px;
    }
    #batchOverviewSummary .batch-overview-card b {
      font-size: 16px;
    }
    #batchOverviewList {
      padding: 0;
      min-height: 0;
      white-space: normal;
      margin: 0;
      overflow: visible;
    }
    #batchOverviewList + .workflow {
      margin-top: 2px;
    }
    #tab-batch .workflow {
      gap: 4px;
    }
    #tab-batch .step {
      padding: 5px 7px;
      min-height: 38px;
    }
    #tab-batch .step b {
      margin-bottom: 1px;
    }
    #tab-batch .step span {
      line-height: 1.15;
    }
    .month-button-row button {
      min-width: 52px;
      padding: 6px 9px;
    }
    .analysis-subtabs {
      gap: 6px;
      padding: 6px;
    }
    .analysis-subtabs button {
      min-width: 96px;
    }
    .batch-overview-scroll {
      max-height: none;
      overflow: visible;
    }
    .account-list {
      max-height: 360px;
    }
    .subject-list {
      gap: 6px;
      max-height: 320px;
    }
    .subject-item {
      gap: 5px;
      padding: 6px 0;
    }
    /* Dense mode: keep management screens visible without dead whitespace. */
    header {
      padding: 5px 12px;
    }
    h1 {
      font-size: 16px;
      line-height: 1.15;
    }
    .header-meta {
      font-size: 11px;
      line-height: 1.15;
    }
    main {
      padding: 6px 10px 12px;
    }
    .grid,
    body.analysis-mode main.grid,
    body.admin-mode main.grid {
      gap: 5px;
    }
    .panel {
      padding: 7px;
      border-radius: 6px;
    }
    .stack {
      gap: 5px;
    }
    h2 {
      font-size: 13px;
      margin: 0 0 5px;
      line-height: 1.2;
    }
    .tabs {
      gap: 2px;
      margin-bottom: 6px;
    }
    .tab {
      padding: 5px 7px;
    }
    .notice {
      padding: 5px 6px;
      min-height: 0;
      line-height: 1.25;
    }
    label {
      gap: 2px;
      font-size: 11px;
    }
    input,
    select,
    button,
    textarea {
      padding: 4px 6px;
      border-radius: 5px;
      min-height: 26px;
    }
    .button-row {
      gap: 4px;
    }
    .form-row,
    .metric-grid,
    .primary-metric-grid,
    .month-comparison-grid,
    .branch-card-grid,
    .batch-overview-metrics,
    .dashboard-table-grid,
    .analysis-support-grid {
      gap: 4px;
    }
    th,
    td {
      padding: 3px 5px;
      line-height: 1.18;
    }
    .count,
    .metric-card,
    .batch-overview-card,
    .branch-card,
    .result-card,
    .txn-box,
    .subject-box,
    .review-box,
    .issue-item {
      padding: 6px;
      border-radius: 6px;
    }
    .summary-row,
    .branch-card .summary-row {
      padding: 3px 0;
    }
    #membersList.notice {
      padding: 0;
      background: #fff;
      white-space: normal;
    }
    .member-table {
      border: 0;
      border-radius: 0;
    }
    .member-table th,
    .member-table td {
      padding: 5px 7px;
      vertical-align: middle;
    }
    .member-table td:last-child,
    .member-table th:last-child {
      width: 180px;
      text-align: right;
      white-space: nowrap;
    }
    .member-table button {
      padding: 4px 8px;
      min-height: 24px;
    }
    .modal-backdrop {
      position: fixed;
      inset: 0;
      z-index: 1000;
      display: grid;
      place-items: center;
      background: rgba(15, 23, 42, 0.35);
      padding: 20px;
    }
    .password-dialog {
      width: min(420px, 100%);
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 8px;
      box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
      padding: 14px;
    }
    .password-dialog h2 {
      margin-bottom: 10px;
    }
    .password-dialog label {
      margin-bottom: 8px;
    }
    .cell-note {
      line-height: 1.2;
    }
    @media (max-width: 1050px) {
      .grid { grid-template-columns: 1fr; }
      .pane-resizer { display: none; }
      .counts { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
      .result-grid { grid-template-columns: 1fr; }
      .metric-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
      .month-comparison-grid,
      .primary-metric-grid,
      .branch-card-grid,
      body.analysis-mode #tab-analysis { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
      .auth-box { grid-template-columns: 1fr; }
      .subject-controls { grid-template-columns: 1fr; }
      .workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
      .batch-overview-metrics { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
    }
    @media (max-width: 560px) {
      .workflow { grid-template-columns: 1fr; }
      .batch-overview-metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
      .form-row { grid-template-columns: 1fr; }
      .metric-grid { grid-template-columns: 1fr; }
      .month-comparison-grid,
      .primary-metric-grid,
      .branch-card-grid,
      body.analysis-mode #tab-analysis { grid-template-columns: 1fr; }
      .amount-row,
      .result-action-buttons,
      .force-row { grid-template-columns: 1fr; }
    }

.bank-ledger-tab {
  gap: 4px;
}

#tab-bank-ledger.bank-ledger-tab:not(.hidden) {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 124px);
  min-height: 0;
  overflow: visible;
}

#tab-bank-ledger .ledger-pane:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tight-title {
  margin: 0;
}

.bank-ledger-titlebar-compact {
  display: none;
}

.bank-ledger-toolbar-spacer {
  display: block;
  width: 1px;
  height: 1px;
}

.panel-subtle {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px;
}

.ledger-subtabs {
  display: inline-flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}

#tab-bank-ledger > .ledger-subtabs {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 34px;
  gap: 8px;
}

.ledger-subtabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 5px 12px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}

#tab-bank-ledger > .ledger-subtabs > button.active,
#tab-bank-ledger .ledger-subtabs-inner .ledger-subtabs > button.active {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-bottom-color: var(--accent);
  border-radius: 6px 6px 0 0;
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.28);
}

#tab-bank-ledger > .ledger-subtabs .bank-ledger-title-actions {
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

#tab-bank-ledger > .ledger-subtabs .bank-ledger-title-actions button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding: 5px 10px;
}

#tab-bank-ledger > .ledger-subtabs .bank-ledger-title-actions button.primary,
#tab-bank-ledger > .ledger-subtabs .bank-ledger-title-actions button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ledger-subtabs-inner {
  margin-top: -4px;
}

.ledger-pane {
  gap: 5px;
}

.ledger-admin-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0;
}

.ledger-admin-toolbar:empty {
  display: none;
}

.bank-ledger-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bank-ledger-titlebar h2 {
  margin: 0;
}

.bank-ledger-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.icon-only-button {
  min-width: 32px;
  width: 32px;
  height: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.bank-ledger-title-actions #bankLedgerUploadStatus {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 10px;
  font-weight: 700;
}

.bank-upload-panel {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 420px) 180px;
  gap: 8px;
  align-items: end;
}

.file-inline input {
  width: 100%;
}

.bank-ledger-controls {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 90px;
  gap: 8px;
  align-items: end;
}

.bank-ledger-month-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  align-items: center;
  margin: 0;
}

.bank-ledger-month-buttons {
  gap: 4px;
}

.bank-ledger-month-buttons button {
  min-width: 44px;
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.2;
}

.bank-ledger-month-buttons button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 800;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
}

.bank-sheet-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.bank-sheet-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-top: 2px;
}

.bank-sheet-tab {
  flex: 0 0 auto;
  min-width: max-content;
  max-width: none;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: #eef2f7;
  padding: 6px 12px 5px;
  text-align: left;
  white-space: nowrap;
}

.bank-sheet-tab span {
  display: block;
  overflow: visible;
  text-overflow: clip;
  font-weight: 700;
}

.bank-sheet-tab small {
  display: block;
  overflow: visible;
  text-overflow: clip;
  color: var(--muted);
  font-size: 10px;
}

.bank-sheet-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35), 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.bank-sheet-tab.active small {
  color: #dffcf7;
}

.bank-ledger-order-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.bank-ledger-order-controls button {
  min-width: 30px;
  padding: 5px 8px;
}

.bank-ledger-tools {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto auto;
  gap: 6px;
  align-items: center;
  margin: 0;
}

.bank-ledger-tools input {
  padding: 6px 8px;
}

.bank-ledger-search-input {
  width: 100%;
  min-height: 30px;
}

.bank-ledger-summary-title {
  min-height: 0;
  justify-content: flex-end;
  margin: 0;
}

#bankLedgerSummary,
#cardLedgerSummaryInline {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  background: #ecfdf5;
  color: #0f766e;
  font-weight: 800;
}

.bank-ledger-count-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.bank-ledger-edge-button {
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  font-weight: 800;
  line-height: 1;
}

.compact-input {
  min-height: 28px;
  padding: 5px 7px;
  font-size: 12px;
}

.sort-hint {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.bank-ledger-table-wrap,
.bank-review-list {
  overflow: visible;
  max-height: none;
}

.bank-ledger-table-wrap {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.bank-review-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
  margin-top: 8px;
}

.bank-review-panel.has-alert {
  border-color: #f59e0b;
  background: #fffbeb;
}

.bank-review-panel summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 700;
}

.bank-review-panel summary::-webkit-details-marker {
  display: none;
}

.bank-review-panel summary::before {
  content: "▶";
  color: var(--muted);
  font-size: 11px;
}

.bank-review-panel summary > span:first-child {
  margin-right: auto;
}

.bank-review-panel[open] summary::before {
  content: "▼";
}

.bank-review-panel .bank-review-list {
  border-top: 1px solid var(--line);
  padding: 8px;
  background: #fff;
}

.bank-ledger-table th,
.bank-ledger-table td,
.bank-review-table th,
.bank-review-table td {
  padding: 5px 7px;
  vertical-align: middle;
  border-bottom: 1px solid #e8edf3;
}

.bank-ledger-table th,
.bank-ledger-table td {
  padding: 4px 5px;
  text-align: center;
}

.bank-ledger-table {
  table-layout: fixed;
  min-width: 0;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: visible;
}

.bank-ledger-table th:nth-child(1),
.bank-ledger-table td:nth-child(1) {
  width: 8%;
  position: sticky;
  left: 0;
  z-index: 2;
}

.bank-ledger-table th:nth-child(1) {
  z-index: 4;
}

.bank-ledger-table td:nth-child(1) {
  background: inherit;
}

.bank-ledger-filter-row th:nth-child(1) {
  z-index: 5;
}

.bank-ledger-table th:nth-child(2),
.bank-ledger-table td:nth-child(2) {
  width: 13%;
}

.bank-ledger-table th:nth-child(3),
.bank-ledger-table td:nth-child(3),
.bank-ledger-table th:nth-child(4),
.bank-ledger-table td:nth-child(4),
.bank-ledger-table th:nth-child(5),
.bank-ledger-table td:nth-child(5) {
  width: 9%;
}

.bank-ledger-table th:nth-child(6),
.bank-ledger-table td:nth-child(6) {
  width: 14%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-ledger-table th:nth-child(7),
.bank-ledger-table td:nth-child(7) {
  width: 12%;
}

.bank-ledger-table th:nth-child(8),
.bank-ledger-table td:nth-child(8) {
  width: 26%;
}

.bank-ledger-table th,
.bank-review-table th {
  background: #f3f6fa;
  color: #31445c;
  font-weight: 700;
}

.bank-ledger-table thead tr:first-child th {
  position: sticky;
  top: var(--bank-ledger-sticky-top, 56px);
  z-index: 4;
  box-shadow: 0 1px 0 #dbe3ed;
}

.bank-ledger-table thead tr:first-child th:nth-child(1) {
  z-index: 6;
}

.bank-ledger-filter-row th {
  background: #f8fafc;
  padding: 3px 4px;
  position: sticky;
  top: calc(var(--bank-ledger-sticky-top, 56px) + 31px);
  z-index: 3;
  box-shadow: 0 1px 0 #dbe3ed;
}

.bank-ledger-filter-row th:nth-child(1) {
  z-index: 5;
}

.bank-ledger-filter-row input {
  width: 100%;
  min-height: 24px;
  padding: 3px 5px;
  border: 1px solid #d8e0ea;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  background: #fff;
}

.bank-ledger-filter-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.08);
  outline: 0;
}

.bank-ledger-table th:not(:last-child),
.bank-ledger-table td:not(:last-child),
.bank-review-table th:not(:last-child),
.bank-review-table td:not(:last-child) {
  border-right: 1px solid #eef2f6;
}

.bank-ledger-table tbody tr:nth-child(even),
.bank-review-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.bank-ledger-table tbody tr:hover,
.bank-review-table tbody tr:hover {
  background: #f6fbff;
}

.bank-ledger-table tbody tr:last-child td,
.bank-review-table tbody tr:last-child td {
  border-bottom: 0;
}

.bank-ledger-table th:nth-child(3),
.bank-ledger-table th:nth-child(4),
.bank-ledger-table th:nth-child(5),
.bank-ledger-table .money-cell {
  text-align: center;
  white-space: nowrap;
}

.bank-ledger-table tr.bank-ledger-revenue-row td {
  background: #fff6d7;
}

.bank-ledger-table tr.bank-ledger-revenue-row:hover td {
  background: #ffefb3;
}

.bank-ledger-table tr.bank-ledger-revenue-row .manager-select {
  border-color: #d97706;
  background: #fffdf2;
  font-weight: 700;
}

.bank-ledger-table tr.bank-ledger-manager-row td.manager-cell,
.bank-ledger-table tr.bank-ledger-manager-row td.manager-memo-cell {
  background: #fff6d7;
}

.bank-ledger-table tr.bank-ledger-manager-row:hover td.manager-cell,
.bank-ledger-table tr.bank-ledger-manager-row:hover td.manager-memo-cell {
  background: #ffefb3;
}

.bank-ledger-table tr.bank-ledger-manager-row .manager-select {
  border-color: #d97706;
  background: #fffdf2;
  font-weight: 700;
}

.bank-ledger-table tr.bank-ledger-manager-row .manager-cell {
  box-shadow: inset 3px 0 0 #f59e0b;
}

.bank-ledger-bulk-manager {
  display: grid;
  grid-template-columns: auto minmax(140px, 180px) minmax(120px, 180px) minmax(180px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff7ed;
}

.bank-ledger-bulk-manager.hidden {
  display: none;
}

.bank-ledger-bulk-manager select,
.bank-ledger-bulk-manager input {
  height: 30px;
}

.bank-ledger-table th.select-cell,
.bank-ledger-table td.select-cell {
  width: 3%;
  min-width: 34px;
  position: sticky;
  left: 0;
  z-index: 5;
  background: inherit;
}

.bank-ledger-table th:nth-child(2),
.bank-ledger-table td:nth-child(2) {
  width: 8%;
  position: sticky;
  left: 34px;
  z-index: 4;
}

.bank-ledger-table th:nth-child(2) {
  z-index: 6;
}

.bank-ledger-table td:nth-child(2) {
  background: inherit;
}

.bank-ledger-table th:nth-child(3),
.bank-ledger-table td:nth-child(3) {
  width: 13%;
}

.bank-ledger-table th:nth-child(4),
.bank-ledger-table td:nth-child(4),
.bank-ledger-table th:nth-child(5),
.bank-ledger-table td:nth-child(5),
.bank-ledger-table th:nth-child(6),
.bank-ledger-table td:nth-child(6) {
  width: 9%;
}

.bank-ledger-table th:nth-child(7),
.bank-ledger-table td:nth-child(7) {
  width: 14%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-ledger-table th:nth-child(8),
.bank-ledger-table td:nth-child(8) {
  width: 12%;
}

.bank-ledger-table th:nth-child(9),
.bank-ledger-table td:nth-child(9) {
  width: 23%;
}

.review-manager-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 5px;
}

.review-manager-controls.hidden {
  display: none;
}

.ledger-subject-cell {
  min-width: 0;
}

.ledger-subject-editor {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  gap: 2px;
  align-items: start;
}

.ledger-subject-input {
  min-height: 26px;
  padding: 3px 6px;
  font-size: 12px;
  text-align: center;
}

.ledger-subject-input.saving {
  background: #f8fafc;
  color: var(--muted);
}

.ledger-subject-arrow {
  min-height: 26px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
}

.ledger-subject-picker {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 160px;
  margin-top: 2px;
  font-size: 12px;
  text-align: left;
  z-index: 2;
}

.ledger-subject-editor.disabled {
  opacity: 0.65;
}

.manager-cell {
  min-width: 0;
}

.manager-cell-stack {
  display: grid;
  gap: 3px;
}

.manager-custom-input {
  min-height: 24px;
  font-size: 11px;
  text-align: center;
  background: #fffbeb;
  border-color: #f59e0b;
}

.manager-select {
  min-height: 26px;
  padding: 3px 6px;
  font-size: 12px;
  text-align: center;
}

.manager-memo-cell {
  min-width: 0;
  text-align: center;
}

.manager-memo {
  width: 100%;
  min-height: 26px;
  height: 26px;
  resize: none;
  padding: 3px 7px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bank-ledger-memo-text {
  display: block;
  text-align: center;
}

.manager-memo.required {
  background: #fff7ed;
  border-color: #fb923c;
}

.manager-memo.saving {
  background: #f8fafc;
  color: var(--muted);
}

.card-ledger-memo {
  min-width: 120px;
}

.manager-required-note {
  margin-top: 2px;
  font-size: 11px;
  color: var(--warn);
  font-weight: 600;
}

.manager-admin-panel .form-row {
  grid-template-columns: 160px minmax(160px, 1fr) 120px;
}

.manager-list {
  display: grid;
  gap: 8px;
}

.manager-group {
  display: grid;
  gap: 5px;
}

.manager-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.manager-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  font-size: 12px;
}

.manager-chip button {
  width: 18px;
  min-height: 18px;
  padding: 0;
  line-height: 1;
}

.manager-settlement-tab {
  gap: 8px;
}

.manager-settlement-toolbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.manager-settlement-toolbar .cell-note {
  grid-column: 1 / -1;
}

.settlement-manager-admin {
  margin: 0;
}

.settlement-manager-admin-form {
  display: grid;
  grid-template-columns: 180px minmax(180px, 1fr) 120px;
  gap: 6px;
  align-items: end;
  margin-top: 6px;
}

.settlement-manager-list {
  margin-top: 8px;
}

.settlement-subtabs {
  margin-top: 0;
}

.settlement-table th,
.settlement-table td {
  text-align: center;
  padding: 5px 7px;
  vertical-align: middle;
  border-bottom: 1px solid #e8edf3;
}

.settlement-table {
  border: 1px solid var(--line);
  border-radius: 6px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: #fff;
}

.settlement-table th {
  background: #f3f6fa;
  color: #31445c;
  font-weight: 700;
}

.settlement-table th:not(:last-child),
.settlement-table td:not(:last-child) {
  border-right: 1px solid #eef2f6;
}

.settlement-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.settlement-table tbody tr:hover {
  background: #f6fbff;
}

.settlement-table .settlement-branch-row td {
  background: #eef7f4;
  color: #0f513f;
  text-align: left;
  font-weight: 700;
  border-top: 1px solid #b7d8ce;
}

.settlement-table .settlement-branch-row span {
  margin-left: 10px;
  color: #375569;
  font-weight: 600;
}

.settlement-table .settlement-special-row td {
  background: #f8fafc;
  color: #64748b;
}

.settlement-table .cross-branch-sales-row td {
  background: #fffbeb;
}

.settlement-table tbody tr:last-child td {
  border-bottom: 0;
}

.settlement-table .money-cell {
  text-align: center;
  white-space: nowrap;
}

.settlement-metric-link {
  width: 100%;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.settlement-metric-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.settlement-pane {
  max-height: none;
}

.card-ledger-note {
  display: none;
}

.card-ledger-heading {
  display: none;
}

.card-ledger-month-bar {
  margin: 0;
}

.card-sheet-row {
  margin: 0;
}

.card-ledger-summary-title {
  margin: 0;
}

.card-ledger-tools {
  grid-template-columns: minmax(260px, 420px) auto auto;
}

#cardLedgerUploadPanel {
  display: none !important;
}

.card-ledger-check-section {
  margin-top: 6px;
  flex: 0 0 auto;
}

.card-ledger-check-section summary {
  padding: 7px 9px;
}

.card-ledger-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 6px;
  max-height: 160px;
  overflow: auto;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.card-check-item {
  display: grid;
  grid-template-columns: 160px 82px 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  background: #fff;
}

.card-check-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.card-check-ok { border-left-color: var(--ok); }
.card-check-warn { border-left-color: var(--danger); background: #fff7f7; }
.card-check-info { border-left-color: #2563eb; background: #f8fafc; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --panel: #171717;
  --line: #343434;
  --text: #f3f4f6;
  --muted: #a3a3a3;
  --accent: #2dd4bf;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #4ade80;
  --chip: #242424;
}

html[data-theme="dark"] body,
html[data-theme="dark"] header {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .status-notice,
html[data-theme="dark"] .account-match-table,
html[data-theme="dark"] .ledger-table,
html[data-theme="dark"] .subject-report-table,
html[data-theme="dark"] .cash-receipt-table,
html[data-theme="dark"] .scroll {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #64748b;
}

html[data-theme="dark"] th,
html[data-theme="dark"] .table-head,
html[data-theme="dark"] .summary-row,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .branch-card,
html[data-theme="dark"] .account-tab,
html[data-theme="dark"] .month-button,
html[data-theme="dark"] .overview-pill,
html[data-theme="dark"] .card-check-info {
  background: #202020;
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] td,
html[data-theme="dark"] tr,
html[data-theme="dark"] .cell,
html[data-theme="dark"] .ledger-row {
  border-color: #253247;
}

html[data-theme="dark"] tr:nth-child(even) td,
html[data-theme="dark"] .zero-row,
html[data-theme="dark"] .soft-row {
  background: #111111;
}

html[data-theme="dark"] tr:hover td,
html[data-theme="dark"] .analytics-table tr.clickable:hover td {
  background: #262626;
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .account-tab.active,
html[data-theme="dark"] .month-button.active,
html[data-theme="dark"] button.primary,
html[data-theme="dark"] .primary {
  background: #0f766e;
  color: #ecfeff;
  border-color: #14b8a6;
}

html[data-theme="dark"] .status-notice-info,
html[data-theme="dark"] .status-notice-ok,
html[data-theme="dark"] .status-notice-warn,
html[data-theme="dark"] .status-notice-danger,
html[data-theme="dark"] .server-status-badge,
html[data-theme="dark"] .header-badges .badge,
html[data-theme="dark"] .status,
html[data-theme="dark"] .chip {
  background: #172033;
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .server-status-badge.ok,
html[data-theme="dark"] .header-badges .badge.ok {
  background: #064e3b;
  color: #bbf7d0;
}

html[data-theme="dark"] .server-status-badge.warn,
html[data-theme="dark"] .header-badges .badge.warn {
  background: #78350f;
  color: #fde68a;
}

html[data-theme="dark"] .server-status-badge.danger,
html[data-theme="dark"] .money-negative,
html[data-theme="dark"] .danger {
  color: #fca5a5;
}

html[data-theme="dark"] .money-positive,
html[data-theme="dark"] .ok {
  color: #86efac;
}

html[data-theme="dark"] .revenue-manager-row,
html[data-theme="dark"] tr.revenue-manager-row td,
html[data-theme="dark"] .needs-manager-row,
html[data-theme="dark"] tr.needs-manager-row td {
  background: #3b2f12;
}

html[data-theme="dark"] .cash-receipt-duplicate,
html[data-theme="dark"] tr.cash-receipt-duplicate td,
html[data-theme="dark"] .card-check-warn {
  background: #3f1d24;
}

html[data-theme="dark"] .cash-receipt-issued,
html[data-theme="dark"] tr.cash-receipt-issued td {
  background: #1f2937;
  color: #94a3b8;
}

.mini-badge {
  display: inline-block;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.card-row-billing .mini-badge { background: #dbeafe; color: #1d4ed8; }
.card-row-prepaid .mini-badge { background: #dcfce7; color: var(--ok); }

.card-ledger-table th:nth-child(4),
.card-ledger-table th:nth-child(5) {
  text-align: right;
}

.card-ledger-table th:nth-child(1),
.card-ledger-table td:nth-child(1) {
  width: 8%;
}

.card-ledger-table th:nth-child(2),
.card-ledger-table td:nth-child(2) {
  width: 9%;
}

.card-ledger-table th:nth-child(3),
.card-ledger-table td:nth-child(3) {
  width: 11%;
}

.card-ledger-table th:nth-child(4),
.card-ledger-table td:nth-child(4),
.card-ledger-table th:nth-child(5),
.card-ledger-table td:nth-child(5) {
  width: 10%;
}

.card-ledger-table th:nth-child(6),
.card-ledger-table td:nth-child(6) {
  width: 12%;
}

.card-ledger-table th:nth-child(7),
.card-ledger-table td:nth-child(7) {
  width: 18%;
}

.card-ledger-table th:nth-child(8),
.card-ledger-table td:nth-child(8) {
  width: 15%;
}

.card-ledger-table th:nth-child(9),
.card-ledger-table td:nth-child(9) {
  width: 17%;
}

.table-sort-button {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: inherit;
}

.table-sort-button:hover {
  color: var(--accent);
}

.table-sort-button span {
  display: inline-block;
  min-width: 12px;
  color: var(--accent);
}

.bank-review-table th:nth-child(1) { width: 210px; }
.bank-review-table th:nth-child(2) { width: 36%; }
.bank-review-table th:nth-child(3) { width: 28%; }
.bank-review-table th:nth-child(4) { width: 260px; }

.bank-review-table textarea {
  min-height: 38px;
}

.ledger-account-admin {
  padding: 8px;
}

.ledger-permission-wrap {
  max-height: none;
  overflow: visible;
}

.ledger-permission-table {
  table-layout: auto;
  min-width: 100%;
}

.ledger-permission-table th,
.ledger-permission-table td {
  padding: 5px 7px;
  vertical-align: middle;
}

.ledger-permission-table th:nth-child(1) { width: 64px; }
.ledger-permission-table th:nth-child(2) { width: 90px; }
.ledger-permission-table th:nth-child(3) { width: 110px; }
.ledger-permission-table th:nth-child(4) { width: 210px; }
.ledger-permission-table th:nth-child(5) { width: 180px; }
.ledger-permission-table th:nth-child(6) { min-width: 340px; }

.ledger-permission-table td:nth-child(4),
.ledger-permission-table td:nth-child(5) {
  white-space: nowrap;
}

.ledger-alias-input {
  width: min(240px, 100%);
  padding: 5px 7px;
  font-weight: 600;
}

.ledger-permission-table tbody tr {
  cursor: grab;
}

.ledger-permission-table tbody tr.dragging {
  opacity: 0.55;
  outline: 2px solid var(--accent);
  background: #ecfdf5;
}

.ledger-row-move {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.ledger-drag-handle {
  min-width: 30px;
  height: 28px;
  padding: 0;
  cursor: grab;
  font-weight: 800;
  color: var(--accent);
  border-color: var(--accent);
  background: #ecfdf5;
}

.ledger-row-move-button {
  min-width: 24px;
  height: 24px;
  padding: 0;
  font-size: 11px;
}

.ledger-permission-table tr.first-row .ledger-row-move-button[title="위로"],
.ledger-permission-table tr.last-row .ledger-row-move-button[title="아래로"] {
  opacity: 0.35;
}

.ledger-permission-users {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.ledger-permission-user {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.ledger-permission-summary {
  margin-top: 4px;
  color: var(--accent-strong);
  font-weight: 600;
}

.mini-button {
  margin-left: 8px;
  min-height: 22px;
  padding: 2px 8px;
  font-size: 12px;
}

/* Dashboard one-page fit override */
body.analysis-mode main {
  padding: 8px 12px 14px;
}

body.analysis-mode header {
  padding-top: 8px;
  padding-bottom: 8px;
}

body.analysis-mode h1 {
  font-size: 16px;
}

body.analysis-mode h2 {
  font-size: 13px;
  margin: 0;
}

body.analysis-mode .header-meta {
  font-size: 11px;
}

body.analysis-mode #tab-analysis {
  display: block !important;
  margin: 0;
  padding: 0;
}

body.analysis-mode #tab-analysis > h2,
body.analysis-mode #analysisMonthCaption,
body.analysis-mode #tab-analysis > label:not(.hidden),
body.analysis-mode #tab-analysis > button,
body.analysis-mode #tab-analysis > .notice {
  display: none !important;
}

body.analysis-mode #analysisMonthButtons {
  display: flex !important;
  gap: 4px;
  margin: 0 0 6px;
}

body.analysis-mode #analysisMonthButtons button {
  min-width: 46px;
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.2;
}

body.analysis-mode #analysisView,
body.analysis-mode #analysisOverviewPane {
  gap: 6px;
}

body.analysis-mode #analysisBalanceDetailPane {
  width: calc(100vw - 8px);
  max-width: none;
  margin-left: calc(50% - 50vw + 4px);
  margin-right: calc(50% - 50vw + 4px);
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-page {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 126px);
  padding: 6px;
  border-radius: 0;
}

body.analysis-mode #analysisBalanceDetailPane .detail-title h2 {
  font-size: 16px;
}

body.analysis-mode #analysisBalanceDetailPane .detail-title .muted {
  font-size: 12.5px;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th,
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td {
  text-align: center !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(3),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(3) {
  text-align: center !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table-wrap {
  width: 100%;
  border-radius: 4px;
}

body.analysis-mode #analysisBalanceDetailPane table.balance-detail-table.analytics-compact-table {
  width: 100% !important;
  max-width: none !important;
  min-width: 100% !important;
  table-layout: fixed !important;
  font-size: 13px;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(1),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(1) {
  width: 7% !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(2),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(2) {
  width: 8% !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(3),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(3) {
  width: 20% !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(4),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(4),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(5),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(5),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(6),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(6) {
  width: 13% !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(7),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(7) {
  width: 17% !important;
}

body.analysis-mode #analysisBalanceDetailPane .balance-detail-table th:nth-child(8),
body.analysis-mode #analysisBalanceDetailPane .balance-detail-table td:nth-child(8) {
  width: 9% !important;
}

body.analysis-mode .analysis-dashboard-page {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(620px, 1fr);
  gap: 7px;
  align-items: stretch;
}

body.analysis-mode .dashboard-summary-panel {
  grid-column: 1;
  grid-row: 1;
}

body.analysis-mode .dashboard-branch-panel {
  grid-column: 2;
  grid-row: 1;
}

body.analysis-mode .dashboard-table-panel {
  grid-column: 1 / -1;
  grid-row: 2;
}

body.analysis-mode .dashboard-panel,
body.analysis-mode .dashboard-anomaly-panel {
  padding: 7px;
  border-radius: 6px;
}

body.analysis-mode .dashboard-summary-panel {
  padding: 10px;
}

body.analysis-mode .detail-title {
  min-height: 22px;
  margin-bottom: 4px;
}

body.analysis-mode .detail-title .muted,
body.analysis-mode .panel-subtitle {
  font-size: 11px;
}

body.analysis-mode .dashboard-summary-panel .primary-metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

body.analysis-mode .dashboard-summary-panel .month-comparison-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

body.analysis-mode .metric-card {
  padding: 6px;
  border-radius: 6px;
}

body.analysis-mode .dashboard-summary-panel .metric-card,
body.analysis-mode .dashboard-summary-panel .metric-card.primary-metric {
  padding: 11px 12px;
  border-radius: 6px;
}

body.analysis-mode .metric-card span {
  font-size: 11px;
}

body.analysis-mode .metric-card b {
  font-size: 17px;
  line-height: 1.15;
}

body.analysis-mode .dashboard-summary-panel .metric-card span {
  font-size: 12px;
  font-weight: 700;
}

body.analysis-mode .dashboard-summary-panel .metric-card.primary-metric b {
  font-size: clamp(22px, 1.9vw, 30px);
  line-height: 1.08;
  margin-top: 6px;
}

body.analysis-mode .dashboard-summary-panel .month-comparison-grid .metric-card b {
  font-size: 20px;
}

body.analysis-mode .metric-card .cell-note {
  font-size: 10.5px;
  line-height: 1.15;
  margin-top: 2px;
}

body.analysis-mode .dashboard-summary-panel .metric-card .cell-note {
  font-size: 11px;
  line-height: 1.2;
  margin-top: 5px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

body.analysis-mode .dashboard-branch-panel .branch-card {
  padding: 6px;
  border-radius: 6px;
}

body.analysis-mode .dashboard-branch-panel .branch-card h3 {
  margin-bottom: 2px;
  font-size: 12px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-primary {
  padding: 2px 0 3px;
  margin-bottom: 2px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-primary-label {
  font-size: 10px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-primary-value {
  font-size: 15px;
  line-height: 1.1;
}

body.analysis-mode .dashboard-branch-panel .branch-card-secondary {
  padding: 2px 0 3px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-secondary b {
  font-size: 12px;
}

body.analysis-mode .dashboard-branch-panel .branch-card-tertiary {
  padding-top: 2px;
  font-size: 10.5px;
}

body.analysis-mode .dashboard-branch-panel .branch-card .summary-row {
  padding: 2px 0;
  min-height: 18px;
}

body.analysis-mode .dashboard-table-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 6px;
}

body.analysis-mode .branch-balance-list {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

body.analysis-mode .branch-balance-row {
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 4px;
  padding: 4px 6px;
  border-radius: 5px;
}

body.analysis-mode .branch-balance-row span,
body.analysis-mode .branch-balance-row b {
  font-size: 11px;
}

body.analysis-mode .balance-total-card {
  min-height: 0;
  padding: 6px 8px;
  gap: 2px;
  border-radius: 6px;
}

body.analysis-mode .balance-total-label,
body.analysis-mode .balance-total-note {
  font-size: 10.5px;
}

body.analysis-mode .balance-total-value {
  font-size: 21px;
}

body.analysis-mode .balance-detail-button {
  min-height: 24px;
  padding: 3px 8px;
  font-size: 11px;
}

body.analysis-mode .dashboard-anomaly-panel {
  margin-top: 0;
}

body.analysis-mode #analysisAnomalies {
  display: block;
}

body.analysis-mode .anomaly-line {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  min-width: 0;
  overflow: visible;
}

body.analysis-mode .anomaly-line-item {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-left: 3px solid #0369a1;
  padding: 3px 0 3px 8px;
  background: transparent !important;
  color: #334155;
  font-size: 12px;
  line-height: 1.25;
}

body.analysis-mode .anomaly-line-item b {
  font-weight: 700;
}

body.analysis-mode .anomaly-line-item span {
  color: var(--muted);
}

body.analysis-mode .anomaly-line-item.anomaly-danger {
  border-left-color: var(--danger);
  color: #7f1d1d;
}

body.analysis-mode .anomaly-line-item.anomaly-warn {
  border-left-color: var(--warn);
  color: #78350f;
}

body.analysis-mode .anomaly-line-item.anomaly-info {
  border-left-color: #0369a1;
  color: #0c4a6e;
}

body.analysis-mode .anomaly-card {
  margin: 0;
  padding: 5px 7px;
  gap: 6px;
  border-radius: 5px;
}

body.analysis-mode .anomaly-title {
  font-size: 11.5px;
  line-height: 1.15;
}

body.analysis-mode .anomaly-detail {
  font-size: 10.5px;
  line-height: 1.15;
  margin-top: 1px;
}

body.analysis-mode .anomaly-dot {
  width: 6px;
  height: 6px;
  margin-top: 4px;
}

body.analysis-mode .dashboard-detail-tabs,
body.analysis-mode #analysisSupportPane {
  display: none !important;
}

@media (max-width: 1280px) {
  body.analysis-mode .analysis-dashboard-page {
    grid-template-columns: 1fr;
  }
  body.analysis-mode .dashboard-summary-panel,
  body.analysis-mode .dashboard-branch-panel,
  body.analysis-mode .dashboard-table-panel {
    grid-column: 1;
    grid-row: auto;
  }
  body.analysis-mode .dashboard-branch-panel .branch-card-grid,
  body.analysis-mode #analysisAnomalies {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body.analysis-mode .branch-balance-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .bank-upload-panel,
  .bank-ledger-controls {
    grid-template-columns: 1fr;
  }
}

.cash-receipt-tab {
  gap: 8px;
}

.cash-receipt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cash-receipt-filter-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.cash-receipt-branch-buttons,
.cash-receipt-branch-buttons.branch-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.cash-receipt-branch-buttons button {
  min-height: 26px;
  padding: 4px 9px;
}

.cash-receipt-toolbar .button-row {
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cash-receipt-lookup-progress {
  min-width: 74px;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.cash-receipt-issue-button {
  min-width: 104px;
  white-space: nowrap;
}

.cash-receipt-toolbar input[type="search"] {
  width: 240px;
}

.cash-receipt-note {
  padding: 7px 9px;
  font-size: 12px;
}

.cash-receipt-table-wrap {
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.cash-receipt-table th,
.cash-receipt-table td {
  padding: 5px 6px;
  vertical-align: middle;
  text-align: center;
  border-bottom: 1px solid #e8edf3;
}

.cash-receipt-table th {
  background: #f3f6fa;
  color: #31445c;
  font-weight: 700;
}

.cash-receipt-table th:not(:last-child),
.cash-receipt-table td:not(:last-child) {
  border-right: 1px solid #eef2f6;
}

.cash-receipt-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.cash-receipt-table tbody tr:hover {
  background: #f6fbff;
}

.cash-receipt-table tbody tr:last-child td {
  border-bottom: 0;
}

.cash-receipt-table input,
.cash-receipt-table select,
.cash-receipt-table textarea {
  width: 100%;
  min-width: 0;
  font-size: 12px;
  padding: 5px 6px;
  text-align: center;
}

.cash-receipt-table .cell-note {
  text-align: center;
}

.cash-receipt-money-input {
  max-width: 110px;
  text-align: center;
}

.cash-receipt-table .money-cell {
  text-align: center;
}

.cash-receipt-phone-input {
  max-width: 128px;
}

.cash-receipt-consultant-input {
  max-width: 110px;
  text-align: center;
}

.cash-receipt-client-input {
  min-width: 120px;
}

.cash-receipt-client-select {
  margin-bottom: 4px;
}

.cash-receipt-client-options {
  display: grid;
  gap: 4px;
  margin-bottom: 4px;
}

.cash-receipt-client-option {
  display: grid;
  grid-template-columns: minmax(58px, 1fr) minmax(82px, 1fr);
  gap: 2px 6px;
  width: 100%;
  padding: 5px 6px;
  border: 1px solid #f2c4c7;
  border-radius: 5px;
  background: #fffafa;
  color: #0f172a;
  text-align: left;
}

.cash-receipt-client-option b {
  font-size: 12px;
}

.cash-receipt-client-option span {
  font-size: 11px;
  color: #475569;
  text-align: right;
}

.cash-receipt-client-option em {
  grid-column: 1 / -1;
  font-style: normal;
  font-size: 11px;
  color: #b91c1c;
  font-weight: 700;
}

.cash-receipt-client-option:hover {
  border-color: #e11d48;
  background: #fff1f2;
}

.cash-receipt-status-select {
  min-width: 110px;
}

.cash-receipt-memo {
  min-height: 34px;
  resize: vertical;
}

.cash-receipt-table tr.cash-receipt-branch-row td {
  background: #e8f1fb;
  color: #12395c;
  font-weight: 800;
  text-align: left;
  padding: 7px 10px;
  border-top: 2px solid #cbddec;
}

.cash-receipt-branch-row span {
  margin-left: 8px;
  color: #52677f;
  font-size: 12px;
  font-weight: 600;
}

.cash-receipt-needs-review {
  background: #fffdf5;
}

.cash-receipt-table tr.cash-receipt-issued-row td {
  background: #f1f5f9;
  color: #64748b;
}

.cash-receipt-table tr.cash-receipt-issued-row:hover td {
  background: #e8eef5;
}

.cash-receipt-table tr.cash-receipt-duplicate-row td {
  background: #fff1f2;
}

.cash-receipt-table tr.cash-receipt-duplicate-row:hover td {
  background: #ffe4e6;
}

.cash-receipt-table .status.중복확인필요,
.cash-receipt-table .status.warn {
  color: var(--danger);
  font-weight: 700;
}

.subject-report-tab {
  gap: 6px;
}

.subject-report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.subject-report-header h2 {
  margin: 0;
}

.subject-report-branch-buttons,
.subject-report-month-buttons,
.subject-report-view-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.subject-report-branch-buttons button,
.subject-report-month-buttons button,
.subject-report-view-buttons button {
  min-width: 52px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.subject-report-branch-buttons button.active,
.subject-report-month-buttons button.active,
.subject-report-view-buttons button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.subject-report-branch-buttons .subject-report-view-chip {
  margin-left: 2px;
  background: #0f6e56;
  border-color: #0f6e56;
  color: #fff;
  font-weight: 800;
}

.subject-report-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
}

.subject-report-options .check-row {
  font-weight: 700;
  color: var(--text);
}

.subject-report-table-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: auto;
}

#subjectReportSummaryPane > .subject-report-table-wrap {
  height: calc(100vh - 320px);
  max-height: none;
  min-height: 430px;
}

.subject-report-table,
.subject-report-detail-table {
  width: 100%;
  min-width: 980px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
}

.subject-report-table th,
.subject-report-table td,
.subject-report-detail-table th,
.subject-report-detail-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #e5edf5;
  border-right: 1px solid #eef2f6;
  white-space: nowrap;
}

.subject-report-table th,
.subject-report-detail-table th {
  background: #f3f6fa;
  color: #31445c;
  font-weight: 700;
}

#subjectReportSummaryPane .subject-report-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--line);
}

.subject-report-table tbody tr:nth-child(even),
.subject-report-detail-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.subject-report-table tr.group-start td {
  border-top: 2px solid #b8d7ce;
}

.subject-report-table tr.clickable {
  cursor: pointer;
}

.subject-report-table tr.clickable:hover td {
  background: #eefbf7;
}

.subject-report-table tfoot td {
  background: #ecfdf5;
  border-top: 2px solid #93d7c8;
  font-weight: 800;
}

.subject-report-subtotal-cell {
  vertical-align: middle;
  text-align: center;
  font-weight: 800;
}

.subject-report-summary-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.subject-report-summary-line span {
  color: var(--muted);
  font-size: 12px;
}

.subject-report-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 6px;
  margin-top: 6px;
  max-width: 760px;
}

.subject-report-kpis div {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 6px 8px;
}

.subject-report-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.subject-report-kpis b {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  color: #0f172a;
}

.subject-report-table tfoot .ledger-total-row td {
  background: #f8fafc;
}

.subject-report-table tfoot .profit-total-row td {
  background: #eefbf6;
  border-top: 1px solid #99d8c6;
}

.subject-report-table th:nth-child(1),
.subject-report-table td:nth-child(1) {
  width: 8%;
}

.subject-report-table th:nth-child(2),
.subject-report-table td:nth-child(2) {
  width: 12%;
}

.subject-report-table th:nth-child(3),
.subject-report-table td:nth-child(3) {
  width: 20%;
}

.subject-report-table th:nth-child(4),
.subject-report-table td:nth-child(4),
.subject-report-table th:nth-child(5),
.subject-report-table td:nth-child(5),
.subject-report-table th:nth-child(6),
.subject-report-table td:nth-child(6),
.subject-report-table th:nth-child(7),
.subject-report-table td:nth-child(7) {
  width: 12%;
}

.subject-report-table th:nth-child(8),
.subject-report-table td:nth-child(8) {
  width: 12%;
}

.subject-report-matrix-table {
  min-width: 1380px;
}

.subject-report-matrix-table th:nth-child(1),
.subject-report-matrix-table td:nth-child(1) {
  width: 7%;
}

.subject-report-matrix-table th:nth-child(2),
.subject-report-matrix-table td:nth-child(2) {
  width: 10%;
}

.subject-report-matrix-table th:nth-child(3),
.subject-report-matrix-table td:nth-child(3) {
  width: 16%;
}

.subject-report-branch-amount,
.subject-report-matrix-total {
  text-align: right !important;
}

.subject-report-total-head,
.subject-report-matrix-total {
  width: 120px !important;
  min-width: 120px;
  font-weight: 800;
}

.subject-report-count-head,
.subject-report-count {
  width: 70px !important;
  min-width: 70px;
  text-align: center !important;
  font-weight: 800;
}

.subject-report-average-head,
.subject-report-monthly-average {
  width: 110px !important;
  min-width: 110px;
  text-align: right !important;
  font-weight: 700;
}

.subject-report-muted-row td {
  color: #94a3b8;
  background: #f8fafc;
}

.subject-report-muted-row .subject-report-branch-amount,
.subject-report-muted-row .subject-report-matrix-total,
.subject-report-muted-row .subject-report-monthly-average {
  color: #94a3b8;
  font-weight: 500;
}

.subject-report-muted-row .money-negative,
.subject-report-muted-row .money-positive {
  color: #94a3b8;
}

.subject-report-detail-table th:nth-child(1),
.subject-report-detail-table td:nth-child(1) {
  width: 9%;
}

.subject-report-detail-table th:nth-child(2),
.subject-report-detail-table td:nth-child(2) {
  width: 8%;
}

.subject-report-detail-table th:nth-child(3),
.subject-report-detail-table td:nth-child(3) {
  width: 14%;
}

.subject-report-detail-table th:nth-child(4),
.subject-report-detail-table td:nth-child(4),
.subject-report-detail-table th:nth-child(5),
.subject-report-detail-table td:nth-child(5) {
  width: 16%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-report-detail-table th:nth-child(6),
.subject-report-detail-table td:nth-child(6),
.subject-report-detail-table th:nth-child(7),
.subject-report-detail-table td:nth-child(7),
.subject-report-detail-table th:nth-child(8),
.subject-report-detail-table td:nth-child(8) {
  width: 10%;
}

.subject-report-detail-table th:nth-child(9),
.subject-report-detail-table td:nth-child(9) {
  width: 12%;
  overflow: visible;
}

.subject-report-subject-edit {
  display: grid;
  gap: 3px;
  align-items: center;
}

.subject-report-subject-edit select {
  width: 100%;
  min-width: 150px;
  height: 28px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.activity-log-title {
  margin-top: 14px;
}

.activity-log-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(140px, 180px) minmax(240px, 1fr) auto;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}

.activity-log-toolbar select,
.activity-log-toolbar input,
.activity-log-toolbar button {
  height: 32px;
}

.activity-session-list {
  padding: 8px;
}

.activity-session-title,
.activity-log-summary {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.activity-session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
}

.activity-session-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  gap: 2px;
  background: #f8fafc;
  font-size: 12px;
}

.activity-session-card b {
  font-size: 13px;
}

.activity-session-card span {
  color: var(--muted);
}

.activity-log-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}

.activity-log-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.activity-log-table th,
.activity-log-table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: middle;
}

.activity-log-table th {
  background: #f3f6fa;
  color: #31445c;
  font-weight: 700;
}

.activity-log-table th:nth-child(1),
.activity-log-table td:nth-child(1) {
  width: 120px;
  text-align: center;
}

.activity-log-table th:nth-child(2),
.activity-log-table td:nth-child(2) {
  width: 130px;
}

.activity-log-table th:nth-child(3),
.activity-log-table td:nth-child(3),
.activity-log-table th:nth-child(4),
.activity-log-table td:nth-child(4) {
  width: 110px;
  text-align: center;
}

.activity-log-table th:nth-child(5),
.activity-log-table td:nth-child(5) {
  width: 110px;
  text-align: center;
}

.activity-log-table th:nth-child(7),
.activity-log-table td:nth-child(7) {
  width: 110px;
  text-align: center;
}

.activity-log-detail {
  word-break: break-all;
  color: var(--text);
  line-height: 1.45;
}

.admin-menu-tabs {
  align-items: center;
  gap: 5px;
}

.admin-menu-tabs .tab[data-tab="members"],
.admin-menu-tabs .tab[data-tab="activity"],
.admin-menu-tabs .tab[data-tab="issues"],
.admin-menu-tabs .tab[data-tab="batch"] {
  font-weight: 700;
}

.activity-log-table td {
  word-break: keep-all;
}

.activity-log-table .cell-note {
  font-size: 11px;
}

.activity-log-table tbody tr:hover td {
  background: #f8fbff;
}

/* True black dark mode surface pass. Keep this last for late component styles. */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] main,
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .analysis-dashboard-page {
  background: #000 !important;
  color: var(--text);
}

html[data-theme="dark"] header,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .dashboard-table-box,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .branch-card,
html[data-theme="dark"] .branch-balance-row,
html[data-theme="dark"] .balance-total-card,
html[data-theme="dark"] .subject-report-table-wrap,
html[data-theme="dark"] .subject-report-kpis div,
html[data-theme="dark"] .balance-detail-page,
html[data-theme="dark"] .balance-detail-table-wrap,
html[data-theme="dark"] .account-balance-panel,
html[data-theme="dark"] .ledger-fixed-head,
html[data-theme="dark"] .ledger-toolbar,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .scroll,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .status-notice,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .card-check-item,
html[data-theme="dark"] .cash-receipt-toolbar,
html[data-theme="dark"] .card-ledger-upload-panel {
  background: #171717 !important;
  color: var(--text) !important;
  border-color: #343434 !important;
}

html[data-theme="dark"] .balance-summary-box,
html[data-theme="dark"] .balance-total-card,
html[data-theme="dark"] .branch-balance-row.total {
  background: #161f1b !important;
  border-color: #315044 !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button,
html[data-theme="dark"] .account-tab,
html[data-theme="dark"] .sheet-tab,
html[data-theme="dark"] .month-button,
html[data-theme="dark"] .mini-badge,
html[data-theme="dark"] .chip,
html[data-theme="dark"] .status {
  background: #202020 !important;
  color: var(--text) !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] thead td,
html[data-theme="dark"] .table-header,
html[data-theme="dark"] .table-head {
  background: #242424 !important;
  color: #f5f5f5 !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] td,
html[data-theme="dark"] tr,
html[data-theme="dark"] .summary-row,
html[data-theme="dark"] .cell,
html[data-theme="dark"] .ledger-row {
  border-color: #303030 !important;
}

html[data-theme="dark"] tr:nth-child(even) td,
html[data-theme="dark"] .soft-row,
html[data-theme="dark"] .zero-row {
  background: #111 !important;
}

html[data-theme="dark"] tr:hover td,
html[data-theme="dark"] .analytics-table tr.clickable:hover td {
  background: #262626 !important;
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .account-tab.active,
html[data-theme="dark"] .sheet-tab.active,
html[data-theme="dark"] .month-button.active,
html[data-theme="dark"] button.primary,
html[data-theme="dark"] .primary {
  background: #0f766e !important;
  border-color: #2dd4bf !important;
  color: #ecfeff !important;
}

/* Dark readability fixes for the account-subject report. */
html[data-theme="dark"] .subject-report-summary-line,
html[data-theme="dark"] .subject-report-summary-line span,
html[data-theme="dark"] .subject-report-options,
html[data-theme="dark"] .subject-report-options .check-row,
html[data-theme="dark"] .subject-report-kpis span {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .subject-report-kpis b,
html[data-theme="dark"] .subject-report-table td,
html[data-theme="dark"] .subject-report-detail-table td {
  color: #f8fafc !important;
}

html[data-theme="dark"] .subject-report-table tbody tr:nth-child(odd) td,
html[data-theme="dark"] .subject-report-detail-table tbody tr:nth-child(odd) td {
  background: #171717 !important;
}

html[data-theme="dark"] .subject-report-table tbody tr:nth-child(even) td,
html[data-theme="dark"] .subject-report-detail-table tbody tr:nth-child(even) td {
  background: #202020 !important;
}

html[data-theme="dark"] .subject-report-table tr.group-start td {
  border-top-color: #5eead4 !important;
}

html[data-theme="dark"] #subjectReportSummaryPane .subject-report-table thead th {
  background: #242424 !important;
  color: #f8fafc !important;
  box-shadow: 0 1px 0 #3a3a3a !important;
}

html[data-theme="dark"] .subject-report-table tr.clickable:hover td,
html[data-theme="dark"] .subject-report-detail-table tr:hover td {
  background: #2a2a2a !important;
}

html[data-theme="dark"] tr.zero-row,
html[data-theme="dark"] .subject-report-table tr.zero-row,
html[data-theme="dark"] .subject-report-detail-table tr.zero-row {
  opacity: 0.78 !important;
}

html[data-theme="dark"] .subject-report-table tr.zero-row td,
html[data-theme="dark"] .subject-report-detail-table tr.zero-row td,
html[data-theme="dark"] .money-zero {
  color: #94a3b8 !important;
}

html[data-theme="dark"] .subject-report-table .money-negative,
html[data-theme="dark"] .subject-report-detail-table .money-negative {
  color: #fca5a5 !important;
}

html[data-theme="dark"] .subject-report-table .memo-cell,
html[data-theme="dark"] .subject-report-detail-table .memo-cell {
  color: #e2e8f0 !important;
}

html[data-theme="dark"] .subject-report-subtotal-cell {
  color: #f8fafc !important;
  background: #1f1f1f !important;
}

html[data-theme="dark"] .balance-detail-button {
  background: #1f2a25 !important;
  color: #86efac !important;
  border-color: #3f6f5f !important;
}

html[data-theme="dark"] .balance-detail-button:hover {
  background: #24372f !important;
}

html[data-theme="dark"] .subject-report-table tfoot td,
html[data-theme="dark"] .subject-report-table tfoot .ledger-total-row td,
html[data-theme="dark"] .subject-report-table tfoot .profit-total-row td {
  background: #16231f !important;
  border-color: #3f6f5f !important;
}

html[data-theme="dark"] .money-zero,
html[data-theme="dark"] .muted,
html[data-theme="dark"] small {
  color: var(--muted) !important;
}

/* Dark mode final overrides kept at the end so late feature styles do not win. */
html[data-theme="dark"] body,
html[data-theme="dark"] header,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .scroll,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .ledger-fixed-head,
html[data-theme="dark"] .ledger-toolbar,
html[data-theme="dark"] .card-ledger-upload-panel,
html[data-theme="dark"] .cash-receipt-toolbar {
  background: var(--bg);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button,
html[data-theme="dark"] table,
html[data-theme="dark"] .account-tab,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .branch-card,
html[data-theme="dark"] .settlement-card,
html[data-theme="dark"] .balance-check-card {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] .metric-card-clickable:hover,
html[data-theme="dark"] .metric-card-clickable:focus-visible {
  border-color: #22d3ee !important;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.18) !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] thead td,
html[data-theme="dark"] .table-header,
html[data-theme="dark"] .sheet-tab,
html[data-theme="dark"] .overview-card {
  background: #172033;
  color: var(--text);
  border-color: var(--line);
}

html[data-theme="dark"] td,
html[data-theme="dark"] tr {
  border-color: #253247;
}

html[data-theme="dark"] tr:nth-child(even) td {
  background: #101827;
}

/* Absolute-last black theme correction. */
html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-theme="dark"] main,
html[data-theme="dark"] header {
  background: #000 !important;
}

html[data-theme="dark"] .panel,
html[data-theme="dark"] .dashboard-table-box,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .branch-card,
html[data-theme="dark"] .branch-balance-row,
html[data-theme="dark"] .balance-total-card,
html[data-theme="dark"] .subject-report-table-wrap,
html[data-theme="dark"] .subject-report-kpis div,
html[data-theme="dark"] .balance-detail-page,
html[data-theme="dark"] .account-balance-panel,
html[data-theme="dark"] .scroll,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .notice,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .card-check-item,
html[data-theme="dark"] .activity-log-list,
html[data-theme="dark"] .activity-session-card,
html[data-theme="dark"] .step,
html[data-theme="dark"] .batch-overview-card,
html[data-theme="dark"] .batch-overview-table,
html[data-theme="dark"] #membersList.notice,
html[data-theme="dark"] .member-table,
html[data-theme="dark"] .issue-item,
html[data-theme="dark"] .activity-log-table {
  background: #171717 !important;
  color: var(--text) !important;
  border-color: #343434 !important;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] button,
html[data-theme="dark"] .account-tab,
html[data-theme="dark"] .sheet-tab,
html[data-theme="dark"] .month-button,
html[data-theme="dark"] table {
  background: #202020 !important;
  color: var(--text) !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] thead td,
html[data-theme="dark"] .table-header,
html[data-theme="dark"] .table-head,
html[data-theme="dark"] .batch-overview-filter-row th,
html[data-theme="dark"] .activity-log-table th,
html[data-theme="dark"] .member-table th {
  background: #242424 !important;
  color: #f5f5f5 !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] tr:nth-child(even) td,
html[data-theme="dark"] .soft-row,
html[data-theme="dark"] .zero-row {
  background: #111 !important;
}

html[data-theme="dark"] .balance-summary-box,
html[data-theme="dark"] .balance-total-card,
html[data-theme="dark"] .branch-balance-row.total,
html[data-theme="dark"] .subject-report-table tfoot td {
  background: #161f1b !important;
  border-color: #315044 !important;
}

html[data-theme="dark"] .tab.active,
html[data-theme="dark"] .account-tab.active,
html[data-theme="dark"] .sheet-tab.active,
html[data-theme="dark"] .month-button.active,
html[data-theme="dark"] button.primary,
html[data-theme="dark"] .primary {
  background: #0f766e !important;
  border-color: #2dd4bf !important;
  color: #ecfeff !important;
}

html[data-theme="dark"] .activity-log-table tbody tr:hover td,
html[data-theme="dark"] .batch-overview-table tbody tr:hover td {
  background: #262626 !important;
}

/* Dark mode issue screen readability. Keep this at the end so legacy issue row colors cannot leak through. */
html[data-theme="dark"] #tab-issues,
html[data-theme="dark"] #tab-issues .notice,
html[data-theme="dark"] #tab-issues .issue-work-toolbar,
html[data-theme="dark"] #tab-issues .admin-issue-result-list {
  color: #f8fafc !important;
}

html[data-theme="dark"] #tab-issues .button-row,
html[data-theme="dark"] #tab-issues .toolbar-row {
  background: transparent !important;
  color: #f8fafc !important;
}

html[data-theme="dark"] .issue-summary-table,
html[data-theme="dark"] .issue-work-table {
  background: #101010 !important;
  color: #f8fafc !important;
  border-color: #343434 !important;
}

html[data-theme="dark"] .issue-summary-table th,
html[data-theme="dark"] .issue-work-table th {
  background: #242424 !important;
  color: #f8fafc !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] .issue-summary-table td,
html[data-theme="dark"] .issue-work-table td {
  background: #151515 !important;
  color: #f8fafc !important;
  border-color: #303030 !important;
}

html[data-theme="dark"] .issue-summary-table tbody tr:nth-child(even) td,
html[data-theme="dark"] .issue-work-table tbody tr:nth-child(even) td {
  background: #111 !important;
}

html[data-theme="dark"] .issue-summary-table tr.issue-critical td {
  background: #260f0f !important;
  color: #ffe4e6 !important;
}

html[data-theme="dark"] .issue-summary-table tr.issue-warn td {
  background: #241b08 !important;
  color: #fef3c7 !important;
}

html[data-theme="dark"] .issue-summary-table tr.issue-info td {
  background: #0b1825 !important;
  color: #dbeafe !important;
}

html[data-theme="dark"] .issue-summary-table tr.issue-ok td {
  background: #0f1f18 !important;
  color: #dcfce7 !important;
}

html[data-theme="dark"] .issue-summary-table td b,
html[data-theme="dark"] .issue-work-table td b,
html[data-theme="dark"] #tab-issues .issue-title {
  color: #fff !important;
}

html[data-theme="dark"] .issue-summary-table .cell-note,
html[data-theme="dark"] .issue-work-table .cell-note,
html[data-theme="dark"] #tab-issues .muted,
html[data-theme="dark"] #tab-issues small {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .issue-summary-table a,
html[data-theme="dark"] .issue-work-table a {
  color: #93c5fd !important;
}

html[data-theme="dark"] .issue-summary-table tbody tr:hover td,
html[data-theme="dark"] .issue-work-table tbody tr:hover td {
  background: #262626 !important;
  color: #fff !important;
}

html[data-theme="dark"] #tab-issues .badge,
html[data-theme="dark"] #tab-issues .pill {
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] .issue-work-table select,
html[data-theme="dark"] .issue-work-table textarea,
html[data-theme="dark"] #tab-issues input,
html[data-theme="dark"] #tab-issues select,
html[data-theme="dark"] #tab-issues textarea {
  background: #202020 !important;
  color: #f8fafc !important;
  border-color: #3a3a3a !important;
}

html[data-theme="dark"] .subject-report-table tr.subject-report-muted-row td {
  background: #121212 !important;
  color: #7f8b9a !important;
}

html[data-theme="dark"] .subject-report-muted-row .money-negative,
html[data-theme="dark"] .subject-report-muted-row .money-positive,
html[data-theme="dark"] .subject-report-muted-row .money-zero {
  color: #7f8b9a !important;
}

/* Dark mode revenue/manager-highlight rows in bank ledger. */
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row td,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row td.manager-cell,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row td.manager-memo-cell,
html[data-theme="dark"] tr.revenue-manager-row td,
html[data-theme="dark"] tr.needs-manager-row td {
  background: #2a210b !important;
  color: #fff7d6 !important;
}

html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row:hover td,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row:hover td.manager-cell,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row:hover td.manager-memo-cell,
html[data-theme="dark"] tr.revenue-manager-row:hover td,
html[data-theme="dark"] tr.needs-manager-row:hover td {
  background: #3a2b0c !important;
  color: #fffbe8 !important;
}

html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row .cell-note,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row .cell-note,
html[data-theme="dark"] tr.revenue-manager-row .cell-note,
html[data-theme="dark"] tr.needs-manager-row .cell-note {
  color: #facc15 !important;
}

html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row input,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row select,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row textarea,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row input,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row select,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row textarea,
html[data-theme="dark"] tr.revenue-manager-row input,
html[data-theme="dark"] tr.revenue-manager-row select,
html[data-theme="dark"] tr.revenue-manager-row textarea,
html[data-theme="dark"] tr.needs-manager-row input,
html[data-theme="dark"] tr.needs-manager-row select,
html[data-theme="dark"] tr.needs-manager-row textarea {
  background: #17130a !important;
  color: #fff7d6 !important;
  border-color: #b7791f !important;
}

html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-revenue-row .manager-select,
html[data-theme="dark"] .bank-ledger-table tr.bank-ledger-manager-row .manager-select {
  background: #1f1708 !important;
  color: #fff !important;
  border-color: #f59e0b !important;
  box-shadow: inset 3px 0 0 #f59e0b !important;
}

/* Dark mode final pass: remove legacy fixed-white cards. */
html[data-theme="dark"] .count,
html[data-theme="dark"] .summary-grid,
html[data-theme="dark"] .summary-row,
html[data-theme="dark"] .result-card,
html[data-theme="dark"] .result-compact-table,
html[data-theme="dark"] .txn-box,
html[data-theme="dark"] .review-box,
html[data-theme="dark"] .coded-edit-grid,
html[data-theme="dark"] .force-compact,
html[data-theme="dark"] .status-notice,
html[data-theme="dark"] .upload-panel,
html[data-theme="dark"] .batch-detail-card,
html[data-theme="dark"] .account-match-row,
html[data-theme="dark"] .matching-new-account,
html[data-theme="dark"] details,
html[data-theme="dark"] summary {
  background: #171717 !important;
  color: #f8fafc !important;
  border-color: #343434 !important;
}

html[data-theme="dark"] .count span,
html[data-theme="dark"] .count .muted,
html[data-theme="dark"] .summary-row span {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .count b,
html[data-theme="dark"] .summary-row b {
  color: #f8fafc !important;
}

html[data-theme="dark"] .status.matched,
html[data-theme="dark"] .status.approved,
html[data-theme="dark"] .status.confirmed {
  background: #0f1f18 !important;
  color: #86efac !important;
}

html[data-theme="dark"] .status.invalid_subject,
html[data-theme="dark"] .status.needs_review,
html[data-theme="dark"] .status.suspicious_subject,
html[data-theme="dark"] .status.amount_mismatch,
html[data-theme="dark"] .status.duplicate {
  background: #241b08 !important;
  color: #fde68a !important;
}

html[data-theme="dark"] .status.missing_in_coded,
html[data-theme="dark"] .status.missing_in_raw,
html[data-theme="dark"] .status.parse_error,
html[data-theme="dark"] .status.column_error,
html[data-theme="dark"] .status.date_error,
html[data-theme="dark"] .status.amount_error,
html[data-theme="dark"] .status.balance_mismatch,
html[data-theme="dark"] .status.rejected {
  background: #260f0f !important;
  color: #fca5a5 !important;
}

/* Bank/card ledger active selections must stay obvious in both themes. */
html[data-theme="dark"] #tab-bank-ledger > .ledger-subtabs > button.active,
html[data-theme="dark"] #tab-bank-ledger .ledger-subtabs-inner .ledger-subtabs > button.active,
html[data-theme="dark"] .bank-ledger-month-buttons button.active,
html[data-theme="dark"] .bank-sheet-tab.active {
  background: #14b8a6 !important;
  color: #031615 !important;
  border-color: #5eead4 !important;
  box-shadow: 0 0 0 2px rgba(94, 234, 212, 0.26), inset 0 -3px 0 rgba(255, 255, 255, 0.22) !important;
}

html[data-theme="dark"] .bank-sheet-tab.active small {
  color: #083f3b !important;
}

html[data-theme="dark"] #bankLedgerSummary,
html[data-theme="dark"] #cardLedgerSummaryInline {
  background: #062f2d !important;
  color: #ccfbf1 !important;
  border-color: #14b8a6 !important;
}
