/* =========================================================
   Balancio – Clean FinTech UI (stable scroll, no artifacts)
   ========================================================= */

:root{
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel2: #fbfbfe;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15,23,42,.10);
  --border2: rgba(15,23,42,.07);

  --primary: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;

  --radius: 16px;
  --radius-sm: 12px;

  --shadow: 0 10px 24px rgba(15,23,42,.06);

  /* ✅ SUMMARY semantic colors (soft) */
  --income:  #4ade80;  /* soft green */
  --expense: #f87171;  /* soft red */
  --cashin:  #60a5fa;  /* soft blue */
  --cashout: #facc15;  /* soft amber */
  --vat:     #a78bfa;  /* soft violet */
}

/* prevent page horizontal scroll */
html, body{
  max-width: 100%;
  overflow-x: hidden;
}

body{
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   NAVBAR
   ========================================================= */

.navbar-blur{
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--border2);
  box-shadow: 0 6px 18px rgba(15,23,42,.04);
}

.navbar-brand{
  font-weight: 800;
  color: var(--text);
}

/* navbar buttons: nech sa text neláme */
.navbar .btn{
  white-space: nowrap;
}

/* selecty v navbare nech majú stabilnú šírku */
.navbar .form-select{
  width: auto;
  min-width: 110px; /* rok */
}

.navbar .form-select[name="m"]{
  min-width: 140px; /* mesiac */
}

/* navbar sizing – vertical centering fix */
.navbar .btn,
.navbar .form-select{
  height: 38px;
}

/* buttons: center text/icon vertically (mobile-safe) */
.navbar .btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding-top: 0;
  padding-bottom: 0;
}

/* selects: keep consistent vertical alignment */
.navbar .form-select{
  line-height: normal;
}

/* =========================================================
   NAVBAR layout: mobile 2 rows, desktop 1 row (correct order)
   ========================================================= */

.bal-navwrap{
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand actions"
    "form  form";
  align-items: center;
  gap: .5rem;
}

.bal-navwrap .navbar-brand{ grid-area: brand; }
.bal-top-actions{
  grid-area: actions;
  display:flex;
  gap:.5rem;
}
.bal-navform{
  grid-area: form;
  width: 100%;
}

.bal-navrow{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

/* icon-only buttons on mobile */
.bal-btn-icon{
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* desktop: everything in one row */
@media (min-width: 992px){
  .bal-navwrap{
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: .75rem;
  }

  .bal-navform{ width: auto; }

  .bal-navrow{
    display:flex;
    align-items:center;
    gap: .5rem;
  }
}

/* =========================================================
   CARDS
   ========================================================= */

.card-soft{
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.text-muted{ color: var(--muted) !important; }

/* =========================================================
   LINKS
   ========================================================= */

a{
  color: var(--primary);
  text-decoration: none;
}
a:hover{ text-decoration: underline; }

/* =========================================================
   FORMS – base
   ========================================================= */

.form-control,
.form-select{
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
  color: var(--text);
}

.form-control:focus,
.form-select:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 .22rem rgba(37,99,235,.12);
}

.form-control-sm{
  padding: .38rem .5rem;
}

/* =========================================================
   TABLE – SCROLL CONTAINER (stable on iOS)
   ========================================================= */

.table-responsive,
.table-responsive.balancio-scroll{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;

  background: transparent;
  border: 0;
  box-shadow: none;

  /* iOS paint stability (light) */
  transform: translateZ(0);
}

/* =========================================================
   BALANCIO TABLE – base
   ========================================================= */

.table.balancio-table{
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0 .35rem;

  width: max-content;   /* allow horizontal scroll, no squeeze */
  min-width: 980px;     /* default (income/expense/other-expense) */
}

.table.balancio-table thead th{
  font-size: .76rem;
  font-weight: 600;
  color: rgba(15,23,42,.65);
  background: transparent;
  border: 0;
  padding: .25rem .45rem;
}

.table.balancio-table tbody td{
  background: rgba(255,255,255,.75);
  border-top: 1px solid rgba(15,23,42,.06);
  border-bottom: 1px solid rgba(15,23,42,.06);
  padding: .22rem .4rem;
  vertical-align: middle;
  overflow: hidden;
}

/* rounded row */
.table.balancio-table tbody tr td:first-child{
  border-left: 1px solid rgba(15,23,42,.06);
  border-radius: 14px 0 0 14px;
}
.table.balancio-table tbody tr td:last-child{
  border-right: 1px solid rgba(15,23,42,.06);
  border-radius: 0 14px 14px 0;
}

.table.balancio-table tbody tr:hover td{
  background: rgba(59,130,246,.06);
}

/* =========================================================
   TABLE INPUTS + SELECTS (match inside table)
   ========================================================= */

.table.balancio-table .form-control-sm{
  height: 28px;
  font-size: .84rem;
  padding: .14rem .34rem;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.14);
  background: rgba(255,255,255,.70);
  box-shadow: none;
}

.table.balancio-table .form-control-sm:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 .18rem rgba(59,130,246,.10);
  background: rgba(255,255,255,.85);
}

