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

:root {
    --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --color-primary: #667eea;
    --color-primary-dark: #5566c8;
    --color-text: #1a1a2e;
    --color-muted: #4a4a6a;
    --color-bg: #f5f6fb;
    --color-card: rgba(255, 255, 255, 0.95);
    --color-border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(31, 38, 135, 0.08);
    --shadow-md: 0 8px 32px rgba(31, 38, 135, 0.12);
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
}

html, body {
    font-family: 'Inter', sans-serif;
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

/* ===== Login page ===== */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    padding: 1rem;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.login-logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: 0.5px;
}

.login-logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-muted);
    margin-bottom: 0.375rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.btn-login {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-login:hover:not(:disabled) {
    opacity: 0.92;
}

.btn-login:active:not(:disabled) {
    transform: scale(0.98);
}

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

.error-msg {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #dc2626;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

/* ===== App / landing page ===== */
.app-body {
    min-height: 100vh;
    background: var(--color-bg);
}

.app-header {
    background: white;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.header-brand .login-logo-icon {
    width: 36px;
    height: 36px;
    font-size: 0.875rem;
    border-radius: 9px;
}

.header-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
}

.header-chat-slot {
    flex: 1;
    display: flex;
    justify-content: center;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.user-name {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-muted);
}

.btn-logout {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--color-muted);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--color-text);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-primary {
    padding: 0.5rem 1.125rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { opacity: 0.92; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Kiemelt "Chat mobil app letöltése" gomb */
.btn-install {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45);
    animation: btn-install-pulse 2.4s ease-in-out infinite;
}

.btn-install svg {
    flex-shrink: 0;
}

.btn-install:hover {
    animation: none;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.55);
}

@keyframes btn-install-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45); }
    50% { box-shadow: 0 4px 22px rgba(102, 126, 234, 0.75); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-install { animation: none; }
}

.btn-danger {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.16);
    color: #991b1b;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--color-primary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    text-decoration: underline;
}
.btn-link:hover { color: var(--color-primary-dark); }

.app-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.welcome {
    margin-bottom: 2.5rem;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.welcome-sub {
    font-size: 1.0625rem;
    color: var(--color-muted);
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.125rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.2s, border-color 0.15s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.card-icon-img {
    width: 100%;
    height: 100%;
    border-radius: 14px;
    object-fit: cover;
    display: block;
}

.cards-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--color-muted);
    padding: 2.5rem 1rem;
    background: white;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
}
.cards-placeholder a { color: var(--color-primary); }

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

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.card-desc {
    font-size: 0.875rem;
    color: var(--color-muted);
    line-height: 1.4;
}

.card-arrow {
    font-size: 1.25rem;
    color: var(--color-muted);
    transition: transform 0.15s, color 0.15s;
    flex-shrink: 0;
}

.card:hover .card-arrow {
    transform: translateX(3px);
    color: var(--color-primary);
}

/* ===== Admin (dev) page ===== */
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.admin-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.admin-row {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.admin-row .card-icon {
    border-radius: 12px;
}

.admin-row-meta {
    flex: 1;
    min-width: 0;
}

.admin-row-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.125rem;
}

.admin-row-desc {
    font-size: 0.875rem;
    color: var(--color-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-row-url {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 0.125rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.admin-row-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.modal-card {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}

.modal-card-sm {
    max-width: 420px;
}

.modal-header {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
}
.modal-close:hover { background: var(--color-bg); }

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    background: #fafbfc;
}

.req { color: #dc2626; }

/* ===== Icon picker ===== */
.icon-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    background: var(--color-bg);
    border-radius: 0.625rem;
    padding: 0.25rem;
    width: fit-content;
}

.icon-tab {
    background: transparent;
    border: none;
    padding: 0.4rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--color-muted);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.icon-tab.active {
    background: white;
    color: var(--color-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.icon-panel {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    background: #fafbfc;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.625rem;
}

.preset-tile {
    background: white;
    border: 2px solid transparent;
    border-radius: 0.75rem;
    padding: 0.625rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    font-family: inherit;
}

.preset-tile:hover {
    border-color: rgba(102, 126, 234, 0.4);
}

.preset-tile.selected {
    border-color: var(--color-primary);
    background: rgba(102, 126, 234, 0.05);
}

.preset-tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.preset-tile-icon svg { width: 22px; height: 22px; }

.preset-tile-label {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-align: center;
    line-height: 1.2;
}

.upload-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.upload-status {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

.upload-preview {
    margin-top: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.upload-preview img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--color-border);
}

textarea.form-input {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

@media (max-width: 640px) {
    .header-inner {
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    .header-chat-slot {
        display: none;
    }
    .user-name {
        display: none;
    }
    .app-main {
        padding: 2rem 1rem;
    }
    .welcome-title {
        font-size: 1.5rem;
    }
    .admin-row {
        flex-wrap: wrap;
    }
    .admin-row-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
