* { box-sizing: border-box; }
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    margin: 0;
    background: #f4f6f9;
    color: #222;
    line-height: 1.4;
}
header {
    background: #1e293b;
    color: white;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.4rem; }
.header-right a, .header-left a {
    color: #93c5fd;
    margin-left: 16px;
    text-decoration: none;
}
.header-right a:hover { text-decoration: underline; }

.user-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}
.user-badge.small { font-size: 0.8rem; padding: 2px 8px; }
.user-badge.tiny { font-size: 0.75rem; padding: 1px 6px; }

.month-nav {
    background: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #e2e8f0;
}
.month-nav a {
    text-decoration: none;
    font-size: 1.4rem;
    color: #334155;
    padding: 4px 12px;
    background: #f1f5f9;
    border-radius: 8px;
}
.working-info { margin-left: auto; color: #64748b; font-size: 0.9rem; }

.balances, .calendar, .chat, .history, .admin-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 16px;
}
.balances h2, .calendar h2, .chat h2 { margin-top: 0; }

.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}
.balance-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.balance-info { margin-top: 8px; font-size: 0.9rem; }
.positive { color: #16a34a; }
.negative { color: #dc2626; }

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.day {
    background: white;
    border-radius: 10px;
    min-height: 120px;
    padding: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.day.empty { background: transparent; box-shadow: none; }
.day.weekend { background: #f8fafc; opacity: 0.7; }
.day-num {
    font-weight: 700;
    margin-bottom: 6px;
    color: #334155;
}
.car {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}
.passengers { margin-top: 4px; }
.full { font-size: 0.75rem; color: #dc2626; margin-top: 6px; }
.declare-form input { margin: 0 4px; }

.btn-small {
    border: none;
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
}
.btn-small.primary { background: #3b82f6; color: white; }
.btn-small.success { background: #16a34a; color: white; }
.btn-small.danger { background: #dc2626; color: white; }
.btn-small:hover { opacity: 0.9; }

.chat-messages {
    background: white;
    border-radius: 12px;
    max-height: 420px; /* ok. 10 wiadomości */
    overflow-y: auto;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chat-msg { 
    margin-bottom: 10px; 
    min-height: 36px;
}
.chat-time { color: #64748b; font-size: 0.75rem; margin-left: 8px; }
.chat-text { margin-top: 4px; }
.chat-form { display: flex; gap: 8px; }
.chat-form textarea { flex: 1; border-radius: 8px; border: 1px solid #cbd5e1; padding: 8px; font-family: inherit; }
.chat-form button { background: #1e293b; color: white; border: none; padding: 0 20px; border-radius: 8px; cursor: pointer; }

.history-user {
    background: white;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.dates { margin-top: 8px; }
.date-chip {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 12px;
    margin: 2px 4px 2px 0;
    font-size: 0.85rem;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b, #334155);
}
.login-box {
    background: white;
    padding: 40px;
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.login-box h1 { text-align: center; margin-top: 0; }
.login-box input[type=text], .login-box input[type=password] {
    width: 100%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
}
.login-box button {
    width: 100%;
    padding: 12px;
    background: #1e293b;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 12px;
}
.remember { display: block; margin: 8px 0; font-size: 0.9rem; }
.error { background: #fee2e2; color: #991b1b; padding: 8px; border-radius: 8px; margin-bottom: 12px; }
.success { background: #dcfce7; color: #166534; padding: 8px 12px; border-radius: 8px; margin-bottom: 16px; }

.admin-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.admin-form input, .admin-form select { padding: 8px; border-radius: 6px; border: 1px solid #cbd5e1; }
.users-table { width: 100%; border-collapse: collapse; background: white; border-radius: 12px; overflow: hidden; }
.users-table th, .users-table td { padding: 10px; text-align: left; border-bottom: 1px solid #e2e8f0; }
.users-table th { background: #f8fafc; }

.balances-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.balances-header h2 { margin: 0; }
.balance-grid.hidden {
    display: none !important;
}
#toggleBalances { display: none; }

@media (max-width: 700px) {
    #toggleBalances { display: inline-block; }
    .calendar-grid { grid-template-columns: 1fr; }
    .day { min-height: auto; }
    header { flex-direction: column; align-items: flex-start; gap: 8px; }
}
