/* SOUBOR: css/style.css (v20.0 - Design System)
  POPIS: Globální styly, proměnné, animace a komponenty UI.
*/

:root {
  --font-stack: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --c-bg: #F2F4F7;
  --c-card: #FFFFFF;
  --c-text-main: #1A1A1A;
  --c-text-muted: #858585;
  --c-accent: #E64A19;
  --c-success: #4CAF50;
  --c-danger: #F44336;
  --radius: 20px;
  --shadow: 0 4px 15px rgba(0,0,0,0.04);
}

body {
  font-family: var(--font-stack);
  background-color: var(--c-bg);
  color: var(--c-text-main);
  margin: 0;
  padding: 20px 16px 40px 16px;
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

/* ANIMATIONS */
@keyframes fadeUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.anim { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; }
.d-1 { animation-delay: 0.05s; } .d-2 { animation-delay: 0.1s; } .d-3 { animation-delay: 0.15s; } .d-4 { animation-delay: 0.2s; }

/* SPINNER / LOADER */
.spinner {
  width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--c-accent);
  border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 15px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-text { font-size: 14px; font-weight: 600; color: var(--c-text-main); }

/* HEADER & CARDS */
.header-wrapper { display: flex; flex-direction: column; align-items: center; margin-bottom: 25px; width: 100%; overflow-x: hidden; }
.brand-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; width: 100%; margin-left: 16px; }
.brand-text { font-size: 26px; font-weight: 900; letter-spacing: 0.5px; color: var(--c-text-main); text-transform: uppercase; line-height: 1; margin-top: 2px; }
.brand-logo { width: 70px; height: 70px; border-radius: 50%; background: #000; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border: 2px solid #fff; flex-shrink: 0; }
.brand-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.update-pill { font-size: 12px; color: var(--c-text-muted); background: rgba(0,0,0,0.04); padding: 5px 14px; border-radius: 20px; font-weight: 500; display: flex; align-items: center; gap: 6px; margin-left: 0; }
.update-pill::before { content: ''; width: 6px; height: 6px; background: #4CAF50; border-radius: 50%; display: block; }

.card { background: var(--c-card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; position: relative; }
.mb-2 { margin-bottom: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }
.card-header-line { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 6px; width: 100%; }
.card-icon { color: var(--c-accent); width: 20px; height: 20px; }
.card-label { font-size: 16px; font-weight: 700; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px; line-height: 1; }
.card-value { font-size: 26px; font-weight: 800; color: var(--c-text-main); line-height: 1.2; }
.card-value.big { font-size: 34px; letter-spacing: 0px; margin: 2px 0; }
.card-sub { font-size: 13px; color: var(--c-text-muted); font-weight: 500; }

/* RECEIPT */
.receipt-container { margin: 25px 0; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.04)); }
.receipt-body { background: #FFF; border-radius: var(--radius) var(--radius) 0 0; padding: 10px 20px 25px 20px; }
.receipt-header { text-align: center; font-size: 20px; font-weight: 800; color: var(--c-text-main); padding-bottom: 5px; border-bottom: 2px dashed #E0E0E0; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.r-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dotted #F0F0F0; font-size: 15px; }
.r-row:last-child { border: none; }
.r-name { font-weight: 500; color: var(--c-text-main); }
.r-val { font-weight: 700; color: var(--c-text-main); }
.jagged { height: 12px; width: 100%; background: #FFF; clip-path: polygon(0% 0%, 0% 100%, 2.5% 0%, 5% 100%, 7.5% 0%, 10% 100%, 12.5% 0%, 15% 100%, 17.5% 0%, 20% 100%, 22.5% 0%, 25% 100%, 27.5% 0%, 30% 100%, 32.5% 0%, 35% 100%, 37.5% 0%, 40% 100%, 42.5% 0%, 45% 100%, 47.5% 0%, 50% 100%, 52.5% 0%, 55% 100%, 57.5% 0%, 60% 100%, 62.5% 0%, 65% 100%, 67.5% 0%, 70% 100%, 72.5% 0%, 75% 100%, 77.5% 0%, 80% 100%, 82.5% 0%, 85% 100%, 87.5% 0%, 90% 100%, 92.5% 0%, 95% 100%, 97.5% 0%, 100% 100%, 100% 0%); margin-top: -1px; }

/* ACTION BUTTONS */
.btn-clean { background: var(--c-card); border: none; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer; color: var(--c-text-main); font-weight: 700; font-size: 15px; transition: transform 0.1s; }
.btn-clean:active { transform: scale(0.97); }
.btn-icon-wrapper { color: var(--c-accent); background: rgba(230, 74, 25, 0.1); width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.btn-icon-wrapper svg { width: 24px; height: 24px; stroke-width: 2.5; }

/* --- STATS OVERLAY --- */
#stats-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #F8F9FA; z-index: 10000;
  transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column; overflow-y: auto;
}
#stats-overlay.open { transform: translateY(0); }

.stats-header {
  position: sticky; top: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
  padding: 12px 20px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #E5E5E5; z-index: 10;
}
.stats-main-title { font-size: 20px; font-weight: 900; color: var(--c-text-main); line-height: 1; }
.year-tabs { display: flex; gap: 8px; margin-top: 5px; }
.year-tab { font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 14px; background: #EEE; color: #666; cursor: pointer; border: none; transition: all 0.2s; }
.year-tab.active { background: var(--c-text-main); color: #FFF; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.stats-close { background: #F0F2F5; border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; font-weight: bold; }

.stats-content { padding: 20px; flex: 1; padding-bottom: 60px; position: relative; }
.section-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; margin-top: 25px; }
.section-header:first-child { margin-top: 5px; }
.section-icon { color: var(--c-accent); width: 18px; height: 18px; }
.section-title { font-size: 13px; font-weight: 800; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* TABLE */
.stats-card { background: #FFF; padding: 15px; border-radius: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-bottom: 10px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th { text-align: center; color: var(--c-text-muted); padding: 10px 5px; border-bottom: 1px solid #E0E0E0; font-size: 11px; text-transform: uppercase; }
.stats-table td { padding: 12px 5px; border-bottom: 1px solid #F0F0F0; color: var(--c-text-main); font-weight: 600; text-align: center; }
.stats-table tr:last-child td { border-bottom: none; }
.align-left { text-align: left !important; }
.total-row td { background-color: #F9FAFB; font-weight: 900 !important; border-top: 2px solid #E0E0E0; font-size: 14px; color: var(--c-text-main); }

/* COLORS */
.profit-pos { color: var(--c-success) !important; } 
.profit-neg { color: var(--c-danger) !important; }

/* KPI GRID */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi-card { background: #FFF; padding: 15px 10px; border-radius: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); text-align: center; display: flex; flex-direction: column; justify-content: center; min-height: 110px; }
.kpi-label { font-size: 14px; font-weight: 800; color: var(--c-text-muted); text-transform: uppercase; margin-bottom: 4px; line-height: 1.2; }
.kpi-val { font-size: 20px; font-weight: 800; color: var(--c-text-main); margin: 2px 0; }
.kpi-val.green { color: var(--c-success); }
.kpi-explain { font-size: 12px; color: #999; margin-top: 4px; font-weight: 600; min-height: 14px; display: block; }

/* ERROR & DEBUG STYLES */
.error-container { padding: 20px; color: #D32F2F; text-align: left; }
.debug-log { background: #f5f5f5; border: 1px solid #ddd; padding: 10px; border-radius: 8px; font-family: monospace; font-size: 11px; color: #333; overflow-x: auto; white-space: pre-wrap; margin-top: 10px; max-height: 300px; overflow-y: auto; line-height: 1.4; }
.debug-log h4 { margin-top: 0; margin-bottom: 5px; color: #555; }

/* MODALS */
dialog { border: none; padding: 0; border-radius: 24px; box-shadow: 0 40px 80px rgba(0,0,0,0.25); width: 85%; max-width: 340px; background: #FFF; }
dialog::backdrop { background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.modal-content { padding: 30px 25px; }
.modal-title { text-align: center; font-size: 18px; font-weight: 800; margin-bottom: 25px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.modal-icon-lg { width: 50px; height: 50px; background: rgba(230, 74, 25, 0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--c-accent); }

/* INPUT FIELDS */
input { display: block; width: 100%; padding: 16px; margin-bottom: 15px; border: 1px solid #E5E5E5; border-radius: 14px; font-size: 16px; background: #FAFAFA; box-sizing: border-box; outline: none; -webkit-appearance: none; }
input:focus { border-color: var(--c-accent); background: #FFF; }
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

.modal-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.btn { padding: 16px; border-radius: 14px; border: none; font-weight: 700; font-size: 16px; cursor: pointer; }
.btn-primary { background: #1A1A1A; color: #FFF; }
.btn-secondary { background: #F0F2F5; color: #1A1A1A; }

/* TOAST */
#toast { visibility: hidden; position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1A1A1A; color: #fff; padding: 12px 24px; border-radius: 50px; font-size: 14px; font-weight: 600; opacity: 0; transition: all 0.3s; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 9999; }
#toast.show { opacity: 1; top: 40px; }