.table.balancio-table input[readonly]{
  background: rgba(15,23,42,.04);
  color: rgba(15,23,42,.75);
}

.table.balancio-table .form-select-sm{
  height: 28px;
  padding: .14rem .34rem;
  font-size: .84rem;
  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.14);
  background: rgba(255,255,255,.70);
  box-shadow: none;
}

.table.balancio-table .form-select-sm:focus{
  border-color: rgba(59,130,246,.55);
  box-shadow: 0 0 0 .18rem rgba(59,130,246,.10);
  background: rgba(255,255,255,.85);
}

/* truncate */
.truncate{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================
   COLUMN WIDTHS – single global set (no per-table overrides)
   ========================================================= */

.col-date{ width: 80px; }
.col-date2{ width: 80px; }
.col-amt{ width: 100px; }
.col-vat{ width: 100px; }
.col-rate{ width: 80px; }
.col-doc{ width: 80px; }
.col-partner{ width: 100px; }
.col-flags{ width: 100px; }
.col-actions{ width: 80px; }
.col-desc{ width: 80px; }

td.col-flags,
td.col-actions{
  white-space: nowrap;
}

.col-paid{ width: 70px; }
.col-delivery{ width: 70px; }

/* =========================================================
   ICON BUTTONS
   ========================================================= */

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 28px;
  padding: .14rem .30rem;

  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15,23,42,.03);
  color: rgba(15,23,42,.85);

  box-shadow: none;
}

.icon-btn:hover{
  background: rgba(15,23,42,.06);
}

.icon-btn.danger{
  border-color: rgba(220,38,38,.35);
}

/* =========================================================
   FLAGS
   ========================================================= */

.flag-toggle input{ display:none; }

.flags-wrap{
  display:flex;
  flex-wrap: nowrap;
  gap:.22rem;
  align-items: center;
}

.flag-toggle label{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  height: 24px;
  padding: .08rem .22rem;

  border-radius: 10px;
  border: 1px solid rgba(15,23,42,.16);
  background: rgba(15,23,42,.03);
  cursor: pointer;
}

.flag-toggle i{
  font-size: .74rem;
}

.flag-toggle input:checked + label{
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.45);
}

/* =========================================================
   SAVED FLASH + TOAST
   ========================================================= */

.saved-flash{
  outline: 2px solid rgba(22,163,74,.28);
  border-radius: 14px;
}

.toast.text-bg-dark{
  background: rgba(15,23,42,.92);
  border-radius: 14px;
}

.balancio-toast-container{
  z-index: 1080;
}

/* =========================================================
   BOOTSTRAP ICONS (iOS SAFE)
   ========================================================= */

.bi::before{
  font-family: "bootstrap-icons" !important;
  display: inline-block;
}

/* =========================================================
   SUMMARY ROW (no inline styles)
   ========================================================= */

.bal-summary__head{
  border-bottom: 1px solid var(--border2);
}

.bal-tile{
  height: 100%;
  padding: 1rem;
  border-radius: 16px;
  background: rgba(15,23,42,.015);
  border: 1px solid rgba(15,23,42,.07);
}

.bal-tile--hero{
  background: rgba(37,99,235,.06);
  border-color: rgba(37,99,235,.18);
}

.bal-tile__value{
  font-weight: 700;
  font-size: 1.2rem;
}

.bal-tile--hero .bal-tile__value{
  font-size: 1.55rem;
  letter-spacing: .2px;
}

/* compact summary */
.bal-summary--compact .p-3{
  padding: .85rem !important;
}

