.structured-root {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-success { color: #22c55e !important; }
.text-error { color: #ef4444 !important; }
.techy { font-family: 'SF Mono', 'Roboto Mono', 'Menlo', 'Monaco', Consolas, monospace; letter-spacing: -0.02em; }
.opaque { opacity: 0.5; }
.align-right { text-align: right; }
.mb-4 { margin-bottom: 1rem; }
.mt-6 { margin-top: 1.5rem; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.stat-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

/* Layout */
.data-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
  align-items: start;
}

.data-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--glass-border);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

.category-group-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
}

.category-group-bar__label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.category-group-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  gap: 2px;
}

.category-group-toggle__btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.category-group-toggle__btn:hover {
  color: #e5e7eb;
}

.category-group-toggle__btn--active {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.summary-panel, .notes-panel, .data-table-panel {
  padding: 1.5rem;
}

/* Categories */
.category-bars {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

button.category-item--filter {
  width: 100%;
  margin: 0;
  padding: 0.75rem 0.85rem 0.85rem;
  gap: 0.65rem;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  box-sizing: border-box;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

button.category-item--filter:hover {
  background: rgba(255, 255, 255, 0.04);
}

button.category-item--filter:focus-visible {
  outline: 2px solid var(--accent-primary, #6366f1);
  outline-offset: 2px;
}

button.category-item--filter.category-item--active {
  background: rgba(99, 102, 241, 0.12);
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.55);
}

.category-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
}

.category-name { color: var(--text-primary); }
.category-value { font-family: monospace; color: var(--text-secondary); }

.category-meter-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  overflow: hidden;
}

.category-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: inherit;
  transition: width 0.5s ease;
}

.ledger-panel-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.panel-header--ledger-filter {
  align-items: flex-start;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  gap: 1rem;
}

.panel-header--ledger-filter .ledger-header-actions {
  margin-top: 0.15rem;
}

.ledger-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.ledger-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.ledger-filter-count {
  flex: 1 1 auto;
  min-width: 0;
}

.ledger-filter-badge {
  flex-shrink: 0;
}

td.ledger-empty {
  text-align: center;
  padding: 2rem 1rem;
}

/* Notes */
.notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.note-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  margin-top: 6px;
  flex-shrink: 0;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
}

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

.ai-table th:nth-child(1), .ai-table td:nth-child(1) { width: 1%; white-space: nowrap; }
.ai-table th:nth-child(3), .ai-table td:nth-child(3),
.ai-table th:nth-child(4), .ai-table td:nth-child(4) { width: 1%; white-space: nowrap; }
.ai-table th:nth-child(5), .ai-table td:nth-child(5) { width: 1%; white-space: nowrap; }
.ai-table th:nth-child(6), .ai-table td:nth-child(6) { width: 1%; white-space: nowrap; }

.ai-table td, 
.ai-table th {
  padding: 1.25rem 0.5rem;
}

.ai-table td:nth-child(2) {
  word-break: break-word;
  min-width: 200px;
}

.ai-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #6b7280;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.ai-table tbody tr {
  transition: background-color 0.2s ease;
}
.ai-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.ai-table tbody td {
  vertical-align: middle;
  font-size: 0.95rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.ai-table tbody td.align-right.techy {
  color: #f3f4f6;
}
.ai-table tbody td.align-right.techy.text-success {
  color: #22c55e !important;
}

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

.mini-pill--sub {
  font-size: 0.75rem;
  opacity: 0.95;
}

.ledger-row--edited {
  background: rgba(59, 130, 246, 0.06);
}

.ledger-edited-tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
  margin-bottom: 4px;
}

.ledger-actions {
  white-space: nowrap;
  text-align: right;
}

.txn-edit-dialog {
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 2rem);
  color: #e5e7eb;
  background: #0f172a;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.05);
}

.txn-edit-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
}

.txn-edit-dialog form {
  padding: 1.5rem 2rem 2rem;
}

.txn-edit-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.txn-edit-dialog__close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.txn-edit-dialog__hint {
  font-size: 0.85rem;
  margin: 0 0 1rem;
  line-height: 1.45;
}

.txn-edit-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.txn-edit-field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.txn-edit-field--checkbox input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  cursor: pointer;
}

.txn-edit-category-mode[hidden] {
  display: none !important;
}

.txn-edit-field__label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.txn-edit-input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
  color: #f3f4f6;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}

select.txn-edit-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(255,255,255,0.5)'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

.txn-edit-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.5);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

textarea.txn-edit-input {
  resize: vertical;
  min-height: 4.5rem;
}

.txn-edit-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.txn-edit-dialog__actions button {
  border-radius: 20px;
}

.txn-edit-dialog__actions .btn-primary {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
  border: none;
  color: white;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #d1d5db;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-edit-txn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  vertical-align: middle;
}

.btn-edit-txn svg {
  width: 14px;
  height: 14px;
}

.btn-edit-txn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
  color: #d1d5db;
  transform: scale(1.05);
}

.panel-header--raw-transcript {
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

button.btn-copy-transcript {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 10.5rem;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

button.btn-copy-transcript:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.btn-copy-transcript:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}

button.btn-copy-transcript--success {
  background: rgba(34, 197, 94, 0.18) !important;
  border-color: rgba(34, 197, 94, 0.55) !important;
  color: #bbf7d0 !important;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.2);
}

button.btn-copy-transcript--success:not(:disabled):hover {
  background: rgba(34, 197, 94, 0.26) !important;
  border-color: rgba(34, 197, 94, 0.65) !important;
}

.btn-copy-transcript__icon {
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 700;
}

.scroll-y {
  max-height: 400px;
  overflow-y: auto;
}

.raw-text-view {
  font-family: monospace;
  font-size: 0.85rem;
  color: #d1d5db;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 8px;
  margin: 0;
}

/* Error Panel */
.error-panel {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  padding: 2rem;
  text-align: center;
}

.error-title {
  color: #ef4444;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.error-text { margin: 0; color: #fca5a5; }

@media (max-width: 1024px) {
  .data-layout { grid-template-columns: 1fr; }
}
