/* Vzhlad podla docs/mockups/mobile-home.html. Ziadne inline styly vo views (prisna CSP). */
:root {
  --app-bg: #f5f6f8;
  --app-border: #e3e5e8;
  --app-muted: #6b7280;
  --app-primary: #0d6efd;
  --app-tabbar-h: 64px;
}

body {
  background: var(--app-bg);
  font-family: -apple-system, system-ui, sans-serif;
  color: #1f2328;
  min-height: 100dvh;
}

.app-header {
  background: #fff;
  border-bottom: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 10px;
}

.app-header .app-sub { color: var(--app-muted); font-size: 12px; }

.app-main {
  padding: 10px 10px calc(var(--app-tabbar-h) + env(safe-area-inset-bottom) + 16px);
}

.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--app-border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  font-size: 11px;
}

.app-tabbar a,
.app-tabbar span {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--app-muted);
}

.app-tabbar [aria-current="page"] { color: var(--app-primary); font-weight: 600; }

.app-topnav { display: none; gap: 8px; align-items: center; }
.app-topnav a,
.app-topnav span {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  text-decoration: none;
  color: var(--app-muted);
}
.app-topnav [aria-current="page"] { color: var(--app-primary); font-weight: 600; }

.app-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.btn, .form-control, .form-select, .nav-link { min-height: 44px; }

input, select, textarea { font-size: 16px; }

img, table { max-width: 100%; }

.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; transition: opacity 200ms ease-in; }

@media (min-width: 992px) {
  .app-tabbar { display: none; }
  .app-topnav { display: flex; }
  .app-header { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; }
  .app-main { max-width: 960px; margin: 0 auto; padding-bottom: 24px; }
}

/* Prihlasovanie a 2FA (layouts/auth) */
.auth-wrap {
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 48px) 16px calc(env(safe-area-inset-bottom) + 24px);
  background: var(--app-bg);
}
.auth-card {
  max-width: 400px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 16px;
}
@media (min-width: 576px) {
  .auth-card { padding: 24px; }
}
.auth-logo {
  text-align: center;
  margin-bottom: 24px;
  font-size: 20px;
  font-weight: 600;
}
.auth-wrap #app-alert { max-width: 400px; margin: 0 auto 16px; }
.btn { font-weight: 600; }
.form-label { font-weight: 600; }
.install-hint { padding: 16px; margin-bottom: 16px; }
.install-hint[hidden] { display: none !important; }
.install-hint-close { min-width: 44px; min-height: 44px; }
.auth-logo img { vertical-align: middle; margin-right: 8px; }
.auth-wrap .install-hint { max-width: 400px; margin: 0 auto 16px; }

/* 2FA nastavenie */
.qr-box {
  background: #fff;
  padding: 16px;
  max-width: 200px;
  margin: 0 auto 32px;
}
.qr-box svg { width: 100%; height: auto; }
.totp-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  user-select: all;
  overflow-wrap: anywhere;
}
.auth-code-input {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: .25em;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.code-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
}

/* Zapamätať zariadenie: dotykový cieľ aspoň 44 px (UX) */
.auth-card .form-check {
  min-height: 44px;
  padding-left: 2rem;
}
.auth-card .form-check-input {
  width: 1.5rem;
  height: 1.5rem;
  margin-left: -2rem;
  margin-top: 0.1rem;
}

/* Viac a Zabezpecenie */
.security-card + .security-card { margin-top: 16px; }
.device-row,
.event-row { padding: 8px 0; border-bottom: 1px solid var(--app-border); }
.device-row:last-child,
.event-row:last-child { border-bottom: 0; }
.btn-touch { min-width: 44px; min-height: 44px; }
.event-ip { font-family: ui-monospace, monospace; font-size: 12px; }
.more-item { min-height: 48px; display: flex; align-items: center; width: 100%; }

/* Master data: subjekty a klienti (Phase 3) */
.master-row {
  display: flex;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-border);
  min-height: 48px;
}
.master-row:last-child { border-bottom: 0; }

.master-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 576px) {
  .master-actions { flex-direction: row; justify-content: flex-end; }
}

