/* ============================================================
   DuTrack — Phase 3b styles
   Navy palette with light/dark mode via :root class toggle
   ============================================================ */

:root {
  --bg-outer: #B5A595;
  --bg-phone: #F5F1EA;
  --card: #FFFFFF;
  --card-soft: #F9F5EE;
  --text: #1A2238;
  --text-2: #5C6680;
  --text-3: #A0A8BC;
  --border: #E2E6F0;
  --border-soft: #EEF1F7;
  --accent: #1F3A5F;
  --accent-hover: #16294A;
  --accent-tint: #E8EDF5;
  --secondary: #2E5D4A;
  --danger: #B33A3A;
  --danger-bg: #FBEAEA;
  --slice-1: #1F3A5F;
  --slice-2: #2E5D4A;
  --slice-3: #C77B5E;
  --slice-4: #C9A348;
  --slice-5: #5E8FD4;
  --slice-6: #6D4F7A;
  --slice-7: #4A8A8A;
  --slice-8: #D96B6B;
}

:root.dark {
  --bg-outer: #0A0E1A;
  --bg-phone: #131826;
  --card: #1E2435;
  --card-soft: #252B3D;
  --text: #E8EDF5;
  --text-2: #A0A8BC;
  --text-3: #6B7388;
  --border: #2D3447;
  --border-soft: #1E2435;
  --accent: #5E8FD4;
  --accent-hover: #7BA5DE;
  --accent-tint: #1F2A45;
  --secondary: #4A8A6E;
  --danger: #E66B6B;
  --danger-bg: #2A1818;
  --slice-1: #5E8FD4;
  --slice-2: #4A8A6E;
  --slice-3: #D88A6B;
  --slice-4: #D9B85C;
  --slice-5: #8FB1E0;
  --slice-6: #9070A8;
  --slice-7: #6BA8A8;
  --slice-8: #E08585;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-outer);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  background: var(--bg-phone);
  min-height: 100vh;
  transition: background 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 481px) {
  body {
    padding: 32px;
    display: flex; align-items: flex-start; justify-content: center;
    /* Soften the surrounding "wallpaper" so the phone-shaped app doesn't float in a sea of brown */
    background: linear-gradient(180deg, var(--bg-outer) 0%, var(--bg-phone) 60%);
  }
  :root.dark body {
    background: linear-gradient(180deg, #0A0E1A 0%, var(--bg-phone) 70%);
  }
  #app {
    border-radius: 32px;
    overflow: hidden;
    width: 480px;
    max-width: 100%;
    min-height: 760px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 12px 32px rgba(0,0,0,0.10);
  }
}

.hidden { display: none !important; }

.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
  padding: 32px 28px;
  position: relative;
  flex: 1;
}

@media (min-width: 481px) {
  .login-wrap { min-height: 760px; }
}

.logo-circle {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 28px;
  transition: background 0.2s;
}
.logo-circle i { font-size: 32px; }

.brand-title { font-size: 30px; font-weight: 600; color: var(--text); margin: 0; letter-spacing: -0.5px; }
.brand-sub { color: var(--text-2); font-size: 14px; margin: 6px 0 0; }

.form-block { width: 100%; max-width: 360px; margin-top: 36px; }
.app-label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 8px; text-align: left; }

/* ============================================================
   INPUTS
   ============================================================ */
input.app-input {
  width: 100%;
  padding: 15px 18px;
  font-size: 15px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
}
input.app-input:focus { outline: none; border-color: var(--accent); }
input.app-input::placeholder { color: var(--text-3); }

input.date-input {
  flex: 1;
  padding: 11px 14px;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  min-width: 0;
  -webkit-appearance: none;
  transition: border-color 0.15s, background 0.2s, color 0.2s;
}
input.date-input:focus { outline: none; border-color: var(--accent); }
input.date-input.invalid { border-color: var(--danger); }
:root.dark input.date-input::-webkit-calendar-picker-indicator { filter: invert(0.7); }

/* Hidden date picker for the Add tab — triggered programmatically by the "Change" button.
   Positioned centered-fixed so the native picker anchors at a sensible spot, but invisible. */
