* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f8f9fa;
    color: #212529;
    height: 100vh;
    overflow: hidden;
}

#loginPage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: #e9ecef;
}

.login-logo {
    max-width: 200px;
    max-height: 100px;
    width: auto;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
    border-radius: 50px;
}

.login-container {
    background: #ffffff;
    padding: 20px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    width: 400px;
    border: 2px solid #dee2e6;
}

.login-container h1 {
    margin: 0 0 8px 0;
    text-align: center;
    color: #495057;
    font-size: 26px;
    font-weight: 500;
}

.login-container h2 {
    margin: 0 0 24px 0;
    text-align: center;
    color: #495057;
    font-size: 24px;
    font-weight: 600;
}

.login-container input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    background: #f8f9fa;
    color: #212529;
}

.login-container input:focus {
    outline: none;
    border-color: #0d6efd;
    background: #ffffff;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-container button:hover {
    background: #0b5ed7;
}

#appPage {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background: #ffffff;
    border-bottom: 2px solid #e9ecef;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 56px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-buttons-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.nav-buttons {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding: 2px 0;
    flex-wrap: nowrap;
}

.nav-buttons::-webkit-scrollbar {
    height: 4px;
}

.nav-buttons::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

.nav-buttons::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
}

.nav-buttons::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

.nav-btn {
    background: #0d6efd;
    border: none;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: #0b5ed7;
}

.nav-btn.active {
    background: #084298;
}

.header-right {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#settingsBtn,
#logoutBtn {
    background: #0d6efd;
    color: #ffffff;
    border: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

#settingsBtn:hover,
#logoutBtn:hover {
    background: #0b5ed7;
}

main {
    flex: 1;
    display: flex;
    padding: 0;
    background: #f8f9fa;
    overflow: hidden;
}

.iframe-wrapper {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    width: 600px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 2px solid #e9ecef;
}

.modal-content h2 {
    margin: 0 0 20px 0;
    font-size: 20px;
    color: #495057;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 12px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #0d6efd;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 6px;
    display: block;
    font-size: 14px;
}

.modal-content input,
.modal-content select {
    padding: 10px 14px;
    border-radius: 6px;
    border: 2px solid #ced4da;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #f8f9fa;
    color: #212529;
    width: 100%;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: #0d6efd;
    background: #ffffff;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.modal-content button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    flex: 1;
}

.close-btn-modal {
    background: #6c757d;
    color: #ffffff;
}

.close-btn-modal:hover {
    background: #5c636a;
}

.confirm-btn {
    background: #0d6efd;
    color: #fff;
}

.confirm-btn:hover {
    background: #0b5ed7;
}

.error-msg {
    color: #dc3545;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    background: #f8d7da;
    border-radius: 6px;
    border-left: 3px solid #dc3545;
    margin-top: 12px;
}

.app-list-container,
.user-list-container {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 8px;
    background: #f8f9fa;
}

.app-item,
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    transition: background 0.2s;
    background: #ffffff;
    margin-bottom: 6px;
    border: 1px solid #e9ecef;
}

.app-item:hover,
.user-item:hover {
    background: #f8f9fa;
}

.app-item:last-child,
.user-item:last-child {
    margin-bottom: 0;
}

