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

:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-soft: #f1f5f9;
    --ink: #172033;
    --muted: #64748b;
    --line: #dbe3ee;
    --line-strong: #cbd5e1;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-soft: #eff6ff;
    --green: #15805e;
    --amber: #b96b06;
    --red: #b42318;
    --sidebar: #0b1220;
    --sidebar-soft: #172033;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 12px 34px rgba(30, 51, 82, 0.08);
    --shadow-hover: 0 18px 46px rgba(30, 51, 82, 0.13);
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: Inter, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
    letter-spacing: -0.006em;
    background:
        radial-gradient(circle at 82% -10%, rgba(37, 99, 235, 0.08), transparent 34rem),
        var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background:
        radial-gradient(circle at 20% 0, rgba(59, 130, 246, 0.2), transparent 18rem),
        linear-gradient(180deg, var(--sidebar), #101827 72%, #0b1220);
    color: #e5e7eb;
    padding: 24px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 4px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: url("/favicon.svg?v=3") center / contain no-repeat;
    display: grid;
    place-items: center;
    color: transparent;
    font-size: 0;
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 12px rgba(37, 99, 235, 0.3));
}

.brand-mark img {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.brand strong {
    display: block;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.brand span {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: #9ca3af;
}

.nav {
    display: grid;
    gap: 5px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    padding: 10px 12px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 550;
    transition: color .18s ease, background .18s ease, transform .18s ease;
}

.nav a.active,
.nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.105);
    transform: translateX(2px);
}

.nav a.active::before {
    content: "";
    position: absolute;
    left: -6px;
    width: 3px;
    height: 20px;
    border-radius: 4px;
    background: #60a5fa;
}

.nav a.nav-account-start {
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 8px 8px;
    padding-top: 14px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(203, 213, 225, 0.55);
    border-radius: 7px;
    color: #e5e7eb;
    font-size: 11px;
    line-height: 1;
    flex: 0 0 auto;
}

main {
    min-width: 0;
    padding: 30px clamp(20px, 3vw, 42px) 48px;
}

