:root{
  --se-bs-bg: #fffdf8;
  --se-bs-surface: #ffffff;
  --se-bs-line: #d9d2c3;
  --se-bs-line-soft: #ece7dc;
  --se-bs-text: #3d352b;
  --se-bs-muted: #786d60;
  --se-bs-accent: #b7791f;
  --se-bs-accent-soft: #f4ead7;
  --se-bs-assets: #edf7e8;
  --se-bs-liabilities: #fff1f0;
  --se-bs-net: #e6f5de;
  --se-bs-shadow: 0 10px 24px rgba(61,53,43,.08);
  --se-bs-shadow-soft: 0 6px 14px rgba(61,53,43,.06);
  --se-bs-radius: 18px;
}

.se-balance-sheet{
  background: var(--se-bs-bg);
  border: 1px solid var(--se-bs-line-soft);
  border-radius: 22px;
  padding: 20px;
  color: var(--se-bs-text);
  box-shadow: var(--se-bs-shadow);
  position: relative;
}

/* config json */
.se-bs__config{
  display: none !important;
}

/* toolbar */
.se-bs__toolbar{
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.se-bs__toolbar-left,
.se-bs__toolbar-right{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.se-bs__unit-switch{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--se-bs-line);
  border-radius: 999px;
  padding: 4px;
}

.se-bs__unit-btn,
.se-bs__action-btn,
.se-bs__add-btn,
.se-bs__modal-close{
  appearance: none;
  border: 1px solid var(--se-bs-line);
  background: #fff;
  color: var(--se-bs-text);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
  transition: .2s ease;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__unit-btn:hover,
.se-bs__action-btn:hover,
.se-bs__add-btn:hover,
.se-bs__modal-close:hover{
  border-color: var(--se-bs-accent);
}

.se-bs__unit-btn.is-active{
  background: var(--se-bs-accent);
  color: #fff;
  border-color: var(--se-bs-accent);
}

.se-bs__action-btn.is-danger{
  color: #9f2f23;
}

/* sheet */
.se-bs__sheet{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.se-bs__panel{
  background: var(--se-bs-surface);
  border: 1px solid var(--se-bs-line-soft);
  border-radius: var(--se-bs-radius);
  overflow: hidden;
}

.se-bs__panel--assets{
  background: linear-gradient(to bottom, var(--se-bs-assets), #fff);
}

.se-bs__panel--liabilities{
  background: linear-gradient(to bottom, var(--se-bs-liabilities), #fff);
}

.se-bs__panel-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--se-bs-line-soft);
}

.se-bs__panel-title{
  margin: 0;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.se-bs__panel-total{
  color: var(--se-bs-muted);
  font-size: .95rem;
  white-space: nowrap;
}

.se-bs__panel-total strong{
  color: #b13217;
  font-size: 1.15rem;
  margin: 0 4px;
}

.se-bs__rows{
  padding: 10px 12px 2px;
}

.se-bs__row{
  background: rgba(255,255,255,.82);
  border: 1px solid var(--se-bs-line-soft);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  transition: box-shadow .2s ease, opacity .2s ease;
}

.se-bs__row.is-dragging{
  opacity: .55;
}

/* default/mobile-safe layout */
.se-bs__row-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: start;
}

.se-bs__field{
  min-width: 0;
}

.se-bs__field-label{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--se-bs-muted);
  margin-bottom: 5px;
  min-height: 24px;
  line-height: 1.4;
}

.se-bs__field-label--actions{
  visibility: hidden;
  margin-bottom: 5px;
  min-height: 24px;
  padding: 0;
}

.se-bs__select-btn,
.se-bs__text,
.se-bs__amount{
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--se-bs-line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  font: inherit;
  color: var(--se-bs-text);
  box-sizing: border-box;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__select-btn{
  text-align: left;
  cursor: pointer;
}

.se-bs__text{
  background: #fffdfa;
}

.se-bs__amount{
  text-align: right;
}

.se-bs__field--actions{
  min-width: 0;
}

/* action buttons */
.se-bs__row-actions{
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 44px;
}

.se-bs__drag-btn{
  appearance: none;
  border: 1px solid var(--se-bs-line);
  background: #fff;
  color: var(--se-bs-muted);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: grab;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__drag-btn:hover{
  border-color: var(--se-bs-accent);
  color: var(--se-bs-accent);
}

.se-bs__drag-btn:active{
  cursor: grabbing;
}

.se-bs__row-remove{
  appearance: none;
  border: 1px solid #e2c8c4;
  background: #fff;
  color: #a43b31;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__row-remove:hover{
  border-color: #c85f54;
  color: #8e2a20;
}

/* panel footer */
.se-bs__panel-foot{
  padding: 0 12px 14px;
}

.se-bs__add-btn{
  width: 100%;
  border-style: dashed;
  background: #fffdfa;
}

/* net worth */
.se-bs__networth{
  margin-top: 16px;
  background: var(--se-bs-net);
  border: 1px solid #b6d9aa;
  border-radius: 18px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.se-bs__networth-label{
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.se-bs__networth-value strong{
  font-size: 1.8rem;
  color: #0d7a18;
  margin-right: 4px;
}

/* help */
.se-bs__help-btn{
  appearance: none;
  border: 1px solid var(--se-bs-line);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  color: var(--se-bs-accent);
  font-size: .85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__tooltip{
  position: absolute;
  z-index: 30;
  max-width: 280px;
  background: #fff;
  color: var(--se-bs-text);
  border: 1px solid var(--se-bs-line);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--se-bs-shadow);
  font-size: .9rem;
  line-height: 1.6;
}

/* modal */
.se-bs__modal[hidden],
.se-bs__tooltip[hidden]{
  display: none !important;
}

.se-bs__modal{
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.se-bs__modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(30,25,20,.45);
}

.se-bs__modal-dialog{
  position: relative;
  z-index: 2;
  width: min(720px, calc(100vw - 24px));
  max-height: min(80vh, 720px);
  overflow: auto;
  margin: 6vh auto 0;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}

.se-bs__modal-head{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--se-bs-line-soft);
}

.se-bs__modal-head h4{
  margin: 0;
}

.se-bs__modal-body{
  padding: 16px 18px 20px;
}

.se-bs__category-list{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}

.se-bs__category-item{
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--se-bs-line);
  background: #fffdfa;
  color: var(--se-bs-text);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  box-shadow: var(--se-bs-shadow-soft);
}

.se-bs__category-item:hover{
  border-color: var(--se-bs-accent);
  background: var(--se-bs-accent-soft);
}

/* print-only block */
.se-bs__print-only{
  display: none;
}

.se-bs__print-head{
  display: none;
  margin-bottom: 12px;
}

.se-bs__print-title{
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.se-bs__print-meta{
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: #555;
}

/* -------------------------
   PC / Tablet
   outer is 2 columns
   row is 2-tier layout
   top: category / amount / actions
   bottom: sub full width
   ------------------------- */
@media (min-width: 861px){
  .se-bs__row-grid{
    grid-template-columns: minmax(130px, 1fr) minmax(120px, 150px) 96px;
    grid-template-areas:
      "category amount actions"
      "sub      sub    sub";
    gap: 10px 10px;
    align-items: end;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(1){
    grid-area: category;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(2){
    grid-area: sub;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(3){
    grid-area: amount;
  }

  .se-bs__row-grid > .se-bs__field--actions{
    grid-area: actions;
    justify-self: end;
    width: 96px;
  }

  .se-bs__row-actions{
    justify-content: flex-end;
  }
}

/* -------------------------
   Small devices
   keep vertical stack
   ------------------------- */
@media (max-width: 860px){
  .se-bs__sheet{
    grid-template-columns: 1fr;
  }

  .se-bs__row-grid{
    grid-template-columns: 1fr;
  }

  .se-bs__field-label--actions{
    display: none;
  }

  .se-bs__row-actions{
    justify-content: flex-start;
  }

  .se-bs__networth{
    flex-direction: column;
    align-items: flex-start;
  }

  .se-bs__category-list{
    grid-template-columns: 1fr;
  }
}

/* -------------------------
   Print
   fixed 2 columns
   compact row
   show print title/meta
   hide actions/help/modal
   ------------------------- */
@media print{
  @page{
    size: A4 portrait;
    margin: 10mm;
  }

  body *{
    visibility: hidden !important;
  }

  .se-balance-sheet,
  .se-balance-sheet *{
    visibility: visible !important;
  }

  .se-balance-sheet{
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
    border: none;
    background: #fff;
    padding: 0;
  }

  .se-bs__toolbar,
  .se-bs__add-btn,
  .se-bs__help-btn,
  .se-bs__modal,
  .se-bs__tooltip,
  .se-bs__field--actions,
  .se-bs__drag-btn,
  .se-bs__row-remove{
    display: none !important;
  }

  .se-bs__print-head{
    display: block !important;
    margin-bottom: 6mm;
  }

  .se-bs__sheet{
    grid-template-columns: 1fr 1fr !important;
    gap: 8mm;
    align-items: start;
  }

  .se-bs__panel{
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #bbb;
    background: #fff !important;
  }

  .se-bs__panel-head{
    padding: 8px 10px;
  }

  .se-bs__rows{
    padding: 6px 8px 0;
  }

  .se-bs__row{
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 8px;
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
  }

  .se-bs__row-grid{
    grid-template-columns: 1fr 90px;
    grid-template-areas:
      "category amount"
      "sub      sub";
    gap: 6px;
    align-items: end;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(1){
    grid-area: category;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(2){
    grid-area: sub;
  }

  .se-bs__row-grid > .se-bs__field:nth-child(3){
    grid-area: amount;
  }

  .se-bs__select-btn,
  .se-bs__text,
  .se-bs__amount{
    min-height: 30px;
    padding: 5px 7px;
    font-size: 11px;
    border-radius: 6px;
    border-color: #ccc;
    box-shadow: none;
  }

  .se-bs__field-label{
    font-size: 9px;
    margin-bottom: 2px;
    min-height: auto;
  }

  .se-bs__panel-title,
  .se-bs__networth-label{
    font-size: 14px;
  }

  .se-bs__panel-total,
  .se-bs__networth-value{
    font-size: 12px;
  }

  .se-bs__networth{
    margin-top: 6mm;
    padding: 8px 10px;
    border: 1px solid #999;
    background: #fff !important;
  }

  .se-bs__networth-value strong{
    font-size: 20px;
    color: #000;
  }
}