/* FinTrack Pro — Main Stylesheet */
:root {
  --primary:    #1a237e;
  --primary-lt: #3949ab;
  --accent:     #00acc1;
  --success:    #00897b;
  --danger:     #e53935;
  --warning:    #f9a825;
  --bg:         #f0f2f8;
  --surface:    #ffffff;
  --text:       #1c2a3a;
  --text-lt:    #546e7a;
  --border:     #dde3ee;
  --sidebar-w:  240px;
  --topbar-h:   58px;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(26,35,126,0.09);
  --shadow-md:  0 4px 24px rgba(26,35,126,0.13);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ---- SIDEBAR ---- */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: linear-gradient(160deg, var(--primary) 0%, #0d1b6b 100%);
  color: #fff; display: flex; flex-direction: column;
  z-index: 100; transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 3px 0 20px rgba(0,0,0,0.2);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.brand-icon { font-size: 1.6rem; color: #80d8ff; }
.brand-text { font-size: 1.25rem; font-weight: 700; letter-spacing: .5px; }
.brand-text span { color: #80d8ff; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: rgba(255,255,255,0.78);
  text-decoration: none; font-size: .92rem;
  border-left: 3px solid transparent;
  transition: all .2s;
}
.nav-item i { width: 18px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.13);
  color: #fff; border-left-color: #80d8ff;
  font-weight: 600;
}
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: .8rem; color: rgba(255,255,255,0.5);
}

/* ---- MAIN WRAP ---- */
#main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin .3s cubic-bezier(.4,0,.2,1);
}

/* ---- TOPBAR ---- */
#topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}
#sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; color: var(--text-lt);
  display: none;
  padding: 6px;
}
#page-title { flex: 1; font-size: 1.15rem; font-weight: 700; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
#refresh-prices {
  background: var(--primary); color: #fff; border: none;
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
  transition: background .2s;
}
#refresh-prices:hover { background: var(--primary-lt); }
.small-text { font-size: .77rem; color: var(--text-lt); }

/* ---- CONTENT ---- */
#content { padding: 22px; }
.page { display: none; }
.page.active { display: block; }

/* ---- CARDS GRID ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.cards-grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; display: flex; gap: 14px;
  align-items: center; box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
  transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-primary { border-left-color: var(--primary); }
.card-success  { border-left-color: var(--success); }
.card-danger   { border-left-color: var(--danger); }
.card-warning  { border-left-color: var(--warning); }
.card-positive { border-left-color: var(--success); }
.card-negative { border-left-color: var(--danger); }
.card-icon {
  font-size: 1.6rem; opacity: .7; color: var(--primary-lt);
  min-width: 36px; text-align: center;
}
.card-label { font-size: .78rem; color: var(--text-lt); margin-bottom: 4px; }
.card-value { font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1; }
.card-sub { font-size: .78rem; color: var(--text-lt); margin-top: 4px; }

/* ---- CHART CARDS ---- */
.charts-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; margin-bottom: 20px;
}
.chart-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.chart-title { font-size: .88rem; font-weight: 600; color: var(--text-lt); margin-bottom: 14px; }
.chart-wrap { position: relative; height: 220px; }

/* ---- SECTION CARD ---- */
.section-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .95rem;
}

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
thead th {
  background: var(--bg); padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: .78rem;
  color: var(--text-lt); white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:hover { background: #f5f7ff; }
.loading { text-align: center; color: var(--text-lt); padding: 30px; }

/* Colored P&L */
.pnl-positive { color: var(--success); font-weight: 600; }
.pnl-negative { color: var(--danger); font-weight: 600; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 8px;
  border: none; cursor: pointer; font-size: .88rem;
  font-weight: 500; transition: all .2s; text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-lt); padding: 4px 6px; border-radius: 5px;
  transition: color .2s;
}
.btn-icon:hover { color: var(--primary); }
.btn-group { display: flex; gap: 8px; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 16px;
}
.filter-group { display: flex; gap: 8px; align-items: center; }

/* ---- PILLS ROW ---- */
.pills-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 30px; padding: 5px 14px; font-size: .8rem;
  cursor: pointer; transition: all .2s;
}
.pill:hover, .pill.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ---- PROGRESS BAR ---- */
.progress-bar-wrap {
  background: var(--border); border-radius: 10px;
  height: 6px; overflow: hidden; margin-top: 6px;
}
.progress-bar { height: 100%; border-radius: 10px; background: var(--success); transition: width .5s; }
.progress-bar.warn  { background: var(--warning); }
.progress-bar.over  { background: var(--danger); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .83rem; font-weight: 500; margin-bottom: 5px; color: var(--text-lt); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; color: var(--text);
  background: var(--bg); transition: border .2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none; border-color: var(--primary);
  background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: .75rem; color: var(--text-lt); margin-top: 3px; display: block; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 92%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-md);
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { transform: scale(.92) translateY(20px); opacity:0; } to { transform: scale(1) translateY(0); opacity:1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; color: var(--primary); }
.modal-close {
  background: none; border: none; font-size: 1.4rem;
  color: var(--text-lt); cursor: pointer; line-height: 1;
}
.modal > form { padding: 20px 22px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 10px; border-top: 1px solid var(--border);
  margin-top: 10px;
}

/* ---- SAVINGS GOALS ---- */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 16px; }
.goal-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
  transition: transform .2s;
}
.goal-card:hover { transform: translateY(-3px); }
.goal-card.completed { opacity: .7; border-top-color: var(--success); }
.goal-name { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.goal-amounts { font-size: .83rem; color: var(--text-lt); margin: 8px 0; }
.goal-dates { font-size: .77rem; color: var(--text-lt); margin-top: 8px; }
.goal-actions { margin-top: 14px; display: flex; gap: 8px; }

/* ---- IMPORT PAGE ---- */
.import-card {
  background: var(--surface); border-radius: var(--radius);
  max-width: 620px; padding: 28px; box-shadow: var(--shadow);
}
.import-card h2 { color: var(--primary); margin-bottom: 8px; }
.import-card p { color: var(--text-lt); font-size: .9rem; margin-bottom: 20px; }
.import-result { padding: 14px; border-radius: 8px; margin-top: 16px; }
.import-result.success { background: #e8f5e9; color: #2e7d32; }
.import-result.error   { background: #ffebee; color: #c62828; }
.import-tips { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 18px; }
.import-tips h3 { font-size: .9rem; color: var(--text-lt); margin-bottom: 8px; }
.import-tips p { font-size: .83rem; color: var(--text-lt); }

/* ---- SETTINGS ---- */
.settings-card {
  background: var(--surface); border-radius: var(--radius);
  max-width: 520px; padding: 28px; box-shadow: var(--shadow);
}
.settings-card h2 { color: var(--primary); margin-bottom: 20px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; }
.alert.success { background: #e8f5e9; color: #2e7d32; }
.alert.error   { background: #ffebee; color: #c62828; }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1c2a3a; color: #fff;
  padding: 12px 20px; border-radius: 10px;
  font-size: .88rem; max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transform: translateY(80px); opacity: 0;
  transition: all .3s cubic-bezier(.4,0,.2,1);
  z-index: 999;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-left: 0; }
  #sidebar-toggle { display: block; }
  .charts-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  #content { padding: 14px; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 12px; }
  .card-value { font-size: 1.1rem; }
  .chart-wrap { height: 180px; }
}
@media (max-width: 380px) {
  .cards-grid { grid-template-columns: 1fr; }
}