.hidden-date-picker {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: none;
  padding: 0;
  margin: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
button.btn-accent {
  width: 100%;
  padding: 16px 18px;
  background: var(--accent); color: #FFFFFF;
  border: none;
  border-radius: 100px;
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.05s;
}
button.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
button.btn-accent:active:not(:disabled) { transform: scale(0.99); }
button.btn-accent:disabled { background: var(--border); color: var(--text-3); cursor: not-allowed; }

button.btn-change {
  background: none; border: none;
  color: var(--accent); font-size: 12px; font-weight: 500;
  cursor: pointer; padding: 6px 10px; border-radius: 8px;
  font-family: inherit;
  transition: background 0.15s;
}
button.btn-change:hover { background: var(--accent-tint); }

button.theme-toggle,
button.qa-icon-btn {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer;
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
button.theme-toggle:hover,
button.qa-icon-btn:hover { background: var(--card-soft); }
button.theme-toggle i,
button.qa-icon-btn i { font-size: 18px; }

#theme-toggle-login {
  position: absolute; top: 20px; right: 22px;
}

button.btn-sheet {
  flex: 1; padding: 13px 16px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); cursor: pointer;
  border-radius: 100px; font-size: 14px; font-weight: 500;
  font-family: inherit;
  transition: background 0.15s;
}
button.btn-sheet:hover { background: var(--card-soft); }
button.btn-sheet.danger { color: var(--danger); border-color: rgba(179, 58, 58, 0.3); }
button.btn-sheet.danger:hover { background: var(--danger-bg); }
button.btn-sheet.full { flex: none; width: 100%; margin-top: 14px; }
button.btn-sheet:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   TABS (Add / History / Stats)
   ============================================================ */
#authed-view {
  display: flex; flex-direction: column;
  flex: 1; min-height: 100vh;
}
@media (min-width: 481px) {
  #authed-view { min-height: 760px; }
}

.tab-view {
  display: flex; flex-direction: column; flex: 1;
  min-height: 0;
}

.qa-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 22px 14px;
  flex-shrink: 0;
}
.qa-title { font-size: 22px; font-weight: 600; color: var(--text); margin: 0; letter-spacing: -0.3px; }
.qa-actions { display: flex; gap: 8px; }

.screen-area {
  flex: 1; overflow-y: auto;
  min-height: 0;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-phone);
  padding: 10px 0 16px;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; color: var(--text-3); font-size: 11px;
  transition: color 0.15s;
  padding: 4px 0;
  user-select: none;
}
.nav-item.active { color: var(--accent); font-weight: 500; }
.nav-item i { font-size: 22px; }

/* ============================================================
   ADD TAB (Quick Add — same as Phase 3a)
   ============================================================ */
.qa-body { padding: 0 22px 16px; }

.preview-card {
  background: var(--card);
  border-radius: 22px;
  padding: 24px 22px;
  margin-top: 14px;
  min-height: 180px;
  border: 1px solid var(--border);
  transition: background 0.2s, border-color 0.2s;
}
.preview-empty {
  color: var(--text-3); text-align: center;
  padding: 44px 0; font-size: 13px;
}
.preview-empty i { font-size: 18px; margin-right: 6px; vertical-align: -3px; }
.preview-amount { font-size: 38px; font-weight: 500; color: var(--text); letter-spacing: -1.2px; line-height: 1; }
.preview-item { font-size: 14px; color: var(--text-2); margin-top: 8px; word-break: break-word; }

