/* --- THEME & GLOBAL STYLES --- */
:root {
  /* Default Light Theme */
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #0ea5e9;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --border: rgba(0, 0, 0, 0.08);
  --glass: rgba(0, 0, 0, 0.03);
  --glass-2: rgba(0, 0, 0, 0.02);
  --gap: 20px;
}

[data-theme="dark"] {
  /* Dark Theme Overrides */
  --bg: #0f1724;
  --card: #0b1220;
  --text: #e6eef6;
  --muted: #9aa4b2;
  --accent: #7dd3fc;
  --danger: #fb7185;
  --warning: #facc15;
  --success: #34d399;
  --border: rgba(255, 255, 255, 0.08);
  --glass: rgba(255, 255, 255, 0.03);
  --glass-2: rgba(255, 255, 255, 0.02);
}


/* --- THE REST OF YOUR CSS REMAINS THE SAME --- */

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: 28px;
}

/* --- LAYOUT --- */
.wrap {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 800px;
  margin: 0 auto;
}

.panel {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.06);
  border: 1px solid var(--border);
}

/* --- AUDITOR & KPIs --- */
.auditor-title {
  font-size: 32px; 
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--accent);
  margin: 0 0 8px 0;
}

.muted-small {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 18px 0;
  line-height: 1.5; /* Added for better readability if it wraps */
}

.kpi-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.metric {
  background: var(--glass);
  padding: 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric .value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--text);
}

/* --- List Controls (Sort/Filter) --- */
.list-controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 12px;
}

.btn-control {
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-control:hover {
  background: var(--glass-2);
  color: var(--text);
}

.btn-control.active {
  background-color: rgba(14, 165, 233, 0.1);
  border-color: rgba(14, 165, 233, 0.3);
  color: var(--accent);
  font-weight: 600;
}

/* --- Subscription List --- */
.list {
  background: var(--glass-2);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 80px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* --- Individual Subscription Item --- */
.sub-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sub-item .meta { flex-grow: 1; display: flex; gap: 12px; align-items: center; min-width: 0; }
.sub-item .avatar {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(14, 165, 233, 0.05));
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; font-size: 14px; border: 1px solid var(--border);
}
.sub-item .info { min-width: 0; }
.sub-item .name { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub-item .sub { font-size: 12px; color: var(--muted); }
.sub-item .right { display: flex; gap: 12px; align-items: center; flex-shrink: 0; }
.sub-item .price { font-weight: 600; font-size: 14px; min-width: 85px; text-align: right; }
.sub-item .price .muted-price { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.trash { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px; opacity: 0.6; transition: all 0.2s; }
.trash:hover { opacity: 1; color: var(--danger); transform: scale(1.1); }

/* --- Badge Styles --- */
.badge {
  font-size: 10px; padding: 4px 8px; border-radius: 6px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border: 1px solid transparent;
}
.badge.cut { background-color: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge.review { background-color: rgba(245, 158, 11, 0.1); border-color: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge.keep { background-color: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); color: var(--success); }


/* --- MEMORY JOGGER --- */
.jogger h2 { margin: 0 0 4px 0; font-size: 16px; letter-spacing: 0.4px; }
.jogger p { margin: 0 0 16px 0; color: var(--muted); font-size: 13px; }
.jogger .category { margin-bottom: 16px; }
.jogger .category:last-child { margin-bottom: 0; }
.jogger .category h3 { margin: 0 0 8px 0; font-size: 14px; color: var(--text); font-weight: 600; }
.jogger .subs { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--glass); padding: 6px 10px; border-radius: 8px; color: var(--muted);
  font-size: 12px; font-family: inherit; border: 1px solid var(--border); cursor: pointer; transition: all 0.2s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.highlighted { background-color: rgba(14, 165, 233, 0.1); border-color: rgba(14, 165, 233, 0.3); color: var(--accent); font-weight: 600; }

/* --- MODAL DIALOG --- */
.modal-backdrop {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(4px); z-index: 60; padding: 20px;
}
.modal {
  width: 400px; max-width: 100%; background: var(--card); border-radius: 12px;
  padding: 24px; border: 1px solid var(--border); box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.modal h3 { margin: 0 0 8px 0; font-size: 18px; }
.modal-description {
  font-size: 13px; color: var(--muted); margin: -4px 0 16px 0;
  line-height: 1.5; border-left: 3px solid var(--border); padding-left: 12px;
}
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.modal label { font-size: 13px; font-weight: 500; color: var(--muted); }
input[type="text"], input[type="number"] {
  background: var(--glass); border: 1px solid var(--border); padding: 10px 12px; border-radius: 8px;
  color: var(--text); outline: none; font-size: 14px; width: 100%; box-sizing: border-box;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.cost-input-group {
  display: flex; align-items: center; background: var(--glass);
  border: 1px solid var(--border); border-radius: 8px; transition: all 0.2s ease;
}
.cost-input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }
.cost-input-group .currency-symbol { padding-left: 12px; color: var(--muted); font-size: 14px; }
.cost-input-group input[type="number"] { border: none; background: transparent; box-shadow: none; flex-grow: 1; }
.cost-input-group input[type="number"]:focus { box-shadow: none; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.period-toggle {
  background: rgba(14, 165, 233, 0.1);
  border: none; border-left: 1px solid var(--border); color: var(--accent);
  font-weight: 600; padding: 10px 12px; cursor: pointer; font-size: 14px;
  font-family: inherit; border-top-right-radius: 7px; border-bottom-right-radius: 7px;
  transition: all 0.2s ease;
}
.period-toggle:hover { opacity: 0.8; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* --- Button Group Styles for the Modal --- */
.button-group-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.choice-button {
  background: var(--glass); border: 1px solid var(--border); color: var(--muted);
  padding: 10px 12px; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: center; transition: all 0.2s ease; font-family: inherit;
}
.choice-button:hover { border-color: var(--text); color: var(--text); }
.choice-button.selected { color: #fff; font-weight: 600; }
.choice-button.keep.selected { background-color: var(--success); border-color: var(--success); }
.choice-button.review.selected { background-color: var(--warning); border-color: var(--warning); }
.choice-button.cut.selected { background-color: var(--danger); border-color: var(--danger); }

/* --- BUTTONS & UTILITIES --- */
.btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 16px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.1); transition: opacity 0.2s ease;
}
.btn:hover { opacity: 0.9; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); box-shadow: none; }
.btn.ghost:hover { color: var(--text); background: var(--glass); opacity: 1; }

/* --- Theme Toggle --- */
.theme-toggle {
  position: fixed; bottom: 20px; right: 20px; background: var(--card);
  border: 1px solid var(--border); border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); z-index: 100; transition: transform 0.2s ease;
}
.theme-toggle:hover { transform: scale(1.1); }
.theme-toggle #themeIcon { font-size: 24px; }

/* --- Footer Styling --- */
footer {
  text-align: center;
  margin-top: 32px;
  padding-bottom: 20px;
  font-size: 13px;
  color: var(--muted);
}
footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
footer a:hover {
  text-decoration: underline;
}
