:root{
  --bg: #07120c;
  --bg2:#0a1a12;

  --stroke: rgba(255,255,255,.10);

  --text: #e9fff3;
  --muted: rgba(233,255,243,.72);

  --shadow: 0 16px 40px rgba(0,0,0,.45);
  --radius2: 22px;

  /* Table fill (the frosted panel) */
  --tableFill: rgba(255,255,255,.055);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:
    radial-gradient(1200px 700px at 12% 0%, rgba(34,197,94,.22), transparent 62%),
    radial-gradient(900px 600px at 88% 12%, rgba(52,211,153,.18), transparent 58%),
    radial-gradient(1100px 900px at 50% 120%, rgba(16,185,129,.10), transparent 55%),
    linear-gradient(180deg, #0a1a12 0%, #07120c 60%, #07120c 100%);
  background-attachment: fixed;
  color: var(--text);
}

html.locked .shell,
html.locked #drawer,
html.locked #drawerBackdrop{
  pointer-events: none;
  user-select: none;
  filter: blur(10px) saturate(1.1);
  opacity: .55;
}

/* =========================
   LAYOUT
   ========================= */
.shell{
  width: min(92vw, 980px);
  margin: 0 auto;
  padding: 18px 0 28px;
}

.header{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px 10px;
}

h1{
  margin: 8px 0 6px;
  font-size: 24px;
  letter-spacing: .2px;
}

.sub{
  margin:0;
  color: var(--muted);
  font-size: 13px;
}

/* =========================
   BUTTONS
   ========================= */
.btn{
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
}
.btn.primary{
  background: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.28);
}
.btn.ghost{
  background: rgba(0,0,0,.18);
}

.note{
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* =========================
   TABLE CARD
   ========================= */
.card{
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin: 14px 0 0;
  width: 100%;
}

.tableWrap{
  margin: 0 auto;
  padding: 0;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: var(--tableFill);
  box-shadow: var(--shadow);
  overflow: hidden;
  width: 100%;
}

.tableWrap::before{
  content:"";
  display:block;
  height: 1px;
  background: rgba(255,255,255,.06);
}

.tableInner{
  width: 100%;
  padding: 0;
}

table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th{
  position: sticky;
  top: 0;
  background: rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
  text-align: left;

  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  user-select: none;

  font-size: 11px;
  font-weight: 700;
  letter-spacing: .15px;
  color: rgba(233,255,243,.80);

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody td{
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 13px;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr:hover{
  background: rgba(255,255,255,.035);
}

/* Column widths (desktop/tablet) */
thead th:nth-child(1),
tbody td:nth-child(1){ width: 30%; }
thead th:nth-child(2),
tbody td:nth-child(2){ width: 20%; }
thead th:nth-child(3),
tbody td:nth-child(3){ width: 22%; }
thead th:nth-child(4),
tbody td:nth-child(4){ width: 28%; }

/* Debits helper */
.debitsCell .days{
  opacity: .78;
  font-size: 11px;
  margin-left: 6px;
}

/* =========================
   MOBILE
   - header edges match table panel
   - debits never clip (wrap into 2 lines)
   ========================= */
@media (max-width: 540px){
  .shell{
    width: 100%;
    padding: 16px 0 24px;
  }

  /* header becomes a panel aligned with tableWrap */
  .header{
    width: calc(100% - 20px);
    margin: 0 auto 10px;
    padding: 12px 12px 10px;
    border-radius: 16px;
    border: 1px solid var(--stroke);
    background: var(--tableFill);
    box-shadow: var(--shadow);
  }

  h1{ font-size: 20px; }
  .sub{ font-size: 12px; }

  .tableWrap{
    width: calc(100% - 20px);
    margin-left: auto;
    margin-right: auto;
  }

  .tableInner{
    padding: 0 6px 6px; /* >=5px gutters & bottom */
  }

  thead th{
    padding: 8px 8px;
    font-size: 10.5px;
  }

  tbody td{
    padding: 8px 8px;
    font-size: 12px;
  }

  /* Debits wraps cleanly */
  .debitsCell{
    white-space: normal;
    line-height: 1.15;
  }
  .debitsCell .days{
    display: block;
    margin-left: 0;
    margin-top: 2px;
    font-size: 10.5px;
  }

  .btn{
    padding: 9px 10px;
    border-radius: 13px;
  }
}

@media (max-width: 380px){
  .header{
    width: calc(100% - 16px);
    padding: 12px 10px 10px;
  }
  .tableWrap{ width: calc(100% - 16px); }
  thead th{ font-size: 10px; }
  tbody td{ font-size: 11px; }
  .debitsCell .days{ font-size: 10px; }
}

/* =========================
   DRAWER
   ========================= */
.backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  display:none;
  z-index: 50;
}

.drawer{
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: rgba(8,18,12,.92);
  border-left: 1px solid rgba(255,255,255,.10);
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
  transform: translateX(110%);
  transition: transform .18s ease;
  z-index: 60;
}

.drawer.open{ transform: translateX(0); }
.backdrop.open{ display:block; }

.drawerHead{
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.drawerTitle{
  font-weight: 700;
  letter-spacing: .2px;
}

.drawerBody{
  padding: 16px;
  overflow:auto;
  height: calc(100% - 62px);
}

/* Inputs layout */
.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field{
  display:flex;
  flex-direction: column;
  gap: 6px;
}

.field span{
  color: var(--muted);
  font-size: 12px;
}

.field input, textarea{
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

.field small{
  color: rgba(233,255,243,.55);
  font-size: 11px;
}

.toggle{
  display:flex;
  align-items:center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

.details{
  margin-top: 14px;
  border-top: 1px dashed rgba(255,255,255,.14);
  padding-top: 12px;
}

.details summary{
  cursor:pointer;
  color: var(--text);
  font-weight: 600;
}

.hint{
  color: var(--muted);
  margin: 10px 0;
  font-size: 13px;
}

textarea{
  width: 100%;
  resize: vertical;
}

.actions{
  display:flex;
  gap: 10px;
  margin-top: 14px;
}

@media (max-width: 420px){
  .grid{ grid-template-columns: 1fr; }
}

/* =========================
   🔒 AUTH OVERLAY (CENTERED)
   ========================= */
.authOverlay{
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;      /* vertical center */
  justify-content: center;  /* horizontal center */
}

.authOverlay[hidden]{ display:none; }

.authBackdrop{
  position:absolute;
  inset:0;
  background:
    radial-gradient(1200px 700px at 12% 0%, rgba(34,197,94,.28), transparent 62%),
    radial-gradient(900px 600px at 88% 12%, rgba(52,211,153,.20), transparent 58%),
    radial-gradient(1100px 900px at 50% 120%, rgba(16,185,129,.14), transparent 55%),
    linear-gradient(180deg, rgba(10,26,18,.90) 0%, rgba(7,18,12,.92) 70%, rgba(7,18,12,.94) 100%);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.authModal{
  position: relative;
  z-index: 1;

  width: min(92vw, 420px);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(10,26,18,.92);
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  padding: 18px;
  text-align: center;
}

.authTitle{
  margin: 0 0 6px;
  font-size: 20px;
}

.authSub{
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.authInput{
  flex: 1;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.20);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

.authBtn{ white-space: nowrap; }

.authError{
  margin: 10px 0 0;
  color: rgba(255,255,255,.88);
  font-size: 12px;
  min-height: 16px;
}

/* ensure no scroll behind lock */
html.locked body{
  overflow: hidden;
}
