* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --green: #1a7f5a;
  --green-dark: #14634a;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2320;
  --muted: #6b7770;
  --red: #c0392b;
  --border: #e0e5e2;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* Login */
#screen-login { justify-content: center; align-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box h1 { font-size: 2rem; margin-bottom: 4px; }
.login-box form { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }

/* Loga coal family */
.logo-main {
  width: 68px; height: 68px;
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(38, 198, 114, 0.25);
}
.logo-row {
  display: flex; justify-content: center; gap: 12px;
  margin-top: 36px;
  opacity: 0.85;
}
.logo-row img { width: 30px; height: 30px; border-radius: 6px; }
.header-brand { display: inline-flex; align-items: center; gap: 10px; }
.logo-header { width: 28px; height: 28px; border-radius: 6px; display: block; }

input, select {
  font-size: 1rem;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  width: 100%;
}

.btn {
  font-size: 1rem;
  padding: 13px 18px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:active { background: var(--green-dark); }
.btn-link { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }

.btn-back {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.btn-back:active { background: var(--bg); }

.btn-photo-view {
  background: var(--card);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 6px 12px;
  font-size: 0.85rem;
  margin: 4px 0;
}

.photo-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 100;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px;
  cursor: pointer;
}
.photo-overlay img {
  max-width: 100%; max-height: 85dvh;
  border-radius: 8px;
  background: #fff;
}
.photo-hint { color: #ccc; font-size: 0.85rem; margin-top: 10px; }

.new-user-form { display: flex; flex-direction: column; gap: 10px; }

.btn-danger {
  background: var(--card);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 6px 12px;
  font-size: 0.85rem;
  margin: 4px 0;
}
.btn-danger:active { background: #fdeceb; }

.btn-logout {
  background: var(--card);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 14px;
  font-size: 0.9rem;
}
.btn-logout:active { background: #fdeceb; }

/* potvrzovací modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--card);
  border-radius: 16px;
  padding: 22px;
  width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-title { font-weight: 700; margin-bottom: 6px; }
.modal .muted { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.btn-modal-danger { background: var(--red); color: #fff; }
.btn-modal-danger:active { background: #a53125; }

/* profil */
.profile-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.profile-card label { font-size: 0.85rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.profile-card textarea {
  font-size: 1rem; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--card); width: 100%;
  font-family: inherit; resize: vertical;
}
.avatar-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }

.avatar {
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 84px; height: 84px; font-size: 2rem; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.95rem; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; }

/* App layout */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.banner {
  background: #fff3cd; color: #7a5d00;
  padding: 8px 16px; font-size: 0.85rem; text-align: center;
}

main { flex: 1; padding: 16px; padding-bottom: 90px; overflow-y: auto; }

nav#tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
nav#tabs button {
  flex: 1;
  background: none; border: none;
  padding: 10px 4px;
  font-size: 1.3rem;
  color: var(--muted);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
nav#tabs button span { font-size: 0.68rem; font-weight: 600; }
nav#tabs button.active { color: var(--green); }

/* Cards & lists */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 10px; }

.item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-row .item-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item-row .item-price { font-weight: 700; white-space: nowrap; }
.item-row select { width: 150px; flex-shrink: 0; padding: 8px 10px; }

.scan-hero {
  display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding: 40px 16px; text-align: center;
}
.scan-hero .btn { font-size: 1.15rem; padding: 18px 32px; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--red); font-weight: 600; }
.success { color: var(--green); font-weight: 600; }
.total-row { display: flex; justify-content: space-between; font-weight: 700; padding-top: 10px; }

.log-line { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.log-line:last-child { border-bottom: none; }
.log-line .muted { display: block; margin-top: 2px; font-size: 0.78rem; }

.badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.badge-pending { background: #fff3cd; color: #7a5d00; }
.badge-done { background: #d9f2e6; color: var(--green-dark); }

.spinner {
  margin: 40px auto; width: 44px; height: 44px;
  border: 4px solid var(--border); border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

table.summary { width: 100%; border-collapse: collapse; }
table.summary td, table.summary th {
  text-align: left; padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
table.summary td:last-child, table.summary th:last-child { text-align: right; }
table.summary tr.summary-total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: none; }

.price-strike { color: var(--muted); font-size: 0.82em; font-weight: 400; margin-right: 4px; }

.discount-form, .closing-form {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.discount-form input[type="number"] { width: 90px; }
.closing-form input[type="month"] { flex: 1; min-width: 140px; }
.discount-form button, .closing-form button { flex-shrink: 0; padding: 12px 16px; }
#discount-msg, #new-user-msg { width: 100%; }
