@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Sora:wght@600;700;800&display=swap');

/* ✦ BudIQ — Design System (na bazie Maat Tools z ModułHandlowy) ✦
   Motyw: budownictwo — granatowy sidebar, akcent amber/orange (hi-vis), stal-niebieski. */
:root {
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    --bg-sidebar-hover: rgba(255,255,255,.08);
    --bg-sidebar-active: rgba(245,158,11,.22);
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --accent-gradient: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
    --steel: #0ea5e9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
    --radius: 12px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

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

body {
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
    overflow-y: auto;
}

.app-sidebar .sidebar-brand {
    padding: 1.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.app-sidebar .sidebar-brand-icon--svg {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    filter: drop-shadow(0 0 10px rgba(251,191,36,0.35));
}
.app-sidebar .sidebar-brand-icon--svg svg { width: 100%; height: 100%; }

.app-sidebar .sidebar-brand-text {
    font-family: 'Sora', 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: .04em;
    line-height: 1;
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 60%, #f97316 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-sidebar .sidebar-brand-sub {
    font-size: .7rem;
    color: var(--text-sidebar);
    font-weight: 400;
    display: block;
    margin-top: .15rem;
}

.sidebar-nav {
    list-style: none;
    padding: .75rem .625rem;
    margin: 0;
    flex: 1;
}
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    border-radius: 8px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: all var(--transition);
}
.sidebar-nav a:hover { background: var(--bg-sidebar-hover); color: #fff; }
.sidebar-nav a.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.sidebar-nav .nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .8; font-size: 1.05rem; line-height: 1; }
.sidebar-nav a.active .nav-icon, .sidebar-nav a:hover .nav-icon { opacity: 1; }
.sidebar-nav .nav-badge {
    margin-left: auto;
    background: var(--accent-gradient);
    color: #1f2937;
    font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 10px;
    min-width: 20px; text-align: center;
}
.nav-section-label {
    padding: 1rem 1rem .35rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: #64748b;
    font-weight: 700;
}

.sidebar-bottom {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .25rem .75rem;
    color: var(--text-sidebar);
}
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--accent-gradient);
    color: #1f2937; font-weight: 800; font-size: .9rem;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-user-name { font-size: .82rem; font-weight: 600; color: #fff; line-height: 1.1; }
