* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: #f4f7fb;
    color: #1f2937;
}

.container {
    width: min(1200px, 92%);
    margin: 0 auto;
}

/* HEADER */
.site-header {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: white;
    padding: 8px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.10);
    position: relative;
    z-index: 10;
}

.site-header .container {
    width: 100%;
    max-width: none;
    padding: 0 32px;
}

.header-inner {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo-block {
    min-width: 0;
    flex: 1;
}

.logo,
.logo-title {
    margin: 0;
    font-size: 24px;
    line-height: 1.15;
    font-weight: 700;
    color: white;
}

.subtitle,
.logo-subtitle {
    margin: 2px 0 0;
    font-size: 13px;
    line-height: 1.2;
    opacity: 0.88;
}

.user-panel {
    margin-left: auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    white-space: nowrap;
}

.username {
    font-weight: bold;
}

.logout-form {
    margin: 0;
}

.site-header .btn,
.site-header .btn-danger {
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 14px;
}

/* LAYOUT */
.app-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 300px;
    flex: 0 0 300px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding: 24px 16px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar-home-link {
    display: block;
    width: 100%;
    text-align: left;
    text-decoration: none;
    font-size: 15px;
    color: #1f2937;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
}

.sidebar-home-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.menu-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    border: 1px solid #dbe4f0;
    background: #f8fafc;
    font-size: 15px;
    font-weight: bold;
    color: #1f2937;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-toggle:hover {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.menu-toggle.open {
    background: #eaf2ff;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.menu-arrow {
    font-size: 14px;
    transition: transform 0.2s ease;
    color: #64748b;
}

.menu-toggle.open .menu-arrow {
    transform: rotate(90deg);
    color: #1d4ed8;
}

.submenu {
    display: none;
    flex-direction: column;
    gap: 6px;
    margin-top: 2px;
    padding-left: 12px;
    border-left: 2px solid #dbeafe;
}

.submenu.open {
    display: flex;
}

.submenu-link {
    display: block;
    width: 100%;
    text-align: left;
    text-decoration: none;
    color: #334155;
    background: #ffffff;
    padding: 10px 12px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.submenu-link:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.submenu-link-separated {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #dbeafe;
}

.submenu-link-with-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.submenu-text {
    flex: 1;
}

.menu-badge {
    min-width: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
}

.active-link {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    font-weight: bold;
}

.active-link .menu-badge {
    background: #bfdbfe;
    color: #1d4ed8;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.content {
    padding: 32px 0;
}

/* PAGE */
.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    margin: 0 0 8px;
    font-size: 28px;
}

.page-description {
    margin: 0;
    color: #6b7280;
}

