/* ====== Dashboard ====== */
.payment_tracker_dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  animation: fadeUp .4s var(--ease) backwards;
  cursor: default;
}
.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.dash-card:nth-child(1) { animation-delay: .05s; }
.dash-card:nth-child(2) { animation-delay: .12s; }
.dash-card:nth-child(3) { animation-delay: .19s; }
.dash-card:nth-child(4) { animation-delay: .26s; }

.dash-card.urgent { border-color: rgba(192,57,43,.2); }
.dash-card.warn   { border-color: rgba(180,83,9,.2); }

.dash-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--text-muted);
  transform: scaleX(0);
  transform-origin: left;
  animation: stretchIn .6s .4s var(--ease) forwards;
}
.dash-card.urgent::before { background: var(--red); }
.dash-card.warn::before   { background: var(--amber); }
.dash-card.ok::before     { background: var(--green); }
.dash-card.info::before   { background: var(--blue); }

/* Pulsing red dot on the urgent card if any items are due */
.dash-card.urgent.has-items::after {
  content: '';
  position: absolute;
  top: 14px; right: 14px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  animation: pulse 1.6s infinite;
}

.dash-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 8px;
}

.dash-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.dash-card.urgent .dash-value { color: var(--red); }
.dash-card.warn   .dash-value { color: var(--amber); }
.dash-card.ok     .dash-value { color: var(--green); }
.dash-card.info   .dash-value { color: var(--blue); }

.dash-amount { font-size: 13px; color: var(--text-2); font-weight: 600; margin-top: 6px; }
.dash-count-hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ====== Totals row ====== */
.totals-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.total-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
  animation: fadeUp .4s .3s var(--ease) backwards;
}
.total-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.totals-row > .total-card:nth-child(2) { animation-delay: .35s; }
.totals-row > .total-card:nth-child(3) { animation-delay: .4s; }

.total-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.total-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
.total-icon.green  { background: var(--green-bg);  color: var(--green); }
.total-icon.blue   { background: var(--blue-bg);   color: var(--blue); }
.total-icon.purple { background: var(--purple-bg); color: var(--purple); }

.total-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; }
.total-value { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.total-hint  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ====== Toolbar ====== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  animation: fadeUp .4s .45s var(--ease) backwards;
}

.search-input {
  flex: 1;
  min-width: 200px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input svg {
  position: absolute;
  left: 12px;
  width: 15px; height: 15px;
  stroke: var(--text-3); fill: none; stroke-width: 2;
}
.search-input input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  transition: all .2s var(--ease);
}
.search-input input:focus {
  border-color: var(--green);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(14,122,78,.08);
}

.filter-pills {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  position: relative;
}
.filter-pill {
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  transition: all .2s var(--ease);
  position: relative;
  white-space: nowrap;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: var(--panel);
  color: var(--green);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.filter-pill .count {
  margin-left: 5px;
  font-size: 10px;
  opacity: .7;
}

.toolbar-right { margin-left: auto; font-size: 12px; color: var(--text-3); }

/* ====== Buttons ====== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14,122,78,.25);
}
.btn-primary:hover { background: #0c6842; box-shadow: 0 4px 12px rgba(14,122,78,.35); }
.btn-ghost { background: var(--panel); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); border-color: #d4dae3; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a5321f; }

/* ====== Table ====== */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fadeUp .4s .55s var(--ease) backwards;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  background: var(--panel-alt);
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.num { text-align: right; }

tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  vertical-align: middle;
  transition: background .15s var(--ease);
}
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }

tbody tr {
  animation: rowIn .35s var(--ease) backwards;
  transition: background .15s var(--ease);
}
tbody tr:nth-child(1) { animation-delay: .55s; }
tbody tr:nth-child(2) { animation-delay: .58s; }
tbody tr:nth-child(3) { animation-delay: .61s; }
tbody tr:nth-child(4) { animation-delay: .64s; }
tbody tr:nth-child(5) { animation-delay: .67s; }
tbody tr:nth-child(6) { animation-delay: .70s; }
tbody tr:nth-child(7) { animation-delay: .73s; }
tbody tr:nth-child(8) { animation-delay: .76s; }
tbody tr:nth-child(n+9) { animation-delay: .8s; }

