/* ─── Layout classes (desktop defaults) ───────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
  padding: 20px;
  gap: 20px;
}

.sidebar {
  width: 208px;
  min-height: calc(100vh - 40px);
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-spacer { flex-grow: 1; }

.main-card {
  flex: 1;
  min-height: calc(100vh - 40px);
  overflow: hidden;
}

/* ─── Page sections ───────────────────────────────────────────────────────── */

.page-pad { padding: 36px 40px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

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

/* ─── Responsive grids ────────────────────────────────────────────────────── */

.resp-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.resp-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-top-grid {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 16px;
  align-items: end;
}

.form-proj-lang {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  margin-top: 16px;
  align-items: end;
}

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

/* ─── VAT section ─────────────────────────────────────────────────────────── */

.vat-section {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
}

.vat-summary {
  min-width: 240px;
  border: 1.5px solid #f1f5f9;
  border-radius: 16px;
  overflow: hidden;
}

/* ─── Scrollable tables ───────────────────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll table {
  min-width: 580px;
}

/* ─── Form action bar ─────────────────────────────────────────────────────── */

.form-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
}

/* ─── Tablet (768px – 1199px) ─────────────────────────────────────────────── */

@media (max-width: 1199px) {
  .page-pad { padding: 28px 28px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Mobile (< 768px) ────────────────────────────────────────────────────── */

@media (max-width: 767px) {

  /* Body stays clean */
  body { background: #eef2ff; }

  /* Shell: column, full viewport */
  .app-shell {
    flex-direction: column;
    padding: 0;
    gap: 0;
    min-height: 100vh;
  }

  /* ── Sidebar → fixed bottom tab bar ──────────────────────────────────── */
  .sidebar {
    order: 2;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    min-height: unset;
    height: 60px;
    border-radius: 0 !important;
    padding: 0 !important;
    flex-direction: row;
    z-index: 200;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar-brand { display: none; }

  .sidebar-nav {
    flex-direction: row;
    gap: 0;
    width: 100%;
    flex: 1;
  }

  .sidebar-spacer { display: none; }

  /* Nav links become bottom tab items */
  .nav-link {
    flex: 1;
    flex-direction: column !important;
    gap: 3px !important;
    padding: 8px 4px !important;
    border-radius: 0 !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center;
    min-height: 60px;
  }

  .nav-link svg {
    width: 22px !important;
    height: 22px !important;
    flex-shrink: 0;
  }

  .nav-link span {
    font-size: 9px !important;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 72px;
    display: block;
  }

  .nav-link.active {
    border-radius: 0 !important;
    box-shadow: none !important;
  }

  /* ── Main card: full screen above nav ─────────────────────────────────── */
  .main-card {
    flex: 1;
    border-radius: 0 !important;
    box-shadow: none !important;
    min-height: unset;
    height: calc(100vh - 60px);
    overflow: hidden;
  }

  .main-card main {
    height: 100%;
  }

  /* ── Page sections ────────────────────────────────────────────────────── */
  .page-pad { padding: 20px 16px; }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }

  .page-header-btn {
    text-align: center;
    justify-content: center !important;
    width: 100%;
    box-sizing: border-box;
  }

  /* ── Stats ────────────────────────────────────────────────────────────── */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }

  /* Stat card inner adjustments */
  .stat-card { padding: 14px 16px !important; }

  /* ── Grids → single column ────────────────────────────────────────────── */
  .resp-grid-2 { grid-template-columns: 1fr !important; gap: 12px !important; }
  .resp-grid-3 { grid-template-columns: 1fr !important; gap: 10px !important; }
  .form-top-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .form-proj-lang { grid-template-columns: 1fr !important; gap: 12px !important; }
  .cond-grid { grid-template-columns: 1fr !important; }

  /* ── VAT section ──────────────────────────────────────────────────────── */
  .vat-section { flex-direction: column !important; gap: 16px !important; }
  .vat-summary { min-width: unset !important; width: 100%; }

  /* ── Tables ───────────────────────────────────────────────────────────── */
  .table-scroll { overflow-x: auto; }
  .table-scroll table { min-width: 560px; }

  /* ── Form actions ─────────────────────────────────────────────────────── */
  .form-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .form-actions-bar > a,
  .form-actions-bar > div {
    display: flex;
    gap: 8px;
  }

  .form-actions-bar > a {
    text-align: center;
    justify-content: center;
  }

  .form-actions-bar > div {
    flex: 1;
  }

  .form-actions-bar > div > button {
    flex: 1;
    justify-content: center;
  }

  /* ── Buttons: touch-friendly ──────────────────────────────────────────── */
  .icon-btn { padding: 10px !important; font-size: 16px !important; }

  /* ── Toast: above bottom nav ──────────────────────────────────────────── */
  .app-toast {
    bottom: 72px !important;
    left: 16px !important;
    right: 16px !important;
    text-align: center;
  }

  /* ── Dashboard table: compact cells ──────────────────────────────────── */
  .col-hide-sm { display: none !important; }
}