.cat-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 24px; padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.cat-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cat-icon-wrap {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.cat-icon-wrap i { font-size: 20px; }
.cat-text { min-width: 0; }
.cat-label-mini { font-size: 11px; color: var(--text-3); letter-spacing: 0.5px; margin: 0 0 2px; }
.cat-name {
  font-size: 14px; font-weight: 500; color: var(--text); margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-parent { font-size: 12px; color: var(--text-2); margin: 2px 0 0; }

.cat-modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px;
  margin-top: 12px;
  max-height: 380px;
  overflow-y: auto;
}
.cat-modal-title {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 0.6px; padding: 8px 12px 10px;
  margin: 0;
}
.cat-item {
  padding: 10px; display: flex; align-items: center; gap: 12px;
  border-radius: 14px; cursor: pointer;
  transition: background 0.1s;
}
.cat-item:hover { background: var(--card-soft); }
.cat-item.selected { background: var(--accent-tint); }
.cat-item.selected .cat-name { color: var(--accent); }

.cat-parent-item { margin-top: 6px; }
.cat-parent-item:first-child { margin-top: 0; }
.cat-parent-item .cat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.cat-sub-item { padding-left: 28px; }
.cat-sub-item .cat-icon-wrap {
  width: 32px; height: 32px;
}
.cat-sub-item .cat-icon-wrap i { font-size: 16px; }
.cat-sub-item .cat-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.cat-sub-item.selected .cat-name { color: var(--accent); }

.save-wrap { padding: 16px 0 0; }

/* ============================================================
   FILTER CHIPS + DATE RANGE
   ============================================================ */
.filter-chips {
  display: flex; gap: 6px;
  padding: 4px 22px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 12px; font-size: 11px;
  background: var(--card); color: var(--text-2);
  border: 1px solid var(--border); border-radius: 100px;
  cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.filter-chip:hover { background: var(--card-soft); }
.filter-chip.active {
  background: var(--accent); color: #FFFFFF;
  border-color: var(--accent);
}

.date-range-wrap {
  display: none;
  padding: 2px 22px 8px;
  gap: 8px;
  flex-shrink: 0;
}
.date-range-wrap.show { display: flex; }

.date-range-error {
  margin: 0 22px 10px;
  padding: 8px 12px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 10px;
  font-size: 12px;
  flex-shrink: 0;
}

/* ============================================================
   HISTORY LIST
   ============================================================ */
.history-list { padding: 6px 22px 24px; }

.day-header {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 0.6px;
  margin: 14px 0 4px;
  padding-top: 8px;
}
.day-header:first-child { padding-top: 0; }

.expense-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.1s;
}
.expense-row:last-child { border-bottom: none; }
.expense-row:active { background: var(--card-soft); }

.expense-icon {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.expense-icon i { font-size: 18px; }
.expense-text { flex: 1; min-width: 0; }
.expense-item {
  font-size: 14px; font-weight: 500; color: var(--text); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.expense-meta {
  font-size: 11px; color: var(--text-2); margin: 2px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.expense-amount {
  font-size: 14px; font-weight: 500; color: var(--text);
  text-align: right; white-space: nowrap;
}

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */
.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-3);
}
.empty-state i { font-size: 36px; opacity: 0.5; }
.empty-state p { margin: 12px 0 0; font-size: 13px; }
.empty-state .sub { font-size: 11px; margin-top: 4px; opacity: 0.7; }

.loading-state {
  display: flex; justify-content: center; align-items: center;
  padding: 80px 24px;
  color: var(--text-3);
}
.loading-state i { font-size: 26px; }

/* ============================================================
   STATS — donut chart
   ============================================================ */
.stats-area { padding: 24px 22px 24px; }

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1;
  margin: 0 auto 8px;
}

.chart-tooltip {
  position: absolute;
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 14px;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 5;
}
:root.dark .chart-tooltip { box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.chart-tooltip.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tooltip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tooltip-name, .tooltip-amount { font-size: 12px; font-weight: 500; color: var(--text); }
.tooltip-pct { font-size: 11px; color: var(--text-2); }
.tooltip-sep { color: var(--text-3); font-size: 11px; opacity: 0.7; }

.donut-svg { display: block; width: 100%; height: 100%; }
.donut-slice { cursor: pointer; transition: opacity 0.2s; }
.donut-slice.dim { opacity: 0.2; }

.chart-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  max-width: 150px;
}
.chart-label {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 0.6px;
  line-height: 1.25;
  word-wrap: break-word;
}
.chart-total {
  font-size: 22px; font-weight: 600; color: var(--text);
  margin-top: 4px; letter-spacing: -0.5px;
}

.hint {
  text-align: center; font-size: 11px;
  color: var(--text-3); margin: 8px 0 0;
  transition: opacity 0.2s;
}

/* ============================================================
   STATS — legend
   ============================================================ */
.legend-list { margin-top: 12px; }
.legend-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; margin: 0 -12px;
  border-bottom: 1px solid var(--border-soft);
  border-radius: 12px; cursor: pointer;
  transition: background 0.15s;
}
.legend-row:last-child { border-bottom: none; }
.legend-row.selected {
  background: var(--accent-tint);
  border-bottom-color: transparent;
}