.app-item-info {
    flex: 1;
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

.app-item-buttons {
    display: flex;
    flex-direction: column;   /* строки друг под другом */
    align-items: flex-end;      /* центр по горизонтали */
    gap: 6px;
}

.app-item-buttons .btn-row {
    display: flex;
    gap: 6px;
    justify-content: center;  /* центр в строке */
}

.small-btn {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  font-weight: 200;
  transition: all 0.2s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;      /* вертикальный центр текста и иконки */
  justify-content: center;  /* горизонтальный центр текста */
  gap: 4px;
}

.small-btn.polz_apps {
    background: #0d6efd;
    color: white;
    padding: 10px 16px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.polz_apps:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.group_apps {
    background: #0d6efd;
    color: white;
    padding: 10px 7px;
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.group_apps:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.group_groups {
    background: #0d6efd;
    color: white;
    padding: 10px 15px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.group_groups:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.polz_passwd {
    background: #0d6efd;
    color: white;
    padding: 10px 27px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.polz_passwd:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.polz_groups {
    background: #0d6efd;
    color: white;
    padding: 10px 28px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.polz_groups:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}


.small-btn.edit {
    background: #0d6efd;
    color: white;
    padding: 8px 14px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.edit:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.delete_apps {
    background: #bb2d3b;
    color: white;
    padding: 10px 32px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.delete_apps:hover {
    background: #bb2d3b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.delete_polz {
    background: #dc3545;
    color: white;
    padding: 10px 25px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.delete_polz:hover {
    background: #bb2d3b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.delete_groups {
    background: #dc3545;
    color: white;
    padding: 10px 71px;   
    font-size: 12px;

    width: auto;         
    max-width: max-content; 
    flex: 0 0 auto;
}

.small-btn.delete_groups:hover {
    background: #bb2d3b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

.small-btn.delete:hover {
    background: #bb2d3b;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* зелёная кнопка */
.small-btn.success {
  background: #198754;
  color: white;
  padding: 8px 10px;   
  font-size: 12px;

  width: auto;         
  max-width: max-content; 
  flex: 0 0 auto;      
}

.small-btn.success:hover {
    background: #157347;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.3);
}

.select-all-btn {
  flex: 0 0 auto;          
  align-self: flex-start; 
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e9ecef;
}

.tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c757d;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab:hover {
    color: #0d6efd;
}

.tab.active {
    color: #0d6efd;
    border-bottom-color: #0d6efd;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }

    .header-left {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .nav-buttons-container {
        width: 100%;
    }

    .modal-content {
        width: 100%;
        padding: 20px;
    }

    .app-item-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .small-btn:not(.select-all-btn) {
        width: 100%;
        justify-content: center;
    }
}

.card-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

/* FAVORITES */
.favorites-container {
    display: flex;
    gap: 6px;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    min-width: 0;
    padding: 2px 0;
}

.favorites-container::-webkit-scrollbar {
    height: 4px;
}
.favorites-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}
.favorites-container::-webkit-scrollbar-thumb {
    background: #ced4da;
    border-radius: 4px;
}

.fav-btn-header {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e7f1ff;
    border: 1.5px solid #b6d4fe;
    color: #0d6efd;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.fav-btn-header:hover {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.25);
}

.fav-btn-header img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
}

.fav-star {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    opacity: 0.4;
    transition: all 0.2s;
    filter: grayscale(1);
    line-height: 1;
}

.fav-star:hover {
    opacity: 1;
    transform: scale(1.2);
    filter: grayscale(0);
}

.fav-star.active {
    opacity: 1;
    filter: grayscale(0);
}

/* POPUP CHOOSE LOCAL/GLOBAL */
    .link-choice-popup {
        position: fixed;
        top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.4);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 2000;
    }
    .link-choice-box {
        background: #fff;
        border-radius: 14px;
        padding: 24px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.2);
        min-width: 300px;
        max-width: 400px;
        text-align: center;
    }
    .link-choice-box h3 {
        margin: 0 0 16px 0;
        font-size: 17px;
        color: #495057;
    }
    .link-choice-btns {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .link-choice-btn {
        padding: 12px 20px;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    .link-choice-btn.local {
        background: #0d6efd;
        color: #fff;
    }
    .link-choice-btn.local:hover {
        background: #0b5ed7;
    }
    .link-choice-btn.global {
        background: #198754;
        color: #fff;
    }
    .link-choice-btn.global:hover {
        background: #157347;
    }
    .link-choice-btn.cancel {
        background: #f8f9fa;
        color: #6c757d;
        border: 1px solid #dee2e6;
    }
    .link-choice-btn.cancel:hover {
        background: #e9ecef;
    }

    /* DRAG AND DROP */
    .app-card.dragging {
        opacity: 0.4;
        transform: scale(0.95);
        box-shadow: 0 0 0 2px #0d6efd;
    }
    .app-card.drag-over {
        border-color: #0d6efd;
        background: #e7f1ff;
        transform: scale(1.02);
    }
