* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --bg: #090b10;
    --panel: #11141b;
    --panel2: #171b24;
    --border: #282e3a;
    --text: #f5f6fa;
    --muted: #929bad;
    --accent: #8b5cf6;
    --accent2: #6d4bea;
    --green: #38d985;
    --red: #ff6470;
    --yellow: #ffcb6b;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 50% -20%, rgba(95, 55, 170, .35), transparent 35%),
        radial-gradient(circle at 100% 0%, rgba(55, 66, 150, .15), transparent 30%),
        var(--bg);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

header {
    height: 76px;
    padding: 0 6%;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(9, 11, 16, .84);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-link {
    text-decoration: none;
}

.brand-logo,
.logo,
.profile-avatar {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), #4f46e5);
    font-weight: 900;
    box-shadow: 0 10px 35px rgba(139, 92, 246, .25);
}

.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
}

.header-user strong {
    color: var(--text);
}

.logout {
    width: auto;
    padding: 9px 13px;
    background: #181c25;
    border: 1px solid var(--border);
}

main {
    width: min(1180px, 90%);
    margin: 50px auto 80px;
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.hero.compact {
    margin-bottom: 22px;
}

.eyebrow {
    display: inline-block;
    color: #aa91ff;
    font-size: 11px;
    letter-spacing: 2px;
    font-weight: 900;
}

.hero h1 {
    margin: 7px 0 8px;
    font-size: clamp(34px, 5vw, 52px);
}

.hero p,
.card p {
    color: var(--muted);
    line-height: 1.6;
}

.connection {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 11px 16px;
    color: var(--muted);
    background: rgba(17, 20, 27, .85);
    font-weight: 800;
    font-size: 12px;
}

.profiles-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.profile-card,
.card {
    border: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(24, 28, 38, .95), rgba(15, 18, 25, .95));
    border-radius: 22px;
    box-shadow: 0 22px 65px rgba(0, 0, 0, .22);
}

.profile-card {
    display: block;
    padding: 25px;
    text-decoration: none;
    transition:
        transform .18s ease,
        border-color .18s ease,
        background .18s ease;
}

.profile-card:hover {
    transform: translateY(-3px);
    border-color: rgba(139, 92, 246, .55);
    background:
        linear-gradient(180deg, rgba(29, 32, 45, .98), rgba(17, 19, 29, .98));
}

.profile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.profile-avatar {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    font-size: 20px;
}

.profile-card h2 {
    margin: 20px 0 8px;
    font-size: 25px;
}

.profile-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 10px;
    background: #11151d;
    font-size: 10px;
    font-weight: 900;
}

.profile-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.profile-status.offline .dot {
    background: var(--red);
    box-shadow: 0 0 10px rgba(255, 100, 112, .6);
}

.profile-status.online .dot {
    background: var(--green);
    box-shadow: 0 0 11px rgba(56, 217, 133, .65);
}

.profile-status.offline {
    color: #ff9098;
}

.profile-status.online {
    color: #78e7a9;
}

.access-badge {
    display: inline-block;
    padding: 6px 9px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .5px;
}

.access-badge.large {
    font-size: 11px;
    padding: 8px 11px;
}

.access-badge.owner {
    color: #bba8ff;
    background: rgba(139, 92, 246, .13);
}

.access-badge.view {
    color: #9ba5b8;
    background: rgba(150, 160, 180, .10);
}

.access-badge.control {
    color: #7ee4ad;
    background: rgba(56, 217, 133, .11);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 25px 0 18px;
}

.stats-row > div {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(10, 12, 18, .45);
}

.stats-row strong,
.stats-row span {
    display: block;
}

.stats-row strong {
    font-size: 20px;
}

.stats-row span {
    color: var(--muted);
    font-size: 10px;
    margin-top: 3px;
}

.mini-settings,
.setting-list {
    border-top: 1px solid var(--border);
    padding-top: 13px;
}

.mini-settings > div,
.setting-list > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    color: var(--muted);
    font-size: 12px;
}

.mini-settings strong,
.setting-list strong {
    color: var(--text);
}

.open-profile {
    margin-top: 17px;
    color: #b39cff;
    font-size: 12px;
    font-weight: 800;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.section-gap {
    margin-top: 18px;
}

.card {
    padding: 25px;
}

.card h2 {
    margin: 7px 0 18px;
}

.notice,
.empty {
    padding: 14px;
    border: 1px dashed #313747;
    border-radius: 12px;
    background: rgba(10, 12, 18, .45);
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.device-list,
.messages-list {
    display: grid;
    gap: 10px;
}

.device-item,
.message-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px;
    border-radius: 13px;
    border: 1px solid var(--border);
    background: rgba(9, 11, 16, .52);
}

.device-item strong,
.device-item span,
.message-row strong,
.message-row p,
.message-row small {
    display: block;
}

.device-item span,
.message-row p,
.message-row small {
    color: var(--muted);
}

.device-item span {
    font-size: 11px;
    margin-top: 3px;
}

.message-row {
    justify-content: flex-start;
    align-items: flex-start;
}

.message-row p {
    margin: 4px 0 0;
    font-size: 12px;
}

.message-row small {
    margin-top: 4px;
    font-size: 10px;
}

.message-state {
    min-width: 38px;
    padding: 5px 6px;
    border-radius: 7px;
    text-align: center;
    color: #ff9098;
    background: rgba(255, 100, 112, .10);
    font-size: 9px;
    font-weight: 900;
}

.message-state.enabled {
    color: #7ee4ad;
    background: rgba(56, 217, 133, .10);
}

.sender-avatar {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #202634;
    font-weight: 900;
}

button {
    border: 0;
    border-radius: 11px;
    padding: 13px;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: min(430px, 100%);
    padding: 38px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: rgba(17, 20, 27, .95);
    box-shadow: 0 35px 120px rgba(0, 0, 0, .48);
}

.logo {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    margin-bottom: 24px;
}

.login-card h1 {
    margin: 7px 0;
}

.muted {
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 25px;
}

label {
    display: block;
    margin: 12px 0 7px;
    font-size: 12px;
    font-weight: 800;
}

input {
    width: 100%;
    padding: 14px;
    color: #fff;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #0c0f15;
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .09);
}