main > * {
    width: min(1500px, 100%);
    margin-left: auto;
    margin-right: auto;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

h1 {
    margin: 0 0 6px;
    font-size: clamp(25px, 2.2vw, 34px);
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.lead {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    box-shadow: 0 7px 18px rgba(30, 51, 82, 0.11);
}

.btn.primary {
    background: linear-gradient(135deg, #3478f6, var(--blue-dark));
    border-color: var(--blue-dark);
    color: #fff;
}

.btn.danger {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
}

.btn.sm {
    padding: 5px 10px;
    min-height: 0;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.status-bar {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    display: none;
}

.status-bar.info {
    background: #eff6ff;
    color: #1d4ed8;
    display: block;
}

.status-bar.ok {
    background: #e7f7ef;
    color: var(--green);
    display: block;
}

.status-bar.error {
    background: #fff1f2;
    color: var(--red);
    display: block;
}

@media (max-width: 900px) {
    .shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
        min-height: auto;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px;
        padding: 14px 16px;
    }

    .sidebar .brand {
        padding: 0;
        border-bottom: 0;
    }

    .sidebar .nav {
        grid-column: 1 / -1;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,.1);
    }

    .sidebar .nav:not(.is-open) {
        display: none;
    }
}

@media (max-width: 620px) {
    main {
        padding: 16px;
    }

    .topbar,
    .panel-title {
        display: grid;
        justify-content: stretch;
    }

    .actions,
    .btn {
        width: 100%;
    }
}

/* Wspolny system komponentow dla wszystkich modulow. */
.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.panel,
.card {
    border-color: var(--line) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}

.card {
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: #c7d7ed !important;
    box-shadow: var(--shadow-hover) !important;
}

input,
select,
textarea {
    border-color: var(--line-strong) !important;
    border-radius: var(--radius-sm) !important;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8 !important;
}

input:focus,
select:focus,
textarea:focus {
    outline: none !important;
    border-color: var(--blue) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .13) !important;
}

.table-wrap {
    border-color: var(--line) !important;
    border-radius: 11px !important;
}

table {
    font-variant-numeric: tabular-nums;
}

th {
    color: #526176 !important;
    background: #f7f9fc !important;
}

tbody tr {
    transition: background .14s ease;
}

tbody tr:hover {
    background: #f8fbff;
}

.status,
.badge {
    letter-spacing: .01em;
}

.caption {
    line-height: 1.55 !important;
}

/* Modul nieruchomosci korzysta z tych samych komponentow i tego arkusza. */
.coverage-note{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:20px;padding:14px 16px;border:1px solid #bfdbfe;border-radius:12px;background:linear-gradient(135deg,#eff6ff,#f8fbff);color:#1e3a8a;font-size:13px;line-height:1.5}
.property-overview{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:20px}.summary-card{display:flex!important;align-items:center;gap:14px;min-height:96px;padding:17px!important}.summary-icon{display:grid;place-items:center;width:44px;height:44px;border-radius:12px;font-size:20px;font-weight:800;flex:0 0 auto}.summary-icon.blue{color:#1d4ed8;background:#dbeafe}.summary-icon.green{color:#167052;background:#dff7ea}.summary-icon.amber{color:#9a5b00;background:#fff1cf}.summary-card>div{display:grid;gap:5px}.summary-label{color:var(--muted);font-size:12px;font-weight:650}.summary-value{font-size:27px;line-height:1;font-variant-numeric:tabular-nums}
.search-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:22px}
.search-card{display:grid;gap:15px;padding:18px;background:#fff;border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease}
.search-card:hover{transform:translateY(-2px);border-color:#c7d7ed;box-shadow:var(--shadow-hover)}
.search-card header{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.search-card h2,.editor h2{margin:0;font-size:17px;letter-spacing:-.02em}.search-card p{margin:0;color:var(--muted);font-size:13px;line-height:1.55}
.badges{display:flex;gap:6px;flex-wrap:wrap}.badge{display:inline-flex;align-items:center;padding:5px 9px;border-radius:999px;background:#eef2f6;color:#475569;font-size:11px;font-weight:750}.badge.active{background:#e7f7ef;color:#167052}.badge.pending{background:#fff7e6;color:#9a5b00}.badge.off{background:#f1f5f9;color:#64748b}.badge.engine-ai{background:#f3e8ff;color:#7e22ce}.badge.engine-auto{background:#dbeafe;color:#1d4ed8}
.card-actions{display:flex;gap:8px}.card-actions .btn{min-height:34px;padding:7px 10px;font-size:12px}.empty-state{grid-column:1/-1;padding:40px;text-align:center;border:1px dashed #bdcadb;border-radius:var(--radius);background:rgba(255,255,255,.78);color:var(--muted)}
.editor{padding:22px}.editor-title{margin-bottom:20px}.caption{margin:5px 0 0;color:var(--muted);font-size:13px}.caption.important{margin:0 0 13px;color:#475569}
.icon-button{width:40px;height:40px;border:1px solid var(--line);border-radius:10px;background:#fff;color:#475569;font-size:24px;line-height:1;cursor:pointer}
#searchForm{display:grid;gap:17px}fieldset{min-width:0;margin:0;padding:17px;border:1px solid var(--line);border-radius:12px;background:#fbfcfe}legend{padding:0 8px;color:#334155;font-size:13px;font-weight:750}
.form-grid{display:grid;gap:13px}.form-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.form-grid.four{grid-template-columns:repeat(4,minmax(0,1fr))}
label{display:grid;align-content:start;gap:7px;color:#334155;font-size:12px;font-weight:700}.wide{grid-column:span 2}input,select,textarea{width:100%;min-height:42px;padding:10px 11px;background:#fff;color:var(--ink)}textarea{min-height:88px;resize:vertical}
.check-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;margin-top:14px}.check-grid label,.toggle{display:flex;align-items:center;gap:8px;min-height:36px;font-weight:500}.check-grid input,.toggle input{width:17px;height:17px;min-height:0;flex:0 0 auto;box-shadow:none!important}
.inline-control{display:flex;gap:7px}.inline-control .btn{min-height:42px}.tag-list{display:flex;gap:7px;flex-wrap:wrap;margin-top:12px}.email-tag{display:inline-flex;align-items:center;gap:7px;padding:6px 9px;border-radius:999px;background:#e8eef8;color:#334155;font-size:12px}.email-tag button{padding:0;border:0;background:transparent;color:#64748b;cursor:pointer;font-size:17px}
.form-actions{display:flex;justify-content:flex-end;gap:9px}.status-bar{margin-bottom:14px}[hidden]{display:none!important}

@media (max-width: 1180px){.search-list{grid-template-columns:repeat(2,minmax(0,1fr))}.form-grid.four{grid-template-columns:repeat(2,minmax(0,1fr))}.check-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media (max-width: 900px){.menu-toggle{display:inline-flex}}
@media (max-width: 720px){.property-overview,.search-list,.form-grid.three,.form-grid.four{grid-template-columns:1fr}.check-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.wide{grid-column:auto}.editor{padding:15px}.form-actions,.card-actions{flex-wrap:wrap}.form-actions .btn{width:100%}}