.bal-tile--compact{
  padding: .75rem;
  border-radius: 14px;
}

.bal-tile__value--md{
  font-size: 1.08rem;
}

.bal-badge-spacer{
  width: 2.5rem;
  height: 1.25rem;
  visibility: hidden;
  display: inline-block;
  flex: 0 0 auto;
}

.bal-kv{
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.bal-kv__value{
  font-weight: 700;
  font-size: 1.08rem;
  line-height: 1.1;
}

@media (max-width: 480px){
  .bal-summary--compact .p-3{ padding: .75rem !important; }
  .bal-tile--compact{ padding: .70rem; }
  .bal-tile__value--md,
  .bal-kv__value{ font-size: 1.02rem; }
}

/* semantic colors (values) */
.bal-tile--income  .bal-tile__value,
.bal-kv--income    .bal-kv__value{ color: var(--income); }

.bal-tile--expense .bal-tile__value,
.bal-kv--expense   .bal-kv__value{ color: var(--expense); }

.bal-tile--cashin  .bal-tile__value,
.bal-kv--cashin    .bal-kv__value{ color: var(--cashin); }

.bal-tile--cashout .bal-tile__value,
.bal-kv--cashout   .bal-kv__value{ color: var(--cashout); }

.bal-tile--vat     .bal-tile__value,
.bal-kv--vat       .bal-kv__value{ color: var(--vat); }

/* small icon next to label */
.bal-tile__label{
  display:flex;
  align-items:center;
  gap:.4rem;
}

.bal-tile__icon{
  width: 1.15rem;
  height: 1.15rem;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius: 10px;
  background: rgba(15,23,42,.04);
  border: 1px solid rgba(15,23,42,.08);
  color: rgba(255, 255, 255, .65);
}

.bal-tile--income  .bal-tile__icon{ color: var(--income); }
.bal-tile--expense .bal-tile__icon{ color: var(--expense); }
.bal-tile--cashin  .bal-tile__icon{ color: var(--cashin); }
.bal-tile--cashout .bal-tile__icon{ color: var(--cashout); }
.bal-tile--vat     .bal-tile__icon{ color: var(--vat); }

/* =========================================================
   SECTIONS LOOP (no inline styles)
   ========================================================= */

.bal-section{ scroll-margin-top: 92px; }
.bal-section__head{ border-bottom: 1px solid var(--border2); }

.bal-soon{
  background: rgba(15,23,42,.02);
  border: 1px dashed rgba(15,23,42,.18);
}

/* =========================================================
   TABLE MODIFIERS – ONLY min-width (no column overrides)
   ========================================================= */

.table.balancio-table.balancio-table--other-income{ min-width: 860px; }
.table.balancio-table.balancio-table--fee{ min-width: 740px; }
.table.balancio-table.balancio-table--claim{ min-width: 860px; }
.table.balancio-table.balancio-table--cash{ min-width: 860px; }
.table.balancio-table.balancio-table--other-expense{ min-width: 980px; }
.table.balancio-table.balancio-table--other-record{ min-width: 640px; }

/* =========================================================
   MOBILE POLISH
   ========================================================= */

@media (max-width: 480px){
  .table.balancio-table{
    min-width: 980px; /* force scroll, no squeeze */
  }

  .table.balancio-table .form-control-sm,
  .table.balancio-table .form-select-sm{
    height: 30px;
    font-size: .88rem;
  }

  .icon-btn{
    height: 30px;
  }
}

.page-shell{
  padding-top: 1rem;
}

/* =========================================================
   Misc
   ========================================================= */

input.is-transfer{
  font-weight: 600;
  opacity: .9;
}

select[name="doc_delivery"]{
  font-weight: 600;
}

select[name="doc_delivery"] option[value="1"]{
  color: var(--primary); /* elektronicky */
}

select[name="doc_delivery"] option[value="2"]{
  color: var(--cashout); /* tlačený */
}

/* Income: extra column (Dodanie) + hint keď je iný mesiac */

.balancio-table tr.row-cross-month td {
  /* iba jemný vizuálny hint bez rozbitia layoutu */
  box-shadow: inset 0 -1px 0 rgba(96,165,250,.18);
}

.balancio-table input.is-cross-month{
  border-color: rgba(96,165,250,.55) !important;
  box-shadow: 0 0 0 .18rem rgba(96,165,250,.10);
}