.login-card button {
    width: 100%;
    margin-top: 17px;
}

.error {
    margin: 18px 0;
    padding: 11px 12px;
    border-radius: 10px;
    color: #ff9ba2;
    background: rgba(255, 100, 112, .10);
}

.secure {
    margin-top: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 10px;
}

@media (max-width: 800px) {
    header {
        height: auto;
        min-height: 72px;
        padding: 13px 5%;
    }

    .header-user > span {
        display: none;
    }

    main {
        width: 92%;
        margin-top: 32px;
    }

    .hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .profiles-grid,
    .grid.two {
        grid-template-columns: 1fr;
    }

    .profile-card,
    .card {
        border-radius: 18px;
    }
}


.sync-time {
    margin-top: 10px;
    color: var(--muted);
    font-size: 10px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
}

.section-title h2 {
    margin: 6px 0 0;
}

.counter {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 30px;
    padding: 0 9px;
    border-radius: 10px;
    background: rgba(139, 92, 246, .12);
    color: #baa8ff;
    font-size: 12px;
    font-weight: 900;
}

.message-body {
    min-width: 0;
    flex: 1;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.details-grid > div {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(9, 11, 16, .5);
}

.details-grid span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .8px;
}

.details-grid p {
    margin: 6px 0 0;
    color: var(--text);
    word-break: break-word;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
}

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


/* =========================================================
   v4 - edycja konfiguracji z WWW
   ========================================================= */

.hidden {
    display: none !important;
}

.save-status {
    position: sticky;
    top: 88px;
    z-index: 40;
    margin: 0 0 18px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(17, 20, 27, .96);
    box-shadow: 0 15px 45px rgba(0, 0, 0, .28);
    font-size: 12px;
    font-weight: 800;
}

.save-status.ok {
    color: #86eab1;
    border-color: rgba(56, 217, 133, .35);
}

.save-status.warning {
    color: #ffd47f;
    border-color: rgba(255, 203, 107, .35);
}

.save-status.error {
    color: #ff9ca4;
    border-color: rgba(255, 100, 112, .38);
}

.save-status.working {
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, .38);
}

.btn {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
}

.btn.small {
    padding: 8px 11px;
    border-radius: 9px;
    font-size: 11px;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.btn.secondary {
    color: #d9dce5;
    border-color: var(--border);
    background: #171b24;
}

.btn.secondary:hover {
    border-color: rgba(139, 92, 246, .5);
}

.btn:disabled {
    opacity: .55;
    cursor: wait;
}

.quick-actions {
    display: flex;
    gap: 8px;
}

.editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.field {
    display: block;
    margin: 0;
}

.field.full {
    grid-column: 1 / -1;
}

.field > span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.field > small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 10px;
}

.field input,
.field textarea,
.ad-editor-row textarea,
.reply-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: #0c0f15;
    color: var(--text);
    outline: none;
}

.field input,
.reply-input {
    padding: 11px 12px;
}

.field textarea,
.ad-editor-row textarea {
    padding: 12px;
    resize: vertical;
    line-height: 1.5;
}

.field input:focus,
.field textarea:focus,
.ad-editor-row textarea:focus,
.reply-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .09);
}

.switch-row {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 0;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(9, 11, 16, .48);
}

.switch-row.compact-switch {
    grid-column: auto;
}

.switch-row strong,
.switch-row small {
    display: block;
}

.switch-row small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.switch-row input[type="checkbox"],
.inline-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.ads-editor {
    display: grid;
    gap: 11px;
}

.ad-editor-row {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 13px;
    background: rgba(9, 11, 16, .5);
}

.ad-editor-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    color: #86eab1;
    font-size: 10px;
    font-weight: 900;
}

.ad-number {
    font-size: 12px;
}

.icon-button {
    width: auto;
    padding: 7px 9px;
    border: 1px solid rgba(255, 100, 112, .22);
    border-radius: 8px;
    background: rgba(255, 100, 112, .08);
    color: #ff9ba2;
    font-size: 10px;
}

.sticky-save {
    position: sticky;
    bottom: 14px;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 18px 0;
    padding: 15px 17px;
    border: 1px solid rgba(139, 92, 246, .32);
    border-radius: 16px;
    background: rgba(15, 18, 25, .94);
    backdrop-filter: blur(18px);
    box-shadow: 0 22px 60px rgba(0, 0, 0, .34);
}

.sticky-save strong,
.sticky-save span {
    display: block;
}

.sticky-save span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.reply-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.reply-input {
    flex: 1;
    min-width: 0;
}

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

    .switch-row.compact-switch,
    .field.full {
        grid-column: 1;
    }

    .sticky-save {
        align-items: stretch;
        flex-direction: column;
        bottom: 8px;
    }

    .sticky-save .btn {
        width: 100%;
    }

    .reply-box {
        align-items: stretch;
        flex-direction: column;
    }

    .reply-box .btn {
        width: 100%;
    }

    .ad-editor-head {
        grid-template-columns: auto 1fr;
    }

    .ad-editor-head .icon-button {
        grid-column: 1 / -1;
    }
}
