/* ============================================================
   1. RESET I GŁÓWNY SZKIELET (PWA FULLSCREEN)
============================================================ */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Wyłącza pasek przewijania przeglądarki */
    background: #F4F1EA;
}

*, *::before, *::after { box-sizing: border-box; }

.app { 
    font-family: 'DM Sans', system-ui, sans-serif; 
    color: #1c1917; 
    height: 100vh; 
    width: 100vw; 
    display: flex; 
}

.font-serif { font-family: 'Fraunces', Georgia, serif; font-feature-settings: "ss01"; }

/* ============================================================
   2. SIDEBAR (LEWY PASEK)
============================================================ */
.sb { 
    width: 200px; 
    height: 100%; 
    flex-shrink: 0; 
    background: #FAF8F4; 
    border-right: 0.5px solid rgba(0,0,0,0.08); 
    display: flex; 
    flex-direction: column; 
}

.sb-brand { padding: 18px 16px 16px; border-bottom: 0.5px solid rgba(0,0,0,0.08); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sb-logo { width: 30px; height: 30px; border-radius: 7px; background: #2F5D50; color: #fff; display: grid; place-items: center; font-family: 'Fraunces', serif; font-style: italic; font-size: 17px; }
.sb-brand-name { font-family: 'Fraunces', serif; font-size: 14px; line-height: 1; }
.sb-brand-tag { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: #78716c; margin-top: 3px; }
.sb-nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 1px; flex: 1; overflow-y: auto; }
.sb-item { display: flex; align-items: center; gap: 9px; padding: 7px 9px; font-size: 12px; border-radius: 6px; cursor: pointer; color: #57534e; background: transparent; border: none; text-align: left; font-family: inherit; transition: background 0.1s; }
.sb-item:hover { background: rgba(0,0,0,0.04); }
.sb-item.active { background: #2F5D50; color: #fff; }
.sb-icon { width: 14px; height: 14px; flex-shrink: 0; }
.sb-divider { height: 0.5px; background: rgba(0,0,0,0.08); margin: 8px 4px; flex-shrink: 0; }
.sb-foot { padding: 10px 12px; border-top: 0.5px solid rgba(0,0,0,0.08); display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-top: auto; } /* margin-top: auto dopycha stopkę w dół */
.sb-avatar { width: 26px; height: 26px; border-radius: 50%; background: #e7e5e4; display: grid; place-items: center; font-size: 10px; font-weight: 500; }
.sb-foot-name { font-size: 11px; font-weight: 500; line-height: 1.2; }
.sb-foot-role { font-size: 9px; color: #78716c; margin-top: 2px; }

/* ============================================================
   3. MAIN & TOPBAR (PRAWY OBSZAR)
============================================================ */
.main { 
    flex: 1; 
    min-width: 0; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
}

.tb { 
    height: 44px; 
    flex-shrink: 0; 
    border-bottom: 0.5px solid rgba(0,0,0,0.08); 
    background: rgba(255,255,255,0.6); 
    padding: 0 18px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
}
.tb-search { flex: 1; max-width: 360px; display: flex; align-items: center; gap: 6px; font-size: 12px; color: #a8a29e; }
.tb-meta { font-size: 10px; color: #78716c; padding-left: 12px; border-left: 0.5px solid rgba(0,0,0,0.08); }

.content { 
    flex: 1; 
    min-height: 0; /* Ważne: powstrzymuje rozciąganie aplikacji */
    overflow-y: auto; 
    padding: 22px 26px; 
}

/* ============================================================
   4. ELEMENTY WSPÓLNE (Przyciski, Nagłówki, Alerty)
============================================================ */
.ph { margin-bottom: 18px; }
.ph-tag { font-size: 9px; letter-spacing: 0.2em; text-transform: uppercase; color: #78716c; margin-bottom: 6px; }
.ph-title { font-family: 'Fraunces', serif; font-size: 30px; line-height: 1; letter-spacing: -0.02em; }
.ph-sub { font-size: 12px; color: #78716c; margin-top: 6px; }
.ph-row { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tg { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.btn { background: #fff; border: 0.5px solid rgba(0,0,0,0.12); border-radius: 6px; padding: 6px 10px; font-size: 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; line-height: 1; color: #44403c; font-family: inherit; }
.btn:hover { background: #f5f5f4; border-color: rgba(0,0,0,0.2); }
.btn-icon { width: 26px; padding: 6px; justify-content: center; }
.btn-primary { background: #2F5D50; color: #fff; border-color: #2F5D50; font-weight: 500; }
.btn-primary:hover { background: #264a40; }
.btn-dark { background: #1c1917; color: #fff; border-color: #1c1917; font-weight: 500; }

.alert { background: #FCF5F0; border: 0.5px solid #F5D5C5; border-radius: 8px; padding: 11px 14px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.alert-icon { color: #C4623A; flex-shrink: 0; }
.alert-h { font-size: 12px; font-weight: 500; color: #8B3D1F; }
.alert-t { font-size: 11.5px; color: #44403c; margin-top: 2px; line-height: 1.45; }

/* ============================================================
   5. WIDOKI APKI (Karty, Kalendarz, Raporty, Notatki)
============================================================ */
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cards-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.card { background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 16px; }
.card-h { display: flex; gap: 11px; align-items: flex-start; }
.card-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.card-role { font-size: 11px; color: #78716c; margin-top: 2px; }
.card-meta { font-size: 11px; color: #57534e; margin-top: 6px; }
.card-stats { display: flex; gap: 14px; padding-top: 11px; margin-top: 11px; border-top: 0.5px solid rgba(0,0,0,0.06); font-size: 10.5px; }
.card-stats > div > div:first-child { font-size: 8.5px; letter-spacing: 0.12em; text-transform: uppercase; color: #a8a29e; }
.card-stats > div > div:last-child { font-weight: 500; margin-top: 2px; font-size: 12px; }
.tag { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 5px; border-radius: 3px; background: #f5f5f4; color: #57534e; font-weight: 500; display: inline-flex; align-items: center; }
.tag.work { background: #2F5D50; color: #fff; }

.task-row { background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 14px 16px; margin-bottom: 8px; }
.tr-row1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.tr-title { font-size: 13px; font-weight: 500; }
.tr-desc { font-size: 11.5px; color: #57534e; line-height: 1.5; margin-top: 4px; }
.tr-meta { display: flex; gap: 10px; margin-top: 8px; font-size: 10.5px; color: #78716c; }

.note { background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start; }
.note-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; font-size: 10px; color: #a8a29e; }

.cal-wrap { background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 10px; overflow: hidden; margin-top: 10px; }
.cal-scroll { overflow-x: auto; }
.grid { display: grid; }
.mh { padding: 7px 10px; font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: #78716c; font-weight: 500; border-bottom: 0.5px solid rgba(0,0,0,0.08); background: #FAF8F4; }
.mh.first { border-right: 0.5px solid rgba(0,0,0,0.08); position: sticky; left: 0; z-index: 3; }
.dh { padding: 5px 0 7px; text-align: center; border-right: 0.5px solid rgba(0,0,0,0.06); border-bottom: 0.5px solid rgba(0,0,0,0.08); background: #FAF8F4; }
.dh.today { background: rgba(196,98,58,0.14); }
.dow { font-size: 9px; text-transform: uppercase; color: #a8a29e; letter-spacing: 0.06em; }
.dh.today .dow { color: #C4623A; font-weight: 500; }
.dnum { font-size: 12px; font-weight: 500; margin-top: 1px; }
.dh.today .dnum { color: #C4623A; }
.nc { padding: 0 11px; display: flex; align-items: center; gap: 9px; border-right: 0.5px solid rgba(0,0,0,0.08); border-bottom: 0.5px solid rgba(0,0,0,0.06); background: #fff; position: sticky; left: 0; z-index: 2; min-height: 42px; }
.nc:hover { background: #FAF8F4; }
.av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 500; flex-shrink: 0; }
.nc-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.dc { padding: 4px; border-right: 0.5px solid rgba(0,0,0,0.06); border-bottom: 0.5px solid rgba(0,0,0,0.06); position: relative; }
.dc.today { box-shadow: inset 0 0 0 1.5px #C4623A; z-index: 1; }
.tile { width: 100%; height: 100%; min-height: 32px; border-radius: 5px; cursor: pointer; position: relative; transition: transform 0.08s, box-shadow 0.08s; border: 0.5px solid rgba(0,0,0,0.08); background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; font-family: inherit; }
.tile:hover { transform: scale(1.07); box-shadow: 0 2px 8px rgba(0,0,0,0.15); z-index: 5; }
.tile.present { border: none; }
.tile-empty { color: #d6d3d1; font-size: 12px; line-height: 1; opacity: 0; }
.tile:hover .tile-empty { opacity: 1; }
.tile-dot { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.95); position: absolute; top: 4px; right: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 10px; color: #78716c; padding: 0 4px; }
.lg-item { display: flex; align-items: center; gap: 5px; }
.lg-sw { width: 11px; height: 11px; border-radius: 3px; }

.panel { margin-top: 14px; background: #fff; border: 0.5px solid rgba(0,0,0,0.1); border-radius: 10px; overflow: hidden; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.panel-h { padding: 14px 18px; border-bottom: 0.5px solid rgba(0,0,0,0.08); display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-l { display: flex; align-items: center; gap: 12px; }
.panel-name { font-size: 14px; font-weight: 500; line-height: 1.2; }
.panel-date { font-family: 'Fraunces', serif; font-size: 20px; line-height: 1.1; margin-top: 4px; letter-spacing: -0.01em; }
.panel-meta { font-size: 11px; color: #78716c; margin-top: 4px; display: flex; gap: 10px; }
.panel-close { background: transparent; border: none; cursor: pointer; padding: 5px 9px; color: #78716c; border-radius: 5px; font-size: 16px; line-height: 1; font-family: inherit; }
.panel-close:hover { background: rgba(0,0,0,0.05); }
.task { padding: 11px 18px; border-bottom: 0.5px solid rgba(0,0,0,0.06); display: flex; gap: 11px; }
.task:last-child { border-bottom: none; }
.task.done { background: rgba(47,93,80,0.04); }
.task.in_progress { background: rgba(196,98,58,0.05); }
.tk-check { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,0.18); flex-shrink: 0; margin-top: 1px; display: grid; place-items: center; font-size: 9px; cursor: pointer; background: #fff; color: transparent; }
.task.done .tk-check { background: #2F5D50; border-color: #2F5D50; color: #fff; }
.task.in_progress .tk-check { border-color: #C4623A; }
.task.in_progress .tk-check::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #C4623A; }
.tk-body { flex: 1; min-width: 0; }
.tk-title { font-size: 12.5px; font-weight: 500; }
.tk-meta { font-size: 10.5px; color: #78716c; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.pill { font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; padding: 1px 5px; border-radius: 3px; background: #f5f5f4; color: #57534e; }
.pill.crit { background: #C4623A; color: #fff; }
.pill.h { background: #f59e0b; color: #fff; }
.panel-empty { padding: 26px; text-align: center; color: #a8a29e; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.stat { background: #fff; border: 0.5px solid rgba(0,0,0,0.08); border-radius: 8px; padding: 12px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-l { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: #78716c; font-weight: 500; }
.stat-v { font-family: 'Fraunces', serif; font-size: 24px; line-height: 1; margin-top: 6px; letter-spacing: -0.01em; }
.stat-s { font-size: 10px; color: #a8a29e; margin-top: 4px; }
.stat-bar { width: 3px; height: 36px; border-radius: 2px; flex-shrink: 0; }

/* ============================================================
   6. AUTH PAGES (LOGOWANIE I ZAPROSZENIA) - PERFEKCYJNIE ZLICOWANE
============================================================ */
body.auth-page { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    height: 100vh; 
    background: #e7e5e4; 
    margin: 0; 
    font-family: 'DM Sans', system-ui, sans-serif;
}

.auth-wrapper {
    background: #F4F1EA;
    padding: 8px;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.08);
    border: 0.5px solid rgba(0,0,0,0.08);
    width: 100%;
    max-width: 380px; 
    box-sizing: border-box; /* Kluczowe! */
}

.auth-card { 
    background: #fff; 
    padding: 40px 32px; 
    border-radius: 12px; 
    border: 0.5px solid rgba(0,0,0,0.04); 
    width: 100%; 
    box-sizing: border-box; /* Kluczowe! */
}

.auth-card form {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.inp-group { 
    margin-bottom: 16px; 
    width: 100%; 
    text-align: left; 
}

.inp-label { 
    display: block; 
    font-size: 11px; 
    color: #78716c; 
    font-weight: 500; 
    margin-bottom: 6px; 
}

.inp { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid rgba(0,0,0,0.1); 
    border-radius: 6px; 
    font-family: inherit; 
    font-size: 13px;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: block;
    box-sizing: border-box; /* Gwarancja, że nie wyjdzie poza formularz */
}

.inp:focus { 
    outline: none; 
    border-color: #2F5D50; 
    box-shadow: 0 0 0 3px rgba(47,93,80,0.1); 
}

/* Wymuszenie zachowania pełnego bloku dla przycisków wewnątrz Auth */
.auth-card .btn {
    width: 100%; 
    display: flex; 
    justify-content: center;
    align-items: center;
    font-size: 13px; 
    padding: 12px; 
    font-weight: 500;
    text-decoration: none;
    margin-top: 8px;
    box-sizing: border-box; /* Gwarancja zrównania z inputem */
}

.auth-links { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    margin-top: 24px; 
    text-align: center; 
}

.auth-link { 
    font-size: 11px; 
    color: #78716c; 
    text-decoration: none; 
    transition: color 0.1s; 
}

.auth-link:hover { 
    color: #1c1917; 
    text-decoration: underline; 
}