/* Happy Happy’s DebtLah App (built on the proven DFSG logic) */

:root{
  --hhdt-ink:#0f172a;
  --hhdt-muted:#475569;
  --hhdt-border:#e5e7eb;
  --hhdt-card:#ffffff;
  --hhdt-soft:#f8fafc;
  --hhdt-green:#22c55e;
  --hhdt-cyan:#06b6d4;
  --hhdt-amber:#f59e0b;
  --hhdt-pink:#ec4899;
  --hhdt-red:#b42318;
}

.dfsg-wrap { max-width: 900px; margin: 0 auto; padding: 16px; }
.dfsg-header {
  margin-bottom: 12px;
  padding: 16px 14px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  position: relative;
  overflow: hidden;
}
.dfsg-header:before{
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 6px;
  background: linear-gradient(90deg, #f97316, #22c55e, #06b6d4, #a78bfa);
}
.dfsg-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dfsg-sub { margin: 4px 0 0; color: #666; }
.dfsg-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .dfsg-grid { grid-template-columns: 1fr 1fr; } }

.dfsg-card {
  background: var(--hhdt-card);
  border: 1px solid var(--hhdt-border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(15,23,42,0.06);
  position: relative;
  overflow: hidden;
}
.dfsg-card:before{
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 5px;
  background: linear-gradient(90deg, rgba(249,115,22,0.85), rgba(34,197,94,0.85), rgba(6,182,212,0.85));
}
.dfsg-divider { height: 1px; background: #eee; margin: 12px 0; }
.dfsg-muted { color: var(--hhdt-muted); }
.dfsg-strong { font-weight: 700; }
.dfsg-note { margin-top: 8px; color: #0a7; min-height: 18px; }
.dfsg-code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; background: #f6f6f6; border: 1px solid #eee; padding: 3px 8px; border-radius: 999px; display: inline-block; margin: 4px 6px 0 0; }

.dfsg-form-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 700px) { .dfsg-form-grid { grid-template-columns: 1fr 1fr; } }

.dfsg-form-row label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.dfsg-form-row input, .dfsg-form-row select { width: 100%; padding: 10px 10px; border: 1px solid #ddd; border-radius: 10px; font-size: 14px; }

.dfsg-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.dfsg-actions-tight { justify-content: flex-start; }

.dfsg-btn {
  background: linear-gradient(135deg,var(--hhdt-green),var(--hhdt-cyan));
  color: #ffffff;
  border: none;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(6,182,212,0.18);
}
.dfsg-btn:hover { opacity: 0.92; }
.dfsg-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dfsg-btn.dfsg-btn-disabled { opacity: 0.5; cursor: not-allowed; }
.dfsg-btn-secondary {
  background: linear-gradient(135deg,#ffffff,var(--hhdt-soft));
  color: var(--hhdt-ink);
  border: 1px solid var(--hhdt-border);
  box-shadow: 0 6px 16px rgba(15,23,42,0.06);
}
.dfsg-btn-danger { background: #c0392b; color: #fff; }

.dfsg-table { width: 100%; display: grid; gap: 8px; }
.dfsg-table-head { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 8px; font-size: 12px; color: #666; }
.dfsg-table-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 8px; align-items: center; background: #fafafa; border: 1px solid #eee; border-radius: 12px; padding: 10px; }
@media (max-width: 650px) {
  .dfsg-table-head { display: none; }
  .dfsg-table-row { grid-template-columns: 1fr; }
  .dfsg-actions { justify-content: flex-start; }
}

.dfsg-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: #eee; font-size: 12px; }
.dfsg-pill-ok { background: #dff7e9; color: #0a7; border: 1px solid #bfead2; }

.dfsg-edit-panel { margin: 8px 0 14px; background: #fff; border: 1px solid #eee; border-radius: 16px; padding: 12px; }

.dfsg-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 900px) { .dfsg-summary { grid-template-columns: repeat(4, 1fr); } }
.dfsg-sum-card { background: linear-gradient(135deg,#ffffff,var(--hhdt-soft)); border: 1px solid var(--hhdt-border); border-radius: 18px; padding: 12px; }
.dfsg-sum-label { font-size: 12px; color: #666; }
.dfsg-sum-val { font-size: 16px; font-weight: 800; margin-top: 6px; }

.dfsg-dues { display: grid; gap: 10px; }
.dfsg-due-card { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: linear-gradient(135deg,#ffffff,var(--hhdt-soft)); border: 1px solid var(--hhdt-border); border-radius: 18px; padding: 12px; }
.dfsg-due-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; }

.dfsg-month-nav { display: flex; gap: 8px; }
.dfsg-check { display: inline-flex; align-items: center; cursor: pointer; position: relative; }
.dfsg-check input { position: absolute; opacity: 0; width: 1px; height: 1px; left: 0; top: 0; }
.dfsg-check-ui { width: 46px; height: 28px; border-radius: 999px; border: 1px solid #ddd; background: #fff; position: relative; transition: 0.15s; }
.dfsg-check-ui:after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: #ddd; position: absolute; top: 2px; left: 2px; transition: 0.15s; }
.dfsg-check input:checked + .dfsg-check-ui { background: #dff7e9; border-color: #bfead2; }
.dfsg-check input:checked + .dfsg-check-ui:after { left: 22px; background: #0a7; }

/* Paid/Pending button group */
.dfsg-status { display: inline-flex; gap: 8px; align-items: center; }
.dfsg-set-status.is-active { outline: 2px solid rgba(0,0,0,0.12); }

/* Active state stronger (app-like) */
.dfsg-set-status.is-active { box-shadow: 0 6px 16px rgba(0,0,0,0.10); transform: translateY(-1px); }

/* No-JS Paid/Pending forms */
.dfsg-status-form { display: inline; margin: 0; }
.dfsg-status-form button { width: auto; }
.dfsg-set-status.is-active { outline: 2px solid rgba(10,167,0,0.35); }

/* Link buttons */
.dfsg-status a.dfsg-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }


/* v1.0.6 additions */
.dfsg-status { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 650px) { .dfsg-status { justify-content: flex-start; } }

.dfsg-set-status.is-active { box-shadow: 0 0 0 2px rgba(10, 170, 119, 0.25); }
.dfsg-disabled { background: #e6e6e6 !important; color: #666 !important; border: 1px solid #d0d0d0 !important; cursor: not-allowed; }
.dfsg-link { color: inherit; text-decoration: underline; }
.dfsg-alert { background: #fff8e6; border: 1px solid #ffe3a3; }
.dfsg-alert-err { background: #ffecec; border: 1px solid #ffb7b7; color: #8a1c1c; }
.dfsg-big { font-size: 22px; font-weight: 900; margin: 8px 0 10px; }
.dfsg-kv { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dfsg-kv-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dashed #eee; padding-bottom: 6px; }


/* v1.0.9 urgency styles for Paid button */
.dfsg-btn.dfsg-paid-inactive{
  background:#fff0f0 !important;   /* lightest red */
  border:1px solid #ffd0d0 !important;
  color:#7a1515 !important;
}
.dfsg-btn.dfsg-paid-overdue{
  background:#d50000 !important;   /* RED when past due */
  border:1px solid #d50000 !important;
  color:#ffffff !important;
}
.dfsg-btn.dfsg-paid-overdue:hover{
  filter:brightness(0.95);
}



/* ===== v1.1.0 UI Enhancements (Happy Happy's DebtLah App) ===== */
.dfsg-ico { vertical-align: -4px; margin-right: 8px; fill: currentColor; opacity: .92; }
.dfsg-danger { color: #b42318; }
.dfsg-small { font-size: 12px; }

.dfsg-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f2f4f7;
  color: #101828;
  border: 1px solid #eaecf0;
}
.dfsg-chip-muted { background: #f9fafb; color: #344054; }
.dfsg-chip-ok { background: #ecfdf3; color: #027a48; border-color: #abefc6; }
.dfsg-chip-warn { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.dfsg-chip-danger { background: #fef3f2; color: #b42318; border-color: #fecdca; }

.dfsg-progress {
  width: 100%;
  height: 10px;
  background: #f2f4f7;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #eaecf0;
}
.dfsg-progress-lg { height: 14px; }
.dfsg-progress-bar {
  height: 100%;
  background: #12b76a; /* green */
  border-radius: 999px;
}

.dfsg-debt-list { display: grid; gap: 14px; }
.dfsg-debt-card {
  display: block;
  text-decoration: none;
  border: 1px solid #eaecf0;
  background: #ffffff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 10px 30px rgba(16,24,40,0.06);
  transition: transform .06s ease, box-shadow .06s ease;
  color: inherit;
}
.dfsg-debt-card:active { transform: scale(0.99); }
.dfsg-debt-top { display: flex; gap: 12px; justify-content: space-between; }
.dfsg-debt-name { font-size: 16px; font-weight: 800; line-height: 1.25; }
.dfsg-debt-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dfsg-debt-amount { text-align: right; min-width: 110px; }
.dfsg-debt-remaining { font-size: 18px; font-weight: 900; }
.dfsg-debt-small { font-size: 12px; color: #667085; }
.dfsg-debt-kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.dfsg-debt-kv-4 { grid-template-columns: repeat(4, 1fr); }
.dfsg-debt-kv span { display:block; font-size: 11px; color: #667085; }
.dfsg-debt-kv strong { display:block; font-size: 13px; color: #101828; }

.dfsg-debt-hero { padding: 16px; }
.dfsg-debt-hero-top { display:flex; justify-content: space-between; align-items: baseline; gap: 10px; }

.dfsg-tabs { display: inline-flex; gap: 8px; margin: 8px 0 12px; }
.dfsg-tab {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #eaecf0;
  background: #fff;
  text-decoration: none;
  color: #344054;
  font-weight: 700;
  font-size: 13px;
}
.dfsg-tab.is-active { background: #101828; border-color: #101828; color: #fff; }

.dfsg-pay-list { display: grid; gap: 10px; margin-top: 12px; }
.dfsg-pay-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr auto;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #eaecf0;
  background: #fff;
}
.dfsg-pay-date, .dfsg-pay-amt { min-width: 0; }
.dfsg-pay-status { display:flex; align-items:center; justify-content:flex-end; }

.dfsg-card-danger { border-color: #fecdca; background: #fffafa; }
.dfsg-overdue-total { display:flex; align-items: baseline; justify-content: space-between; gap: 10px; }

.dfsg-table.dfsg-table-compact .dfsg-table-head,
.dfsg-table.dfsg-table-compact .dfsg-table-row{
  grid-template-columns: 2.2fr 1.2fr 1fr 1fr 1.2fr;
}
.dfsg-table.dfsg-table-compact .dfsg-table-head div { font-size: 12px; }
.dfsg-table.dfsg-table-compact .dfsg-table-row { gap: 10px; }

/* Paid button state colors (requested) */
.dfsg-paid-pending{
  background: #fef3f2 !important; /* light red */
  color: #b42318 !important;
  border: 1px solid #fecdca !important;
}
.dfsg-paid-overdue{
  background: #b42318 !important; /* strong red */
  color: #ffffff !important;
  border: 1px solid #b42318 !important;
}
.dfsg-paid-active{
  background: #101828 !important; /* keep current dark */
  color: #ffffff !important;
  border: 1px solid #101828 !important;
}

/* Mobile tweaks */
@media (max-width: 520px){
  .dfsg-debt-kv{ grid-template-columns: repeat(2, 1fr); }
  .dfsg-debt-kv-4{ grid-template-columns: repeat(2, 1fr); }
  .dfsg-pay-row{ grid-template-columns: 1fr 1fr; }
  .dfsg-pay-status{ grid-column: 1 / -1; justify-content: flex-start; }
  .dfsg-debt-amount{ min-width: 90px; }
}


/* App-like shell */
.dfsg-app { position: relative; }
.dfsg-content { padding-bottom: 92px; } /* space for bottom nav */

.dfsg-bottom-nav{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--hhdt-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.dfsg-tab{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none !important;
  color: var(--hhdt-muted);
  font-weight: 700;
  font-size: 12px;
  padding: 8px 6px;
  border-radius: 14px;
  border: 1px solid transparent;
  min-height: 56px;
}
.dfsg-tab svg{ fill: currentColor; }
.dfsg-tab-ico{ line-height: 1; }
.dfsg-tab-lbl{ line-height: 1.1; }

.dfsg-tab.is-active{
  color: var(--hhdt-ink);
  background: #f1f5f9;
  border-color: #e2e8f0;
}
.dfsg-tab.is-disabled{
  opacity: 0.45;
}

/* Make header feel like an app bar on mobile */
@media (max-width: 720px){
  .dfsg-header{
    position: sticky;
    top: 8px;
    z-index: 5;
  }
  .dfsg-wrap{ padding-bottom: 88px; }
}

/* Advanced toggle */
.dfsg-adv-toggle{
  margin-top: 8px;
  background: transparent;
  border: 1px solid var(--hhdt-border);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
}
.dfsg-advanced{ display:none; }
.dfsg-advanced.is-open{ display:block; }


.dfsg-form-row-full{ grid-column: 1 / -1; }
