/* ============================================
   BENNETT FIDUCIARY — MASTER STYLESHEET
   Refined legal/professional aesthetic
   ============================================ */

:root {
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;

  --bg-primary: #FAFAF8;
  --bg-secondary: #F4F3EF;
  --bg-tertiary: #ECEAE3;
  --bg-sidebar: #1C1C1A;
  --bg-sidebar-hover: #2A2A27;
  --bg-sidebar-active: #333330;

  --text-primary: #1A1A18;
  --text-secondary: #6B6B64;
  --text-tertiary: #9B9B92;
  --text-sidebar: #E8E8E2;
  --text-sidebar-muted: #8A8A82;

  --border-light: #E4E3DC;
  --border-medium: #D4D3CA;

  --accent-green: #1D9E75;
  --accent-red: #E24B4A;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Matter palette vars (overridden per matter) */
  --matter-dot: #1D9E75;
  --matter-accent: #E1F5EE;
  --matter-text: #085041;
  --matter-mid: #5DCAA5;
}

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

html, body { height: 100%; font-family: var(--font-body); background: var(--bg-primary); color: var(--text-primary); font-size: 14px; line-height: 1.6; }

.hidden { display: none !important; }

/* ============ LOGIN ============ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sidebar);
  background-image: radial-gradient(ellipse at 30% 50%, #2A2A25 0%, #1C1C1A 100%);
}

.login-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 40px 44px;
  width: 360px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.logo-mark {
  width: 48px;
  height: 48px;
  background: var(--bg-sidebar);
  color: #E8E8E2;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.login-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.login-field {
  margin-bottom: 16px;
}

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

.login-field input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--text-secondary);
}

.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.15s;
  margin-top: 4px;
}

.login-btn:hover { background: #2A2A27; }

.login-err {
  font-size: 12px;
  color: var(--accent-red);
  margin-top: 10px;
  min-height: 16px;
  text-align: center;
}

/* ============ APP LAYOUT ============ */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */
#sidebar {
  width: 256px;
  min-width: 256px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-top {
  padding: 20px 16px 12px;
  border-bottom: 1px solid #2A2A27;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  background: #333330;
  color: #E8E8E2;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-sidebar);
  line-height: 1.2;
}

.brand-loc {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  margin-top: 1px;
}

.new-matter-btn {
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 1px dashed #444441;
  border-radius: var(--radius-sm);
  color: var(--text-sidebar-muted);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.new-matter-btn:hover {
  border-color: #666660;
  color: var(--text-sidebar);
}

.matter-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.matter-list::-webkit-scrollbar { width: 4px; }
.matter-list::-webkit-scrollbar-track { background: transparent; }
.matter-list::-webkit-scrollbar-thumb { background: #333330; border-radius: 2px; }

.matter-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s;
  border: 1px solid transparent;
}

.matter-item:hover { background: var(--bg-sidebar-hover); }

.matter-item.active {
  background: var(--bg-sidebar-active);
  border-color: #444441;
}

.matter-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matter-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.matter-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matter-item-meta {
  font-size: 11px;
  color: var(--text-sidebar-muted);
  margin-top: 2px;
  margin-left: 16px;
}

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid #2A2A27;
}

.signout-btn {
  width: 100%;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-sidebar-muted);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.signout-btn:hover { color: var(--text-sidebar); }

/* ============ MAIN ============ */
#main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.no-matter {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.no-matter-inner {
  text-align: center;
}

.no-matter-icon {
  width: 64px;
  height: 64px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: 0 auto 16px;
}

.no-matter-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.no-matter-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 280px;
}

/* ============ TOPBAR ============ */
.topbar {
  background: var(--bg-primary);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topbar-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-type {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1px;
}

.task-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--matter-accent);
  color: var(--matter-text);
  font-weight: 500;
}

.accent-bar {
  height: 3px;
  background: var(--matter-dot);
  opacity: 0.6;
}

/* ============ TABS ============ */
.tabs {
  background: var(--bg-primary);
  padding: 0 24px;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
}

.tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
}

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

.tab.active {
  color: var(--matter-dot);
  border-bottom-color: var(--matter-dot);
  font-weight: 500;
}

/* ============ TAB CONTENT ============ */
.tab-content {
  padding: 24px;
  flex: 1;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--matter-dot);
}

/* ============ FORM FIELDS ============ */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-grid.full { grid-template-columns: 1fr; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field.span2 { grid-column: 1 / -1; }

.field label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color 0.15s;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--matter-dot);
}

.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* ============ BUTTONS ============ */
.btn-primary {
  padding: 8px 18px;
  background: var(--matter-dot);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }

.btn-secondary {
  padding: 8px 18px;
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-ghost {
  padding: 7px 14px;
  background: none;
  color: var(--text-secondary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 10px;
}

.btn-ghost:hover {
  border-color: var(--matter-dot);
  color: var(--matter-dot);
}

.btn-save {
  padding: 8px 18px;
  background: none;
  color: var(--matter-dot);
  border: 1px solid var(--matter-dot);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-save:hover {
  background: var(--matter-accent);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  transition: all 0.15s;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--accent-red);
  background: #FEF0F0;
}

/* ============ TABLES ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 6px 10px 10px 0;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 11px 10px 11px 0;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.data-table tr:hover td { background: var(--bg-secondary); }

/* ============ BADGES ============ */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--matter-accent);
  color: var(--matter-text);
  white-space: nowrap;
}

/* ============ CHECKING ============ */
.balance-display {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 16px;
}

.balance-amount {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  color: var(--matter-dot);
}

.balance-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.txn-credit { color: var(--accent-green); font-weight: 500; }
.txn-debit { color: var(--accent-red); font-weight: 500; }

.txn-btns {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ============ TASKS ============ */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.task-row:last-of-type { border-bottom: none; }

.task-check {
  width: 17px;
  height: 17px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--matter-dot);
}

.task-text {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
}

.task-done .task-text {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.task-date {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.task-date.overdue {
  color: var(--accent-red);
  font-weight: 500;
}

.tasks-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  padding: 14px 0 4px;
  font-weight: 500;
}

/* ============ NOTES ============ */
.notes-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font-body);
  line-height: 1.7;
  background: var(--bg-secondary);
  color: var(--text-primary);
  resize: vertical;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--matter-dot);
}

/* ============ COLOR PALETTE PICKER ============ */
.palette-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

.palette-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.palette-swatches {
  display: flex;
  gap: 6px;
}

.palette-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}

.palette-swatch:hover { transform: scale(1.15); }
.palette-swatch.selected { border-color: var(--text-primary); }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 32px 0;
  color: var(--text-tertiary);
  font-size: 13px;
  font-style: italic;
}

/* ============ MODAL ============ */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 400px;
  max-width: 92vw;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text-primary); background: var(--bg-secondary); }

#modal-body {
  padding: 18px 22px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-light);
}

.modal-field {
  margin-bottom: 14px;
}

.modal-field:last-child { margin-bottom: 0; }

.modal-field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 5px;
}

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: var(--matter-dot);
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.2s ease;
}

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

/* ============ LOADING ============ */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  #sidebar { width: 200px; min-width: 200px; }
  .tab { padding: 10px 10px; font-size: 12px; }
  .tab-content { padding: 16px; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: auto; max-height: 50vh; }
  .matter-list { max-height: 200px; }
}