.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-text { flex: 1; min-width: 0; }
.legend-name { font-size: 14px; color: var(--text); margin: 0; font-weight: 500; }
.legend-pct { font-size: 11px; color: var(--text-2); margin: 2px 0 0; }
.legend-amount { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; }
.legend-chevron {
  color: var(--text-3); font-size: 16px;
  opacity: 0.5; margin-left: 2px; flex-shrink: 0;
}

/* ============================================================
   DRILL-DOWN SHEET
   ============================================================ */
.drill-backdrop {
  position: fixed; inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.4);
  display: none; align-items: flex-end;
  justify-content: center;
}
.drill-backdrop.show { display: flex; }

.drill-sheet {
  background: var(--bg-phone);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 18px 22px 22px;
  max-height: 85vh;
  overflow-y: auto;
  animation: sheet-up 0.25s ease-out;
  display: flex; flex-direction: column;
}
@media (min-width: 481px) {
  .drill-sheet { max-width: 480px; }
}

@keyframes sheet-up {
  from { transform: translateY(60px); opacity: 0.5; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 14px;
}

.drill-header { margin: 0 0 6px; display: flex; align-items: center; gap: 12px; }
.drill-cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.drill-title { font-size: 18px; font-weight: 600; color: var(--text); margin: 0; flex: 1; }
.drill-summary { font-size: 13px; color: var(--text-2); margin: 0 0 14px; padding-left: 24px; }

.drill-list { flex: 1; padding: 4px 0; }
.drill-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
}
.drill-item:last-child { border-bottom: none; }
.drill-item:active { background: var(--card-soft); }

/* ============================================================
   EDIT SHEET (stacks on top)
   ============================================================ */
.edit-backdrop {
  position: fixed; inset: 0;
  z-index: 110;
  background: rgba(0,0,0,0.4);
  display: none; align-items: flex-end;
  justify-content: center;
}
.edit-backdrop.show { display: flex; }

.edit-sheet {
  background: var(--bg-phone);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 20px 22px 22px;
  max-height: 85vh;
  overflow-y: auto;
  animation: sheet-up 0.2s ease-out;
}
@media (min-width: 481px) {
  .edit-sheet { max-width: 480px; }
}

.sheet-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 0 0 12px; text-align: center; }
.sheet-amount {
  font-size: 32px; font-weight: 500; color: var(--text);
  margin: 4px 0; letter-spacing: -1px; text-align: center;
}
.sheet-item {
  font-size: 14px; color: var(--text-2);
  margin: 0 0 16px; text-align: center;
  word-break: break-word;
}

