:root{
  --bg: #f6f3ef;
  --panel: rgba(255,255,255,0.72);
  --panel-2: rgba(255,255,255,0.85);
  --stroke: rgba(25, 31, 51, 0.10);
  --text: #1e2333;
  --muted: rgba(30,35,51,0.65);

  --blue: #cfe3ff;
  --green: #d7f2e2;
  --amber: #fff1c9;
  --rose: #ffd6dc;

  --shadow: 0 10px 22px rgba(23, 28, 44, 0.10);
  --shadow-soft: 0 6px 14px rgba(23, 28, 44, 0.08);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 420px at 50% -120px, rgba(255,255,255,0.86), rgba(255,255,255,0)),
    linear-gradient(180deg, rgba(246,243,239,0.72), rgba(246,243,239,0.92)),
    url("./Bg.png");
  background-size: auto, auto, cover;
  background-position: center, center, center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  background-attachment: scroll, scroll, fixed;
  color: var(--text);
}

a{ color: inherit; text-decoration: none; }
button, input { font: inherit; }

.app{
  min-height: 100%;
  padding: 34px 18px 40px;
  display: grid;
  place-items: center;
}

.dashboard{
  width: min(1120px, 100%);
}

.topbar{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}

.tabs{
  display:flex;
  gap: 10px;
  padding: 6px;
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--stroke);
  border-radius: 999px;
}

.tab{
  display:flex;
  align-items:center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  color: rgba(30,35,51,0.72);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.tab:hover{ background: rgba(255,255,255,0.7); }
.tab.active{
  color: var(--text);
  background: rgba(213, 233, 255, 0.75);
  border: 1px solid rgba(69, 146, 255, 0.25);
}
.tab-ico{ font-size: 14px; opacity: 0.8; }

.user-chip{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.60);
  border-radius: 999px;
}

.avatar{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display:grid;
  place-items:center;
  font-weight: 800;
  color: rgba(30,35,51,0.85);
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.65));
  border: 1px solid var(--stroke);
}
.user-greet{
  font-weight: 600;
  color: rgba(30,35,51,0.85);
  white-space: nowrap;
}

.content{
  padding-top: 18px;
}

