:root {
    --primary: #1a1f2a;
    --secondary: #0f1219;
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.3);
    --accent-hover: #60a5fa;
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --warning: #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.4);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.1);
    --glass: rgba(26, 31, 42, 0.6);
    --glass-border: rgba(148, 163, 184, 0.08);
    --surface: rgba(26, 31, 42, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--secondary);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-image:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(59, 130, 246, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(139, 92, 246, 0.06), transparent),
        radial-gradient(ellipse 50% 30% at 50% 90%, rgba(59, 130, 246, 0.04), transparent);
    background-attachment: fixed;
}

/* ═══════════════════════ HEADER ═══════════════════════ */

header {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1rem 2rem;
    padding-top: max(1rem, calc(0.5rem + env(safe-area-inset-top, 0px)));
    padding-left: calc(2rem + env(safe-area-inset-left, 0px));
    padding-right: calc(2rem + env(safe-area-inset-right, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.logo {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.logo-img {
    height: 28px;
    width: auto;
    filter: brightness(0) invert(1);
}

.logo span {
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation links in header */
header nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

header nav a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

header nav a:hover,
header nav a.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.profile-menu {
    position: relative;
}

.profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    user-select: none;
}

.profile-avatar:hover {
    box-shadow: 0 0 16px var(--accent-glow);
    transform: scale(1.05);
}

.profile-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.5rem;
    min-width: 160px;
    display: none;
    z-index: 10;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    animation: dropdownIn 0.2s ease;
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown.show {
    display: block;
}

.profile-dropdown-name {
    padding: 0.6rem 1rem 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}

.profile-dropdown a {
    display: block;
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}

.profile-dropdown a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

/* ═══════════════════════ MAIN ═══════════════════════ */

main {
    max-width: 100%;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex-grow: 1;
}

/* ═══════════════════════ DASHBOARD HEADER ═══════════════════════ */

.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ═══════════════════════ SEARCH BOX ═══════════════════════ */

.search-box {
    position: relative;
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* ═══════════════════════ MONITORS LIST ═══════════════════════ */

.monitors-list {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.monitors-header {
    display: grid;
    grid-template-columns: 30px minmax(120px, 1.2fr) minmax(0, 2fr) 60px 70px 80px 100px 120px;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.monitor-item {
    display: grid;
    grid-template-columns: 30px minmax(120px, 1.2fr) minmax(0, 2fr) 60px 70px 80px 100px 120px;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    align-items: center;
    transition: all 0.2s ease;
}

.monitor-item > div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-item:last-child {
    border-bottom: none;
}

.monitor-item:hover {
    background: rgba(59, 130, 246, 0.04);
}

.monitor-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    font-size: 0.825rem;
}

.monitor-item a:hover {
    color: var(--accent-hover);
}

.monitor-item .red {
    color: var(--danger);
    font-weight: 600;
}

/* ═══════════════════════ STATUS INDICATOR ═══════════════════════ */

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.status-up {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
    animation: pulseGreen 2s ease-in-out infinite;
}

.status-down {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
    animation: pulseRed 1.5s ease-in-out infinite;
}

.status-paused {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning-glow);
}

@keyframes pulseGreen {
    0%, 100% { box-shadow: 0 0 4px var(--success-glow); }
    50% { box-shadow: 0 0 12px var(--success-glow), 0 0 24px rgba(34, 197, 94, 0.15); }
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 4px var(--danger-glow); }
    50% { box-shadow: 0 0 12px var(--danger-glow), 0 0 24px rgba(239, 68, 68, 0.15); }
}

/* ═══════════════════════ NOTIFY ICONS ═══════════════════════ */

.monitor-notify-icons {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.notify-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.notify-icon:hover {
    color: var(--accent-hover);
}

/* ═══════════════════════ ACTIONS ═══════════════════════ */

.monitor-actions {
    display: flex;
    gap: 0.25rem;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

/* ═══════════════════════ MODAL ═══════════════════════ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.close-modal {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* ═══════════════════════ FORMS ═══════════════════════ */

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background-color: rgba(15, 18, 25, 0.6);
    color: var(--text);
    font-size: 0.925rem;
    transition: all 0.2s ease;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder, textarea::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.form-error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.input-error {
    border-color: var(--danger) !important;
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

/* ═══════════════════════ CONFIRM MODAL ═══════════════════════ */

.confirm-modal-content {
    max-width: 400px;
    text-align: center;
    padding: 2.5rem 2rem;
}

.confirm-icon {
    margin-bottom: 1.25rem;
}

.confirm-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.confirm-message {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 100px;
    justify-content: center;
}

.conditional-field {
    padding-left: 1.5rem;
    border-left: 2px solid var(--border);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 2rem;
}

/* ═══════════════════════ BUTTONS ═══════════════════════ */

.btn {
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.875rem;
    border: none;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: white;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(148, 163, 184, 0.2);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 8px;
    white-space: nowrap;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 18, 25, 0.6);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-group:hover {
    border-color: rgba(148, 163, 184, 0.2);
}

.checkbox-group:has(input:checked) {
    border-color: rgba(148, 163, 184, 0.2);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-group label {
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.925rem;
    color: var(--text);
    cursor: pointer;
    flex: 1;
}

/* ═══════════════════════ NTFY SUBSCRIBE PAGE ═══════════════════════ */

.ntfy-list {
    display: grid;
    gap: 0.75rem;
}

.ntfy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ntfy-item:hover {
    border-color: rgba(59, 130, 246, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

.ntfy-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ntfy-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.ntfy-topic-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ntfy-topic {
    color: var(--text-muted);
    font-size: 0.8rem;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.ntfy-copy-btn.copied {
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

.ntfy-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.ntfy-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

/* Hide mobile stats row on desktop */
.monitor-stats-row {
    display: none;
}

/* ═══════════════════════ DASHBOARD ACTIONS ═══════════════════════ */

.dashboard-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ═══════════════════════ FOOTER ═══════════════════════ */

footer a {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--accent);
}

footer {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-muted);
    text-align: center;
    padding: 1rem;
    margin-top: auto;
    border-top: 1px solid var(--glass-border);
    font-size: 0.8rem;
}

/* ═══════════════════════ SCROLLBAR ═══════════════════════ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.35);
}

/* ═══════════════════════ RESPONSIVE ═══════════════════════ */

/* Mobile: Card layout for monitors */
@media (max-width: 639px) {
    header {
        padding: 0.75rem 1rem;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    }

    main {
        margin: 1rem auto;
        padding: 0 0.75rem;
    }

    .dashboard-header h1 {
        font-size: 1.35rem;
    }

    .monitors-header {
        display: none;
    }

    .monitors-list {
        background: none;
        border: none;
        box-shadow: none;
        display: grid;
        gap: 0.75rem;
    }

    .monitor-item {
        display: flex;
        flex-direction: column;
        gap: 0;
        min-width: 0;
        background: var(--surface);
        border: 1px solid var(--glass-border);
        border-radius: 14px;
        padding: 0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        position: relative;
        overflow: hidden;
    }

    .monitor-item:hover {
        border-color: rgba(59, 130, 246, 0.2);
    }

    /* Hide label pseudo-elements */
    .monitor-item > div[data-label]::before {
        display: none;
    }

    /* Card header: name + status dot */
    .monitor-item > div[data-label="Name"] {
        font-weight: 600;
        font-size: 1rem;
        padding: 1.25rem 1.25rem 0.25rem;
        padding-right: 2.5rem;
    }

    .monitor-status {
        position: absolute;
        top: 1.35rem;
        right: 1.25rem;
    }

    /* URL row */
    .monitor-item > div[data-label="URL"] {
        padding: 0.1rem 1.25rem 1rem;
        overflow: hidden;
    }

    .monitor-item > div[data-label="URL"] a {
        font-size: 0.8rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }

    /* Hide desktop-only columns on mobile */
    .monitor-desktop-only {
        display: none !important;
    }

    /* Stats row on mobile */
    .monitor-stats-row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0;
        padding: 0.85rem 1.25rem;
        background: rgba(0, 0, 0, 0.15);
        border-top: 1px solid var(--border);
    }

    .monitor-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }

    .monitor-stat-label {
        font-size: 0.6rem;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        font-weight: 600;
    }

    .monitor-stat-value {
        font-size: 0.85rem;
        font-weight: 600;
    }

    .monitor-stat-value.red {
        color: var(--danger);
    }

    /* Actions bar */
    .monitor-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1.25rem;
        background: rgba(0, 0, 0, 0.15);
        border-top: 1px solid var(--border);
    }

    .action-btn {
        padding: 0.6rem 1.5rem;
        font-size: 0.85rem;
    }

    /* Modal full-screen on mobile */
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 1.5rem;
        padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* ntfy items */
    .ntfy-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (min-width: 640px) {
    header {
        padding: 1rem 2.5rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    main {
        margin: 2.5rem auto;
        padding: 0 2rem;
    }

    .dashboard-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }

    .modal-content {
        padding: 2.5rem;
    }
}

@media (min-width: 1024px) {
    main {
        max-width: 1200px;
    }
}

/* ═══════════════════════ SELECTION ═══════════════════════ */

::selection {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text);
}