.page-header-flex {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.card {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.section-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px;
    color: #1e293b;
}

.card .section-title {
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 16px;
}

.section-divider {
    margin: 16px 0 8px;
    border: none;
    border-top: 2px solid #3b82f6;
    opacity: 0.6;
}

/* Section headers used inside cards */
.form-section-title,
.dashboard-section-title {
    margin: -20px -24px 20px;
    padding: 14px 20px;
    background: linear-gradient(90deg, #dbeafe 0%, #eaf2ff 100%);
    color: #1e3a8a;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid #c7dbff;
    border-left: 5px solid #2563eb;
    border-radius: 16px 16px 0 0;
}

/* BUTTONS */
.btn {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #64748b;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-small {
    padding: 7px 10px;
    font-size: 13px;
}

.table-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.actions-column-header {
    text-align: center !important;
    background: #e0ecff !important;
}

.center-column-header {
    text-align: center !important;
}

.center-column-cell {
    text-align: center !important;
}

.actions-column-cell {
    min-width: 220px;
    background: #fbfdff;
    border-left: 1px solid #e5eefb;
}

.callsign-column-header {
    text-align: left !important;
}

.callsign-column-cell {
    display: table-cell !important;
    text-align: left !important;
}

.users-table th.callsign-column-header,
.users-table td.callsign-column-cell {
    text-align: left !important;
}

.users-table td.callsign-column-cell .table-link {
    display: block;
    width: 100%;
    text-align: left !important;
}

.callsign-link-text {
    display: block;
    width: 100%;
    text-align: left !important;
}

/* ADMIN */
.admin-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 20px;
}

.admin-actions-grid-compact {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.admin-action-card {
    display: flex;
    min-height: 220px;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
    padding: 24px;
    color: #1f2937;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #dbe4f0;
    border-radius: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-action-card:hover {
    transform: translateY(-2px);
    border-color: #93c5fd;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.14);
}

.admin-action-kicker {
    width: fit-content;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
}

.admin-action-title {
    color: #1e3a8a;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 700;
}

.admin-action-description {
    color: #64748b;
    font-size: 15px;
    line-height: 1.4;
    flex: 1;
}

.admin-action-button {
    width: fit-content;
    margin-top: 8px;
}

/* AUTH */
.auth-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    padding: 24px;
    max-width: 420px;
    margin: 40px auto;
}

.auth-form p {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.auth-form input {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
}

/* TABLES */
.table-wrapper {
    margin-top: 10px;
    overflow-x: auto;
}

.radio-table {
    width: 100%;
    border-collapse: collapse;
}

.radio-table th,
.radio-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: middle;
}

.radio-table th {
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 14px;
    white-space: nowrap;
}

.radio-table tr:hover td {
    background: #f8fafc;
}

.table-link {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: bold;
}

.table-link:hover {
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    color: #6b7280;
    padding: 24px;
}

/* BADGES */
.status-badge,
.equipment-badge {
    display: inline-block;
    min-width: 80px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.status-badge:hover,
.equipment-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.status-ksp,
.equipment-available {
    background-color: #d4edda;
    color: #155724;
}

.status-issued {
    background-color: #fff3cd;
    color: #856404;
}

.status-maintenance,
.equipment-warehouse {
    background-color: #e2d9f3;
    color: #4b2e83;
}

.status-lost,
.equipment-lost {
    background-color: #f8d7da;
    color: #721c24;
}

.status-decommissioned,
.equipment-unknown {
    background-color: #e2e3e5;
    color: #383d41;
}

/* SORTING */
.sort-link,
.radio-table th a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1e3a8a;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.sort-link:hover,
.radio-table th a:hover {
    text-decoration: none;
}

.sort-text {
    display: inline-block;
}

.sort-arrow {
    display: inline-block;
    width: 12px;
    font-size: 11px;
    line-height: 1;
    text-align: center;
    flex-shrink: 0;
}

.sort-arrow-hidden {
    visibility: hidden;
}

.active-sort {
    color: #dc2626;
    border-bottom: 3px solid #dc2626;
    padding-bottom: 3px;
}

/* DASHBOARD */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-card {
    margin-bottom: 0;
}

.dashboard-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #6b7280;
}

.dashboard-value {
    font-size: 28px;
    font-weight: bold;
    color: #1e3a8a;
    margin: 0;
}

.dashboard-summary-card {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    align-items: center;
    gap: 24px;
}

.dashboard-summary-main h2 {
    margin: 0 0 6px;
    font-size: 28px;
}

.dashboard-summary-item {
    padding-left: 24px;
    border-left: 1px solid #e5e7eb;
}

.dashboard-summary-label {
    display: block;
    color: #6b7280;
    font-weight: 700;
    margin-bottom: 8px;
}

.dashboard-summary-value {
    display: block;
    color: #1e3a8a;
    font-size: 26px;
}

/* DETAIL */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.detail-label {
    color: #6b7280;
    font-weight: bold;
    min-width: 180px;
}

.detail-value {
    text-align: right;
    flex: 1;
}

.detail-photo-block {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.detail-photo-main {
    width: 100%;
    max-width: 320px;
    max-height: 320px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    object-fit: contain;
    background: #ffffff;
}

.detail-photos-grid {
    display: flex;
    justify-content: center; /* центрування */
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap; /* перенос якщо багато фото */
}

.detail-photo-secondary {
    width: 220px;        /* фіксована ширина */
    height: 160px;       /* фіксована висота */
    object-fit: cover;   /* або contain, якщо не хочеш обрізання */
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.detail-photo-secondary:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

.radio-title {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 14px;
    color: #1e3a8a;
}

.radio-side-card .section-title {
    margin-top: 18px;
}

.radio-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 18px;
}

.radio-image-wrapper img {
    width: 100%;
    max-width: 320px;
    max-height: 320px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
}

.no-photo {
    width: 100%;
    max-width: 320px;
    height: 220px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: #f8fafc;
}

/* FORMS */
.form-card {
    max-width: 100%;
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 20px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-row-full {
    grid-column: 1 / -1;
}

.form-label {
    font-weight: bold;
    color: #334155;
}

.edit-form input,
.edit-form select,
.edit-form textarea,
.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

.edit-form textarea,
.form-row textarea {
    min-height: 160px;
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
}

.user-status-badge {
    display: inline-block;
    min-width: 92px;
    padding: 5px 11px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
}

.user-status-active {
    background: #d4edda;
    color: #155724;
}

.user-status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.role-badge-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    line-height: 1;
}

.role-badge-admin {
    background: #dbeafe;
    color: #1e3a8a;
}

.role-badge-department {
    background: #fef3c7;
    color: #92400e;
}

.department-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 54px;
    padding: 5px 10px;
    border-radius: 12px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.department-badge-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    background: #c7d2fe;
    color: #312e81;
    font-size: 10px;
    line-height: 1;
}

.responsible-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.responsible-person-card {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid #dbe4f0;
    border-left: 4px solid #2563eb;
    border-radius: 12px;
    background: #f8fbff;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.responsible-person-card:hover {
    border-color: #93c5fd;
    border-left-color: #1d4ed8;
    background: #eff6ff;
}

.responsible-person-name {
    color: #12337a;
    font-size: 16px;
    font-weight: 800;
}

.limited-edit-grid {
    max-width: 920px;
    margin: 0 auto;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.user-form-grid {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    align-items: start;
}

.form-error {
    color: #b91c1c;
    font-size: 14px;
}

.form-help {
    color: #64748b;
    font-size: 13px;
    line-height: 1.35;
}

.form-row input[type="checkbox"] {
    width: auto;
    align-self: flex-start;
}

.equipment-group {
    margin-top: 0;
}

.photo-form-row {
    min-width: 0;
}

.photo-form-row a {
    word-break: break-all;
}

.photo-form-row input[type="file"] {
    max-width: 100%;
}

.photo-edit-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.photo-edit-item {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.photo-edit-item h4 {
    margin: 0;
    text-align: center;
    font-size: 16px;
    color: #1e293b;
}

.photo-edit-preview {
    width: 100%;
    height: 180px;
    object-fit: contain;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
}

.photo-edit-empty {
    height: 180px;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: #f8fafc;
}

.photo-edit-item input[type="file"] {
    width: 100%;
}

/* SEARCH */
.search-card {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
}

.search-alert {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #fee2e2;
    color: #991b1b;
    font-weight: 700;
    text-align: center;
}

.search-success {
    margin-top: 18px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #dcfce7;
    color: #166534;
    font-weight: 700;
    text-align: center;
}

.search-title {
    text-align: center;
    margin: 15px 0;
    font-weight: 600;
}

.match-highlight {
    background: #fef08a;
    color: #713f12;
    font-weight: 700;
    padding: 1px 2px;
    border-radius: 4px;
}

/* ALERTS */
.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

/* PAGINATION */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.pagination-link {
    text-decoration: none;
    color: #1d4ed8;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 8px;
    background: #eff6ff;
}

.pagination-link:hover {
    background: #dbeafe;
}

.pagination-info {
    color: #475569;
    font-size: 14px;
}

/* FOOTER */
.site-footer {
    margin-top: 20px;
    padding: 16px 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.footer-content {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
}

/* RESPONSIVE */
@media (max-width: 992px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-basis: auto;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .dashboard-grid,
    .admin-actions-grid,
    .dashboard-summary-card,
    .detail-grid,
    .form-grid,
    .photo-edit-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-summary-item {
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #e5e7eb;
        padding-top: 16px;
    }

    .detail-row {
        flex-direction: column;
        gap: 6px;
    }

    .detail-value {
        text-align: left;
    }
}

@media (max-width: 768px) {
    .site-header .container {
        padding: 0 16px;
    }

    .header-inner {
        min-height: auto;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .logo,
    .logo-title {
        font-size: 22px;
    }

    .user-panel {
        width: 100%;
        justify-content: space-between;
    }

    .content {
        padding: 24px 0;
    }

    .page-header h2 {
        font-size: 22px;
    }

    .page-header-flex {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions,
    .search-form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* клікабельність */
.clickable-photo {
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.clickable-photo:hover {
    transform: scale(1.05);
}

/* модалка */
.photo-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);

    align-items: center;
    justify-content: center;
}

/* саме фото */
.photo-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.photo-modal-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    cursor: zoom-in;
    user-select: none;
    transition: transform 0.15s ease;
}

.photo-modal-img.zoomed {
    cursor: grab;
}

.photo-modal-img.dragging {
    cursor: grabbing;
    transition: none;
}

.photo-deleted-message {
    height: 180px;
    border: 1px dashed #fca5a5;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #991b1b;
    background: #fee2e2;
    font-weight: 700;
}
