.addon-card {
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: rgba(0, 0, 0, 0.1);
}

.addon-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
    transition: margin-bottom 0.2s;
}

.addon-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.addon-fields {
    margin-top: 12px;
}


:root {
    --bg: #0d0d12;
    --surface: rgba(30, 30, 42, 0.75);
    --surface-border: rgba(255, 255, 255, 0.09);
    --accent: #bb86fc;
    --accent-hover: #9965f4;
    --accent-dim: rgba(187, 134, 252, 0.12);
    --text-primary: #f0f0f5;
    --text-secondary: rgba(240, 240, 245, 0.55);
    --danger: #ec4a6b;
    --success: #4caf85;
    --radius: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(ellipse at 80% 0%, rgba(187, 134, 252, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 10% 90%, rgba(100, 80, 220, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

/* ── Glass ── */
.glass-panel {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

/* ── Header ── */
header {
    padding: 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(13, 13, 18, 0.85);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Buttons ── */
button {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

button:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(187, 134, 252, 0.25);
}

button.secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--surface-border);
}

button.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
}

button.danger {
    background: var(--danger);
    color: #fff;
}

button.danger:hover {
    background: #c93a5a;
    box-shadow: 0 4px 12px rgba(236, 74, 107, 0.3);
}

button.small {
    padding: 7px 13px;
    font-size: 0.82rem;
}

.danger-text {
    color: var(--danger) !important;
}

/* ── Inputs ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select.styled-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

select.styled-select {
    cursor: pointer;
    background: rgba(0, 0, 0, 0.3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none;
}

select.styled-select option {
    background: #1a1a2a;
}

input[type="color"].colour-input {
    width: 44px;
    height: 44px;
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--surface-border);
    background: transparent;
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ── Layout ── */
.container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 20px;
    width: 100%;
    flex: 1;
}

.view {
    display: none;
    animation: fadeIn 0.35s ease forwards;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Auth ── */
.auth-panel {
    max-width: 420px;
    margin: 80px auto;
    text-align: center;
}

.auth-panel h2 {
    margin-bottom: 8px;
}

.error-message {
    color: var(--danger);
    font-size: 0.9rem;
    margin-bottom: 16px;
    min-height: 20px;
}

/* ── Dashboard ── */
#dashboardView {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-secondary);
    padding: 4px 8px;
    margin-top: 4px;
}

.nav-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left: 2px solid var(--accent);
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* ── Sync Bar ── */
.sync-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.sync-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* ── Tab Header ── */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.tab-title {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* ── Settings Groups ── */
.settings-group {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.settings-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 14px;
}

.field-row {
    margin-bottom: 14px;
}

.field-row:last-child {
    margin-bottom: 0;
}

.field-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.field-badge {
    display: inline-block;
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 6px;
}

/* ── Toggle Rows ── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--surface-border);
}

.toggle-row:last-child {
    border-bottom: none;
}

.toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.toggle-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    cursor: pointer;
    transition: background 0.25s;
}

.slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s, box-shadow 0.25s;
}

.toggle-switch input:checked+.slider {
    background: var(--accent);
}

.toggle-switch input:checked+.slider::before {
    transform: translateX(20px);
    box-shadow: 0 0 8px rgba(187, 134, 252, 0.5);
}

/* ── Theme Picker ── */
.theme-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0;
}

.theme-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
}

.theme-swatch:hover {
    transform: scale(1.15);
}

.theme-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

/* ── Manifests ── */
.manifest-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--surface-border);
}

.manifest-row:last-child {
    border-bottom: none;
}

.manifest-url {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex: 1;
    word-break: break-all;
}

/* ── Data Grid ── */
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.data-card {
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid var(--surface-border);
    transition: border-color 0.2s, transform 0.2s;
}

.data-card:hover {
    transform: translateY(-2px);
    border-color: rgba(187, 134, 252, 0.3);
}

.data-card h4 {
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 0.95rem;
    word-break: break-all;
}

.data-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.data-card .actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

/* Device cards */
.device-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.device-icon {
    font-size: 2rem;
    color: var(--accent);
    flex-shrink: 0;
}

.device-info {
    flex: 1;
}

/* ── Loader ── */
#loader {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#loader.show {
    opacity: 1;
    pointer-events: all;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(40, 40, 60, 0.95);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(12px);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

.toast.error {
    border-color: var(--danger);
    color: var(--danger);
}

h3 {
    font-weight: 600;
}

.text-secondary {
    color: var(--text-secondary);
}
