﻿*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.admin-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #f0f2f5;
    color: #1a2b4a;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
}

.sidebar {
    width: 240px;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #0a1d56 0%, #0d2868 100%);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    padding-top: calc(1.25rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-top {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.sidebar-logo {
    background: #e8f4fc;
    border-radius: 10px;
    padding: 0.5rem;
    flex: 1;
    min-width: 0;
}

.sidebar-logo img { width: 100%; display: block; }

.sidebar-close {
    display: none;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-label {
    display: block;
    color: rgba(255,255,255,0.45);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    margin: 1rem 0.5rem 0.5rem;
}

.sidebar-label:first-child { margin-top: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.92rem;
    min-height: 44px;
}

.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: #2c4185; color: #fff; }

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.92rem;
    margin-top: auto;
    min-height: 44px;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 29, 86, 0.5);
    z-index: 190;
    -webkit-tap-highlight-color: transparent;
}

.admin-shell {
    flex: 1;
    min-width: 0;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 150;
    background: #0a1d56;
    color: #fff;
    padding: 0.65rem 1rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.mobile-menu-btn,
.mobile-topbar-brand {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    text-decoration: none;
    flex-shrink: 0;
}

.mobile-topbar-title {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    min-width: 0;
}

.page-title { font-size: 1.65rem; font-weight: 700; color: #0a1d56; margin-bottom: 1.5rem; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header .page-title { margin-bottom: 0; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

.section-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 1.5rem;
}

.section-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.25rem; }
.section-header i { font-size: 1.25rem; color: #1565c0; margin-top: 0.15rem; }
.section-header h2 { font-size: 1.05rem; font-weight: 700; color: #0a1d56; }
.section-header p { font-size: 0.85rem; color: #6b7c93; margin-top: 0.15rem; }

.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

.info-card { border-radius: 12px; padding: 1.1rem 1.25rem; }
.info-card .label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; color: rgba(0,0,0,0.45); margin-bottom: 0.5rem; }
.info-card .value { font-size: 1.15rem; font-weight: 700; color: #0a1d56; word-break: break-word; }
.info-card .value.small { font-size: 0.95rem; font-weight: 600; }
.info-card.ip { background: #e3f2fd; }
.info-card.provider { background: #e8f5e9; }
.info-card.datetime { background: #f5f5f5; }

.link-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.link-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: #fafbfc;
    border: 1px solid #e8ecf0;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    position: relative;
}

.link-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.link-card .ext { position: absolute; top: 0.75rem; right: 0.75rem; color: #9aa8b8; font-size: 0.75rem; }

.link-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1.1rem;
}

.link-icon.evo { background: #1565c0; }
.link-icon.chat { background: #2e7d32; }
.link-icon.n8n { background: #e65100; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: #1565c0; color: #fff; }
.btn-primary:hover { background: #0d47a1; }
.btn-secondary { background: #e8ecf0; color: #1a2b4a; }

.data-panel {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eef1f5;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f5f7fa;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    flex: 1;
    max-width: 360px;
    min-width: 0;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9rem;
    width: 100%;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th {
    text-align: left;
    padding: 0.75rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #9aa8b8;
    background: #fafbfc;
    border-bottom: 1px solid #eef1f5;
}

.data-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #f0f2f5;
    font-size: 0.9rem;
}

.actions { display: flex; gap: 0.5rem; justify-content: flex-end; }

.btn-icon {
    width: 40px; height: 40px; border: none; border-radius: 6px;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    background: #e3f2fd; color: #1565c0;
}

.btn-icon.danger { background: #ffebee; color: #c62828; }

.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #ffebee; color: #c62828; }

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #e8f4fc 0%, #b8daf0 100%);
    padding: 1.5rem;
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(13, 71, 161, 0.15);
}

.login-card img { display: block; max-width: 280px; width: 100%; height: auto; margin: 0 auto 1.5rem; }
.login-card h1 { font-size: 1.2rem; text-align: center; color: #0a1d56; margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: #4a5d78; margin-bottom: 0.35rem; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.7rem 0.75rem;
    min-height: 44px;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    font-size: 16px;
}

.login-error { background: #ffebee; color: #c62828; padding: 0.6rem 0.85rem; border-radius: 8px; font-size: 0.85rem; margin-bottom: 1rem; }
.btn-block { width: 100%; justify-content: center; margin-top: 0.5rem; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 29, 86, 0.45);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    width: 100%;
    max-width: 440px;
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
}

.modal h3 { font-size: 1.1rem; color: #0a1d56; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }
.empty-state { padding: 2rem; text-align: center; color: #9aa8b8; }

@media (max-width: 900px) {
    .sidebar {
        width: min(300px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0,0,0,0.25);
    }

    .sidebar-close { display: inline-flex; }

    .sidebar-overlay {
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .admin-shell { margin-left: 0; }

    .mobile-topbar { display: flex; }

    .main-content {
        padding: 1rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    }

    .page-title { font-size: 1.35rem; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header .btn,
    .page-header .page-header-actions {
        width: 100%;
    }

    .page-header-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .page-header-actions .btn,
    .page-header-actions .btn-primary,
    .page-header-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .section-card { padding: 1.1rem; }

    .info-cards,
    .link-cards {
        grid-template-columns: 1fr;
    }

    .search-box { max-width: none; width: 100%; }

    .panel-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .data-panel { border-radius: 12px; }

    .table-scroll,
    .data-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-actions { justify-content: stretch; }
    .modal-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 430px) {
    .main-content { padding: 0.85rem; }
    .login-card { padding: 1.35rem; }
    .login-card img { max-width: 220px; }
}