tbody tr.row-urgent { background: var(--red-bg); }
tbody tr.row-urgent:hover { background: #fce4e0; }
tbody tr.row-warn { background: linear-gradient(90deg, var(--amber-bg) 0%, var(--panel) 60%); }
tbody tr:hover:not(.row-urgent) { background: var(--panel-alt); }

/* Mark-paid flash animation (added briefly via class) */
tbody tr.flash-paid {
  animation: paidFlash .8s var(--ease);
}

.vendor-name { font-weight: 600; }
.desc-cell { max-width: 320px; font-size: 12px; color: var(--text-2); white-space: normal; line-height: 1.4; }

.due-cell { min-width: 140px; }
.due-date-main { font-size: 13px; font-weight: 700; }
.due-countdown { font-size: 11px; font-weight: 600; margin-top: 2px; }
.due-countdown.urgent { color: var(--red); }
.due-countdown.warn   { color: var(--amber); }
.due-countdown.ok     { color: var(--text-3); }

.amount-cell { font-weight: 700; font-size: 14px; }
.amount-frequency {
  font-size: 10px;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 1px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform .15s var(--ease);
}
.pill:hover { transform: scale(1.05); }
.pill-green  { background: var(--green-bg);  color: var(--green); }
.pill-blue   { background: var(--blue-bg);   color: var(--blue); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-amber  { background: var(--amber-bg);  color: var(--amber); }
.pill-red    { background: var(--red-bg);    color: var(--red); }
.pill-gray   { background: #eef1f5;          color: var(--text-2); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  font-family: inherit;
  text-decoration: none;
  transition: all .15s var(--ease);
}
.icon-btn:hover { background: var(--bg); color: var(--text); transform: translateY(-1px); }
.icon-btn.danger:hover { background: var(--red-bg); color: var(--red); }
.icon-btn.success:hover { background: var(--green-bg); color: var(--green); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

.link-cell a {
  color: var(--blue);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: opacity .15s var(--ease);
}
.link-cell a:hover { text-decoration: underline; }
.link-cell .no-link { color: var(--text-muted); font-size: 11px; }

/* ====== Mobile cards ====== */
.mobile-cards { display: none; }
.mobile-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  animation: rowIn .35s var(--ease) backwards;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.mobile-card:active { transform: scale(.98); }
.mobile-card.row-urgent { border-color: var(--red); background: var(--red-bg); }
.mobile-card.row-warn { border-left: 3px solid var(--amber); }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.mc-desc { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.mc-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.mc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.mc-actions { display: flex; gap: 6px; }

/* ====== Empty state ====== */
.empty {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-3);
  animation: fadeUp .4s var(--ease);
}
.empty-icon { font-size: 36px; margin-bottom: 8px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.empty-desc { font-size: 12px; }

/* ====== Modal ====== */
/*.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.modal-overlay.show { display: flex; opacity: 1; }
*/
/*.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,23,42,.25);
  transform: translateY(40px) scale(.96);
  opacity: 0;
  transition: all .3s var(--ease-bounce);
}*/
.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 17px; font-weight: 800; }

.modal-body { padding: 20px 24px; }*/

.form-row { margin-bottom: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  font-weight: 700;
  margin-bottom: 6px;
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  outline: none;
  color: var(--text);
  transition: all .2s var(--ease);
}
.form-input:focus, .form-select:focus {
  border-color: var(--green);
  background: var(--panel);
  box-shadow: 0 0 0 3px rgba(14,122,78,.08);
}
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 5px; }

.modal-footer {
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--panel-alt);
  border-radius: 0 0 14px 14px;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(15,23,42,.25);
  opacity: 0;
  transition: all .3s var(--ease-bounce);
  z-index: 2000;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ====== Loading skeleton ====== */
.loading-bar {
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ====== KEYFRAMES ====== */
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
@keyframes logoPop {
  0%   { transform: scale(0)   rotate(-180deg); opacity: 0; }
  60%  { transform: scale(1.1) rotate(10deg); }
  100% { transform: scale(1)   rotate(0deg);  opacity: 1; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes stretchIn {
  to { transform: scaleX(1); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 0 rgba(192,57,43,.4); }
  50%      { transform: scale(1.2); box-shadow: 0 0 0 8px rgba(192,57,43,0); }
}
@keyframes paidFlash {
  0%   { background: var(--green); color: #fff !important; }
  100% { background: transparent; }
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* AngularJS ng-repeat enter/leave animations */
.row-anim.ng-enter,
.row-anim.ng-leave {
  transition: all .3s var(--ease);
}
.row-anim.ng-enter      { opacity: 0; transform: translateX(-20px); }
.row-anim.ng-enter-active { opacity: 1; transform: translateX(0); }
.row-anim.ng-leave      { opacity: 1; transform: translateX(0); }
.row-anim.ng-leave-active { opacity: 0; transform: translateX(20px); }

/* ====== Responsive ====== */
@media (max-width: 980px) {
  .payment_tracker_dashboard { grid-template-columns: repeat(2, 1fr); }
  .totals-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-header { padding: 14px 16px; }
  .container { padding: 16px 14px 100px; }
  .app-title { font-size: 16px; }
  .app-sub { display: none; }
  .payment_tracker_dashboard { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .dash-card { padding: 14px; }
  .dash-value { font-size: 22px; }
  .table-wrap { display: none; }
  .mobile-cards { display: block; }
  .toolbar { padding: 10px 12px; }
  .filter-pills { width: 100%; overflow-x: auto; }
  .filter-pill { flex-shrink: 0; }
  .toolbar-right { display: none; }
  .form-row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .payment_tracker_dashboard { grid-template-columns: 1fr; }
  .header-actions .btn span { display: none; }
  .header-actions .btn { padding: 8px 12px; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