.sidebar-user-role { font-size: .7rem; color: var(--text-sidebar); }
.sidebar-bottom .btn-logout {
    display: flex; align-items: center; gap: .5rem;
    width: 100%; padding: .5rem 1rem;
    border: none; border-radius: 8px;
    background: rgba(239,68,68,.15); color: #fca5a5;
    font-size: .85rem; font-weight: 500; cursor: pointer;
    transition: all var(--transition);
}
.sidebar-bottom .btn-logout:hover { background: rgba(239,68,68,.3); color: #fff; }

/* ===== Main content ===== */
.app-main {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition);
}
.app-topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 1020;
    backdrop-filter: blur(8px);
}
.app-topbar h1 { font-size: 1.35rem; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.app-content { padding: 1.5rem 2rem 3rem; max-width: 1400px; }

/* ===== Cards ===== */
.page-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.page-card:hover { box-shadow: var(--shadow-md); }
.page-card h5 {
    font-size: 1rem; font-weight: 700; color: var(--text-primary);
    margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem;
}
.card-icon { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; flex-shrink: 0; }
.card-icon-blue   { background: #eff6ff; color: #3b82f6; }
.card-icon-green  { background: #f0fdf4; color: #22c55e; }
.card-icon-amber  { background: #fff7ed; color: #f97316; }
.card-icon-steel  { background: #f0f9ff; color: #0ea5e9; }
.card-icon-purple { background: #faf5ff; color: #a855f7; }

/* ===== Stat tiles ===== */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; display: flex; align-items: flex-start; gap: 1rem;
    box-shadow: var(--shadow-sm); transition: all var(--transition);
}
.stat-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-tile-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.stat-tile-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-tile-label { font-size: .8rem; color: var(--text-secondary); margin-top: .15rem; }

/* ===== Buttons ===== */
.btn { border-radius: 8px; font-weight: 500; font-size: .85rem; padding: .45rem 1rem; transition: all var(--transition); }
.btn-primary { background: var(--accent-gradient); border: none; color: #1f2937; }
.btn-primary:hover { opacity: .92; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(245,158,11,.35); color: #1f2937; }
.btn-outline-primary { border-color: var(--accent); color: #b45309; }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); color: #1f2937; }
.btn-sm { font-size: .78rem; padding: .3rem .65rem; border-radius: 6px; }

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 8px; border: 1px solid var(--border);
    font-size: .9rem; padding: .55rem .8rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: .3rem; }

/* ===== Alerts / badges ===== */
.alert { border-radius: 10px; font-size: .85rem; border: none; padding: .75rem 1rem; }
.alert-info { background: #eff6ff; color: #1e40af; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.badge { font-weight: 500; font-size: .72rem; padding: .3em .6em; border-radius: 6px; }

.small-muted { color: var(--text-secondary); font-size: .85rem; }

/* ============================================================
   ✦ Auth (login / rejestracja) — pełnoekranowa scena
   ============================================================ */
.auth-stage {
    position: fixed; inset: 0; overflow: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(245,158,11,0.22), transparent 60%),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(14,165,233,0.20), transparent 60%),
        linear-gradient(155deg, #050714 0%, #0a0e27 35%, #0b1a2e 70%, #050714 100%);
    color: #e5e7eb;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5; mix-blend-mode: screen; animation: orbFloat 22s ease-in-out infinite; }
.auth-orb--gold  { width: 520px; height: 520px; background: radial-gradient(circle, #fbbf24 0%, #f97316 40%, transparent 70%); top: -120px; left: -100px; animation-delay: -3s; }
.auth-orb--steel { width: 600px; height: 600px; background: radial-gradient(circle, #38bdf8 0%, #0ea5e9 40%, transparent 70%); bottom: -180px; right: -140px; animation-delay: -11s; }
.auth-orb--amber { width: 380px; height: 380px; background: radial-gradient(circle, #f59e0b 0%, #d97706 40%, transparent 70%); top: 45%; left: 55%; opacity: .3; animation-delay: -7s; animation-duration: 28s; }
@keyframes orbFloat { 0%,100% { transform: translate(0,0) scale(1); } 33% { transform: translate(60px,-40px) scale(1.08); } 66% { transform: translate(-50px,30px) scale(.94); } }
.auth-grid {
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    -webkit-mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, #000 30%, transparent 80%);
    mask-image: radial-gradient(ellipse 60% 70% at 50% 50%, #000 30%, transparent 80%);
}

.auth-card {
    position: relative; width: 100%; max-width: 460px;
    padding: 2.75rem 2.5rem 2rem; border-radius: 24px;
    background: linear-gradient(160deg, rgba(30,41,59,0.55) 0%, rgba(15,23,42,0.65) 100%);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04), inset 0 1px 0 rgba(255,255,255,0.08);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    z-index: 2;
    animation: cardRise 0.8s cubic-bezier(.16,.84,.3,1) both;
}
@keyframes cardRise { from { opacity: 0; transform: translateY(20px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.auth-card.shake { animation: cardShake .45s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes cardShake { 10%,90% { transform: translateX(-3px); } 20%,80% { transform: translateX(5px); } 30%,50%,70% { transform: translateX(-8px); } 40%,60% { transform: translateX(8px); } }
.auth-card-glow { position: absolute; top: 0; left: 50%; width: 70%; height: 1px; background: linear-gradient(90deg, transparent, rgba(251,191,36,0.6), transparent); transform: translateX(-50%); box-shadow: 0 0 18px rgba(251,191,36,0.5); }

.auth-brand { text-align: center; margin-bottom: 1.75rem; }
.auth-logo { width: 92px; height: 92px; margin: 0 auto .9rem; filter: drop-shadow(0 0 24px rgba(251,191,36,0.45)) drop-shadow(0 6px 14px rgba(0,0,0,0.45)); animation: logoPulse 4s ease-in-out infinite; }
.auth-logo svg { width: 100%; height: 100%; display: block; }
@keyframes logoPulse { 0%,100% { filter: drop-shadow(0 0 24px rgba(251,191,36,0.45)) drop-shadow(0 6px 14px rgba(0,0,0,0.45)); } 50% { filter: drop-shadow(0 0 38px rgba(251,191,36,0.7)) drop-shadow(0 6px 14px rgba(0,0,0,0.45)); } }
.auth-wordmark {
    font-family: 'Sora', 'Inter', sans-serif; font-size: 2.4rem; font-weight: 800; letter-spacing: .04em; margin: 0;
    background: linear-gradient(180deg, #fde68a 0%, #fbbf24 55%, #f97316 100%);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.auth-tagline { margin: .35rem 0 .15rem; font-size: .68rem; letter-spacing: .38em; text-transform: uppercase; color: rgba(56,189,248,0.85); font-weight: 600; }
.auth-sub { margin: 0; font-size: .82rem; color: rgba(229,231,235,0.55); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1.25rem; }
.auth-field { position: relative; display: flex; align-items: center; }
.auth-field-icon { position: absolute; left: 1rem; width: 18px; height: 18px; color: rgba(251,191,36,0.75); pointer-events: none; z-index: 2; transition: color .2s ease; }
.auth-field-icon svg { width: 100%; height: 100%; }
.auth-input {
    width: 100%; padding: 1.55rem 1rem .55rem 2.85rem;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px; color: #fff; font-size: .95rem; font-family: inherit;
    outline: none; line-height: 1.2; transition: all .25s cubic-bezier(.4,0,.2,1);
}
.auth-input:hover { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.18); }
.auth-input:focus { background: rgba(15,23,42,0.6); border-color: rgba(251,191,36,0.55); box-shadow: 0 0 0 4px rgba(251,191,36,0.12), 0 0 24px -4px rgba(251,191,36,0.35); }
.auth-label { position: absolute; left: 2.85rem; top: 50%; transform: translateY(-50%) scale(1); transform-origin: left top; color: rgba(229,231,235,0.55); font-size: .9rem; font-weight: 500; pointer-events: none; transition: all .2s cubic-bezier(.4,0,.2,1); }
.auth-input:focus + .auth-label, .auth-input:not(:placeholder-shown) + .auth-label { top: .45rem; transform: translateY(0) scale(.72); color: #fbbf24; letter-spacing: .06em; font-weight: 600; }
.auth-field:has(.auth-input:focus) .auth-field-icon { color: #fbbf24; }

.auth-submit {
    position: relative; overflow: hidden; margin-top: .35rem; padding: .95rem 1.25rem;
    border: none; border-radius: 12px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 40%, #f97316 100%);
    color: #0f172a; font-size: .92rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .65rem;
    box-shadow: 0 10px 28px -6px rgba(245,158,11,0.5), 0 0 0 1px rgba(255,255,255,0.15) inset;
    transition: all .3s cubic-bezier(.4,0,.2,1);
}
.auth-submit:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px rgba(245,158,11,0.65), 0 0 0 1px rgba(255,255,255,0.25) inset; }
.auth-submit:active { transform: translateY(0); }
.auth-submit-arrow { transition: transform .3s cubic-bezier(.4,0,.2,1); font-size: 1.15rem; line-height: 1; }
.auth-submit:hover .auth-submit-arrow { transform: translateX(4px); }
.auth-submit-shine { position: absolute; top: 0; left: -100%; width: 60%; height: 100%; background: linear-gradient(110deg, transparent, rgba(255,255,255,0.45), transparent); transition: left .7s ease; }
.auth-submit:hover .auth-submit-shine { left: 130%; }
.auth-submit.is-loading { pointer-events: none; opacity: .75; }
.auth-submit.is-loading .auth-submit-text::after { content: '...'; display: inline-block; animation: dots 1s steps(4, end) infinite; }
@keyframes dots { 0%,20% { content: '.'; } 40% { content: '..'; } 60% { content: '...'; } 80%,100% { content: ''; } }

.auth-switch { text-align: center; font-size: .85rem; color: rgba(229,231,235,0.6); margin-bottom: 1rem; }
.auth-switch a { color: #fbbf24; text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

.auth-footer { display: flex; align-items: center; justify-content: center; gap: .45rem; font-size: .72rem; color: rgba(229,231,235,0.45); text-align: center; }
.auth-lock svg { width: 12px; height: 12px; vertical-align: middle; color: rgba(251,191,36,0.7); }
.auth-version { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); font-size: .7rem; letter-spacing: .25em; color: rgba(229,231,235,0.3); text-transform: uppercase; z-index: 2; }
.auth-alert { background: rgba(239,68,68,0.12) !important; border: 1px solid rgba(239,68,68,0.3) !important; color: #fecaca !important; font-size: .82rem; padding: .65rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.auth-alert.auth-alert-ok { background: rgba(34,197,94,0.12) !important; border-color: rgba(34,197,94,0.3) !important; color: #bbf7d0 !important; }

@media (max-width: 520px) {
    .auth-card { padding: 2rem 1.5rem 1.5rem; border-radius: 20px; }
    .auth-wordmark { font-size: 1.9rem; }
    .auth-logo { width: 78px; height: 78px; }
}

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-secondary); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .5; }
.empty-state-text { font-size: .9rem; }

/* ===== Dashboard ===== */
.dash-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 55%, #0ea5e9 130%);
    border-radius: var(--radius-lg); padding: 2rem 2.25rem; color: #fff;
    position: relative; overflow: hidden; margin-bottom: 1.5rem;
    box-shadow: 0 12px 32px -12px rgba(14,165,233,.35);
}
.dash-hero::after { content: ''; position: absolute; inset: -40% -20% auto auto; width: 380px; height: 380px; background: radial-gradient(circle, rgba(251,191,36,.35), transparent 60%); pointer-events: none; }
.dash-hero-eyebrow { text-transform: uppercase; letter-spacing: .15em; font-size: .7rem; color: rgba(255,255,255,.65); margin-bottom: .35rem; }
.dash-hero h1 { font-family: 'Sora','Inter',sans-serif; font-size: 1.85rem; font-weight: 800; margin: 0 0 .35rem; letter-spacing: -.02em; }
.dash-hero-sub { font-size: .95rem; color: rgba(255,255,255,.78); margin: 0; }
.dash-hero-meta { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; font-size: .78rem; }
.dash-hero-chip { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); padding: .25rem .65rem; border-radius: 999px; backdrop-filter: blur(6px); }

.dash-shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .85rem; margin-bottom: 1.5rem; }
.dash-shortcut {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: .85rem;
    text-decoration: none; color: inherit; box-shadow: var(--shadow-sm); transition: all var(--transition);
    position: relative;
}
.dash-shortcut:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent-light); color: inherit; }
.dash-shortcut.is-soon { opacity: .72; }
.dash-shortcut-icon { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.dash-shortcut-name { font-weight: 700; font-size: 1rem; }
.dash-shortcut-desc { font-size: .78rem; color: var(--text-secondary); margin-top: .1rem; }
.dash-soon-badge { position: absolute; top: .65rem; right: .65rem; font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: #fef3c7; color: #92400e; padding: .1rem .45rem; border-radius: 999px; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .app-content { padding: 1rem; }
    .topbar-toggle { display: inline-flex !important; }
}
.topbar-toggle { display: none; background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .6rem; cursor: pointer; font-size: 1.1rem; }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