.sheet-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border-soft);
}
.sheet-row .label { font-size: 12px; color: var(--text-3); flex: 1; }
.sheet-row .value { font-size: 13px; color: var(--text); font-weight: 500; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ----- Edit mode (form inside the same sheet) ----- */
.edit-form { margin-top: 8px; }
.edit-form .form-row { margin-bottom: 14px; }
.edit-form label {
  display: block; font-size: 11px; color: var(--text-3);
  letter-spacing: 0.5px; margin: 0 0 6px;
}
.edit-form input.app-input { font-size: 14px; padding: 12px 14px; border-radius: 12px; }
.edit-form .cat-pick-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.edit-form .cat-pick-row .name { font-size: 14px; color: var(--text); font-weight: 500; }
.edit-form .cat-pick-row .parent { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.edit-form .cat-pick-row i.chev { color: var(--text-3); font-size: 18px; }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container {
  position: fixed; bottom: 88px; left: 0; right: 0;
  padding: 0 22px;
  pointer-events: none;
  z-index: 200;
  display: flex; justify-content: center;
}
@media (min-width: 481px) {
  #toast-container { bottom: 100px; }
}
.toast {
  max-width: 380px; width: 100%;
  padding: 14px 16px;
  background: var(--secondary); color: #FFFFFF;
  border-radius: 14px; font-size: 13px;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in 0.2s ease-out;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.toast.error { background: var(--danger); }
.toast i { font-size: 16px; }

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

/* ============================================================
   ERROR MESSAGE (login)
   ============================================================ */
.error-msg {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 12px;
  font-size: 13px;
  text-align: left;
  max-width: 360px;
  width: 100%;
}

/* ============================================================
   CATEGORIES MANAGEMENT — full-screen overlay
   ============================================================ */
.screen-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-phone);
  z-index: 50;
  display: none;
  flex-direction: column;
  transition: background 0.2s;
}
.screen-overlay.show { display: flex; }

#cat-screen-area { padding: 6px 22px 22px; }

button.add-parent-btn {
  width: 100%; padding: 13px 16px;
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: 14px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 6px 0 18px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
button.add-parent-btn i { font-size: 16px; }
button.add-parent-btn:hover { background: var(--accent); color: #FFFFFF; }

.cat-group { margin-bottom: 12px; }

.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.cat-row:hover { background: var(--card-soft); }

.cat-row.cat-parent .cat-name { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.cat-row.cat-sub { padding-left: 28px; }
.cat-row.cat-sub .cat-name { font-size: 13px; font-weight: 500; color: var(--text-2); margin: 0; }
.cat-row .cat-icon-wrap {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cat-row.cat-sub .cat-icon-wrap { width: 32px; height: 32px; }
.cat-row .cat-icon-wrap i { font-size: 18px; }
.cat-row.cat-sub .cat-icon-wrap i { font-size: 14px; }
.cat-row .cat-text { flex: 1; min-width: 0; }
.cat-row .cat-meta { font-size: 11px; color: var(--text-3); margin: 2px 0 0; }
.cat-row .cat-chevron { color: var(--text-3); font-size: 16px; opacity: 0.5; flex-shrink: 0; }

button.add-sub-link {
  background: none; border: none;
  color: var(--text-3);
  font-size: 12px; font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  margin-left: 28px;
  display: flex; align-items: center; gap: 4px;
  font-family: inherit;
  transition: color 0.15s;
}
button.add-sub-link:hover { color: var(--accent); }
button.add-sub-link i { font-size: 14px; }

/* ----- Category edit + delete sheets ----- */
.cat-edit-backdrop, .cat-delete-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 60;
}
.cat-delete-backdrop { z-index: 70; }
.cat-edit-backdrop.show, .cat-delete-backdrop.show { display: flex; }

.cat-edit-sheet {
  background: var(--bg-phone); width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 18px 22px 22px;
  max-height: 90%; overflow-y: auto;
  animation: sheet-up 0.25s ease-out;
}
@media (min-width: 481px) {
  .cat-edit-sheet { max-width: 480px; }
}

.cat-edit-sheet .field { margin-bottom: 14px; }
.field-label {
  display: block; font-size: 11px; color: var(--text-3);
  letter-spacing: 0.5px; margin: 0 0 6px;
}

.icon-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 6px; margin-top: 6px;
}
.icon-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
  color: var(--text-2);
  transition: all 0.1s;
}
.icon-cell:hover { background: var(--card-soft); }
.icon-cell.selected {
  background: var(--accent); border-color: var(--accent); color: #FFFFFF;
}
.icon-cell i { font-size: 18px; }

.confirm-cat-name {
  font-size: 18px; font-weight: 600; color: var(--text);
  text-align: center; margin: 6px 0 12px;
}
.confirm-warning {
  font-size: 13px;
  margin: 0 0 8px; line-height: 1.5;
  padding: 14px 16px;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 12px;
  text-align: center;
}
.confirm-warning i { font-size: 16px; vertical-align: -3px; margin-right: 4px; }