.stats{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card{
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  padding: 18px 18px 16px;
  background: var(--panel-2);
  box-shadow: var(--shadow);
  position: relative;
  overflow:hidden;
}
.stat-card:before{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(520px 220px at 30% 20%, rgba(255,255,255,0.9), rgba(255,255,255,0));
  opacity: 0.75;
  pointer-events:none;
}

.tint-blue{ background: linear-gradient(180deg, rgba(207,227,255,0.8), rgba(255,255,255,0.78)); }
.tint-green{ background: linear-gradient(180deg, rgba(215,242,226,0.84), rgba(255,255,255,0.78)); }
.tint-amber{ background: linear-gradient(180deg, rgba(255,241,201,0.88), rgba(255,255,255,0.78)); }
.tint-rose{ background: linear-gradient(180deg, rgba(255,214,220,0.9), rgba(255,255,255,0.78)); }

.stat-title{
  font-weight: 700;
  color: rgba(30,35,51,0.75);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
  text-align:center;
}
.stat-pill{
  margin: 0 auto;
  width: fit-content;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(25, 31, 51, 0.10);
  box-shadow: 0 10px 18px rgba(23, 28, 44, 0.08);
  font-weight: 800;
  position: relative;
  z-index: 1;
}
.with-dot{ padding-right: 34px; }
.dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ff3b30;
  position:absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.panel{
  border: 1px solid var(--stroke);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
  overflow:hidden;
}

.panel-head{
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(25, 31, 51, 0.08);
}
.panel-title{
  font-weight: 800;
  color: rgba(30,35,51,0.82);
  display:flex;
  align-items:center;
  gap: 10px;
}
.panel-body{ padding: 14px 16px; }
.panel-ico{ opacity: 0.85; }

/* Mobile-friendly: allow wide tables to scroll */
.panel-body{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table{
  min-width: 640px;
}
.table:not(.wide){
  min-width: 520px;
}
.table.wide.clients{ min-width: 920px; }
.table.wide.payments{ min-width: 980px; }

.reminder{
  margin-top: 14px;
}
.reminder-body{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(255,255,255,0.6);
}
.reminder-text{
  color: rgba(30,35,51,0.72);
}

.grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.table{
  display:grid;
  gap: 10px;
}
.row{
  display:grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.8fr;
  gap: 10px;
  align-items:center;
  padding: 12px 12px;
  border: 1px solid rgba(25,31,51,0.08);
  background: rgba(255,255,255,0.65);
  border-radius: 14px;
}
.row.header{
  background: transparent;
  border: none;
  padding: 0 4px 6px;
  color: rgba(30,35,51,0.55);
  font-weight: 700;
}
.cell-strong{ font-weight: 800; color: rgba(30,35,51,0.85); }
.money{ font-weight: 800; }

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid rgba(25,31,51,0.10);
}
.badge.pending{
  background: rgba(255, 216, 122, 0.55);
  color: rgba(88, 55, 0, 0.85);
}
.badge.overdue{
  background: rgba(255, 96, 96, 0.55);
  color: rgba(90, 0, 0, 0.88);
}
.badge.paid{
  background: rgba(46, 204, 113, 0.22);
  color: rgba(0, 80, 35, 0.92);
}

.btn{
  border: 1px solid rgba(25,31,51,0.14);
  background: rgba(255,255,255,0.7);
  color: rgba(30,35,51,0.85);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 800;
  cursor:pointer;
  box-shadow: 0 8px 16px rgba(23,28,44,0.08);
}
.btn:hover{ filter: brightness(0.985); transform: translateY(-1px); }
.btn:active{ transform: translateY(0px); }
.btn.primary{
  background: linear-gradient(180deg, rgba(107, 166, 255, 0.95), rgba(58, 122, 255, 0.95));
  color: white;
  border-color: rgba(58, 122, 255, 0.65);
  box-shadow: 0 10px 18px rgba(58,122,255,0.20);
}
.btn.ghost{
  background: rgba(255,255,255,0.55);
}
.btn.small{
  padding: 10px 14px;
  border-radius: 12px;
}
.btn.chip{
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: none;
}

.icon-btn{
  width: 36px;
  height: 36px;
  display:grid;
  place-items:center;
  border-radius: 12px;
  border: 1px solid rgba(25,31,51,0.12);
  background: rgba(255,255,255,0.65);
  cursor:pointer;
  color: rgba(30,35,51,0.78);
}
.icon-btn:hover{ background: rgba(255,255,255,0.8); }

.footer{
  margin-top: 16px;
  padding: 6px 2px;
}
.muted{ color: var(--muted); }

/* Auth */
.auth{
  width: min(520px, 100%);
}
.auth-card{
  padding: 22px 22px 18px;
  border: 1px solid var(--stroke);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.auth-header h1{
  margin: 14px 0 6px;
  letter-spacing: -0.03em;
}
.auth-header .muted{ margin:0; }
.brand{
  display:flex;
  align-items:center;
  gap: 12px;
}
.brand-mark{
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display:grid;
  place-items:center;
  font-weight: 900;
  background: linear-gradient(180deg, rgba(107, 166, 255, 0.95), rgba(58, 122, 255, 0.95));
  color: white;
  box-shadow: 0 10px 18px rgba(58,122,255,0.22);
}
.brand-title{ font-weight: 900; letter-spacing: -0.03em; }
.brand-subtitle{ color: var(--muted); font-weight: 700; margin-top: 2px; font-size: 12px; }

.auth-form{
  margin-top: 18px;
  display:grid;
  gap: 14px;
}
.field{
  display:grid;
  gap: 8px;
}
.field-label{
  font-weight: 800;
  color: rgba(30,35,51,0.75);
}
input{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(25,31,51,0.14);
  background: rgba(255,255,255,0.75);
  outline: none;
}
select{
  width: 100%;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(25,31,51,0.14);
  background: rgba(255,255,255,0.75);
  outline: none;
}
input:focus{
  border-color: rgba(58, 122, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(58, 122, 255, 0.12);
}
select:focus{
  border-color: rgba(58, 122, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(58, 122, 255, 0.12);
}
.password-wrap{
  display:flex;
  gap: 10px;
  align-items:center;
}
.password-wrap input{ flex: 1; }

.auth-actions{
  display:flex;
  gap: 10px;
  margin-top: 4px;
}
.hint{
  color: var(--muted);
  font-weight: 700;
}
.code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 2px 8px;
  border: 1px solid rgba(25,31,51,0.12);
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  color: rgba(30,35,51,0.82);
}
.alert{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 59, 48, 0.30);
  background: rgba(255, 59, 48, 0.10);
  color: rgba(120, 0, 0, 0.88);
  font-weight: 800;
}

.success{
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(46, 204, 113, 0.28);
  background: rgba(46, 204, 113, 0.10);
  color: rgba(0, 80, 35, 0.88);
  font-weight: 800;
}

textarea{
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(25,31,51,0.14);
  background: rgba(255,255,255,0.75);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}
/* smaller textarea for forms */
#invoiceRemarksInput{
  min-height: 110px;
}
textarea:focus{
  border-color: rgba(58, 122, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(58, 122, 255, 0.12);
}

/* Modal */
.modal{
  width: min(820px, calc(100% - 24px));
  border: none;
  padding: 0;
  background: transparent;
}
.modal::backdrop{
  background: rgba(18, 20, 28, 0.42);
  backdrop-filter: blur(6px);
}
.modal-card{
  border: 1px solid var(--stroke);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.modal-head{
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(25, 31, 51, 0.08);
}
.modal-title{
  font-weight: 900;
  letter-spacing: -0.03em;
  color: rgba(30,35,51,0.86);
}
.modal-body{
  padding: 14px 16px 10px;
  display:grid;
  gap: 12px;
}
.modal-actions{
  padding: 14px 16px 16px;
  display:flex;
  gap: 10px;
  justify-content:flex-end;
  flex-wrap: wrap;
  border-top: 1px solid rgba(25, 31, 51, 0.08);
}

.head-actions{
  display:flex;
  gap: 10px;
  align-items:center;
}

.filters{
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.field.inline{
  grid-template-columns: auto minmax(220px, 1fr);
  align-items:center;
  gap: 10px;
}
.field.inline .field-label{
  margin: 0;
}

.form-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.table.wide .row{
  grid-template-columns: 1.5fr 0.8fr 0.9fr 1.1fr 0.8fr;
}
.table.wide .row.header{
  grid-template-columns: 1.5fr 0.8fr 0.9fr 1.1fr 0.8fr;
}

/* extra-wide table for payments */
.table.wide.payments .row,
.table.wide.payments .row.header{
  grid-template-columns: 1.2fr 0.8fr 0.9fr 0.7fr 1.1fr 1.2fr 0.8fr;
}

/* clients table with more columns */
.table.wide.clients .row,
.table.wide.clients .row.header{
  grid-template-columns: 1.2fr 0.75fr 0.9fr 0.95fr 0.7fr 0.7fr 0.8fr;
}

.client-meta{
  margin-top: -2px;
}
.actions{
  display:flex;
  justify-content:flex-end;
  gap: 8px;
}
.btn.tiny{
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: none;
  font-weight: 800;
}

/* Mobile card lists */
.empty{
  padding: 12px 10px;
  color: var(--muted);
  font-weight: 700;
}
.card-list{
  display: grid;
  gap: 12px;
  min-width: 0;
}
.card-item{
  border: 1px solid rgba(25,31,51,0.10);
  background: rgba(255,255,255,0.70);
  border-radius: 16px;
  padding: 12px 12px;
  box-shadow: 0 10px 18px rgba(23, 28, 44, 0.06);
}
.card-top{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card-title{
  font-weight: 900;
  letter-spacing: -0.02em;
  color: rgba(30,35,51,0.90);
}
.card-kv{
  display:grid;
  gap: 8px;
}
.card-kv > div{
  display:flex;
  justify-content: space-between;
  gap: 12px;
}
.card-kv .k{
  color: rgba(30,35,51,0.62);
  font-weight: 800;
}
.card-kv .v{
  color: rgba(30,35,51,0.86);
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}
.card-actions{
  display:flex;
  gap: 10px;
  margin-top: 12px;
}
.card-actions .btn{
  flex: 1;
  text-align:center;
}

@media (max-width: 980px){
  .stats{ grid-template-columns: 1fr 1fr; }
  .grid-2{ grid-template-columns: 1fr; }
  .form-grid{ grid-template-columns: 1fr; }
}

@media (max-width: 540px){
  .app{
    padding: 18px 12px 28px;
  }
  .topbar{
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .tabs{
    flex-wrap: wrap;
    justify-content: center;
  }
  .tab{
    padding: 10px 12px;
  }
  .user-chip{
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .auth-actions{ flex-direction: column; }

  .stats{ grid-template-columns: 1fr; }
  .reminder-body{
    flex-direction: column;
    align-items: stretch;
  }
  .btn.chip{
    flex: 1;
    text-align: center;
  }

  .modal{
    width: calc(100% - 16px);
  }
  .modal-card{
    border-radius: 18px;
  }

  /* On mobile, prefer cards over horizontal table scrolling */
  .table{
    min-width: 0;
  }
}