.master-kv { margin: 0; }
.master-kv dt { font-size: 12px; font-weight: 400; color: var(--app-muted); margin-top: 8px; }
.master-kv dd { font-size: 16px; margin: 4px 0 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
@media (min-width: 768px) {
  .master-kv { display: grid; grid-template-columns: 200px 1fr; column-gap: 16px; }
  .master-kv dt { margin-top: 0; padding: 8px 0 0; }
  .master-kv dd { margin: 0; padding: 4px 0; }
}

.master-fixed {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 6px;
}

.master-changed { border-left: 4px solid #6b7280; padding-left: 8px; }

.master-iban {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.master-sticky-actions { margin-top: 24px; }
@media (max-width: 767.98px) {
  .master-sticky-actions {
    position: sticky;
    bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--app-border);
    padding: 8px 16px;
    margin-left: -16px;
    margin-right: -16px;
  }
}

/* Radio a checkbox riadky formularov Phase 3: dotykovy ciel aspon 44 px */
.master-check { min-height: 44px; padding-left: 2rem; display: flex; align-items: center; }
.master-check .form-check-input { width: 1.5rem; height: 1.5rem; margin-left: -2rem; margin-top: 0; flex: none; }
.master-check .form-check-label { padding-left: 0.5rem; }

/* Ulohy, fakturacne casti a dashboard (Phase 4). Jediny blok tried .work-*, inline styly sa nepouzivaju. */
.tabular-nums { font-variant-numeric: tabular-nums; }
.work-narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.work-wide { max-width: 960px; margin-left: auto; margin-right: auto; }

.work-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 359.98px) {
  .work-tiles { grid-template-columns: 1fr; }
}
.work-tile {
  display: block;
  min-height: 88px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.work-tile .work-tile-label { display: block; font-size: 12px; color: var(--app-muted); margin-bottom: 4px; }
.work-tile .work-tile-amount { display: block; font-size: 20px; font-weight: 600; line-height: 1.2; }
.work-tile .work-tile-hours { display: block; font-size: 12px; color: var(--app-muted); margin-top: 4px; }

.work-group { margin-top: 24px; }
.work-group h2 { font-size: 20px; font-weight: 600; line-height: 1.2; display: flex; align-items: center; gap: 8px; }

.work-task {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 64px;
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid var(--app-border);
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.work-task .work-task-title { flex: 1 1 100%; font-size: 16px; font-weight: 600; }
.work-task .work-task-meta { flex: 1 1 auto; font-size: 12px; color: var(--app-muted); font-variant-numeric: tabular-nums; }
@media (min-width: 768px) {
  .work-task .work-task-title { flex: 1 1 0; }
  .work-task .work-task-meta { flex: 0 0 96px; text-align: right; }
}

.work-progress {
  display: flex;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--app-border);
}
.work-progress .work-billed { background: #6b7280; }
.work-progress .work-planned { background: #adb5bd; }
.work-seg-0 { width: 0%; }
.work-seg-5 { width: 5%; }
.work-seg-10 { width: 10%; }
.work-seg-15 { width: 15%; }
.work-seg-20 { width: 20%; }
.work-seg-25 { width: 25%; }
.work-seg-30 { width: 30%; }
.work-seg-35 { width: 35%; }
.work-seg-40 { width: 40%; }
.work-seg-45 { width: 45%; }
.work-seg-50 { width: 50%; }
.work-seg-55 { width: 55%; }
.work-seg-60 { width: 60%; }
.work-seg-65 { width: 65%; }
.work-seg-70 { width: 70%; }
.work-seg-75 { width: 75%; }
.work-seg-80 { width: 80%; }
.work-seg-85 { width: 85%; }
.work-seg-90 { width: 90%; }
.work-seg-95 { width: 95%; }
.work-seg-100 { width: 100%; }

.work-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--app-primary);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  z-index: 20;
}
@media (min-width: 768px) {
  .work-fab { display: none; }
}

.work-alloc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-border);
  font-variant-numeric: tabular-nums;
}

.work-sheet.offcanvas-bottom {
  max-height: 85dvh;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
}

.work-month-pick { display: flex; gap: 0; }
.work-month-pick .btn { flex: 1 1 0; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.work-month-pick .btn-check:checked + .btn { background: #6c757d; border-color: #6c757d; color: #fff; }

.work-delta { font-size: 12px; font-weight: 600; color: var(--app-muted); }

/* Phase 5: faktury (.inv-*) */
.tabular-nums { font-variant-numeric: tabular-nums; }

.inv-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px;
}
@media (min-width: 768px) {
  .inv-picker { grid-template-columns: repeat(3, 1fr); }
}

.inv-summary { padding: 8px 0; }
.inv-summary-total { font-size: 28px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }

.inv-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-border);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.inv-total {
  padding: 16px 0 0;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.inv-total .small { font-size: 12px; font-weight: 400; }

.inv-dates { display: flex; flex-wrap: wrap; gap: 16px; }
.inv-dates .form-control { min-height: 44px; }

.inv-pay .form-select, .inv-pay .form-control { min-height: 44px; font-size: 16px; }
.inv-pay textarea.form-control { min-height: 88px; }

.inv-warn { padding: 16px; }
.inv-warn .form-check { min-height: 44px; display: flex; align-items: center; gap: 8px; }

.inv-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-height: 64px;
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid var(--app-border);
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.inv-row .inv-row-title { flex: 1 1 auto; font-size: 16px; font-weight: 600; }
.inv-row .inv-row-meta { font-size: 12px; color: var(--app-muted); }
.inv-row .inv-row-amount { font-size: 16px; font-weight: 400; font-variant-numeric: tabular-nums; }

.inv-docs { display: flex; flex-direction: column; gap: 8px; }
.inv-docs .btn { width: 100%; min-height: 44px; }
@media (min-width: 768px) {
  .inv-docs { flex-direction: row; align-items: center; }
  .inv-docs .btn { width: auto; }
}

/* Zakonne texty (Phase 6, SET-01) */
.lt-group { margin-bottom: 24px; }
.lt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-border);
}
.lt-row:last-child { border-bottom: 0; }
.lt-row > .lt-main { flex: 1 1 auto; min-width: 0; }
.lt-badge { flex: 0 0 auto; }
.lt-body { font-size: 16px; min-height: 8em; overflow-wrap: anywhere; }
.lt-effective { font-size: 12px; }
.lt-check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
