* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f6f8;
    color: #1f2933;
}

#admin-root {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

h1, h2 {
    margin: 0 0 0.75rem 0;
}

.subtle {
    margin: 0;
    color: #6b7280;
}

.login-panel {
    max-width: 420px;
    margin: 6rem auto 0;
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-panel input {
    width: 100%;
}

.admin-panel.hidden,
.login-panel.hidden,
.hidden {
    display: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-button {
    border: none;
    background: #e5e7eb;
    color: #111827;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 600;
}

.tab-button.active {
    background: #1f2933;
    color: #fff;
}

.tab-content {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
}

.tab-content.active {
    display: flex;
}

.card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    margin-bottom: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

label.inline {
    flex-direction: row;
    align-items: center;
    gap: 0.6rem;
}

input, select, textarea {
    padding: 0.5rem 0.7rem;
    border: 1px solid #cbd2d9;
    border-radius: 8px;
    font-size: 0.95rem;
}

button {
    border: none;
    background: #1f2933;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

button.ghost {
    background: transparent;
    color: #1f2933;
    border: 1px solid #cbd2d9;
}

.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #1f2933;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-weight: 600;
}

.link-button.ghost {
    background: transparent;
    color: #1f2933;
    border: 1px solid #cbd2d9;
}

.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.assign-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.assign-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
    font-size: 0.9rem;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
}

.assign-item input {
    width: 18px;
    height: 18px;
    margin-left: 0;
}

.assign-item .status {
    font-size: 0.85rem;
    color: #3bb273;
    font-weight: 600;
}

.assign-item .assign-left {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 1rem;
    overflow-y: auto;
}

.modal.hidden {
    display: none;
}

.admin-toast-root {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: auto;
    width: min(520px, calc(100vw - 2rem));
}

.admin-toast {
    border-radius: 10px;
    padding: 0.9rem 1rem;
    font-size: 0.9rem;
    line-height: 1.35;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
    border: 1px solid transparent;
}

.admin-toast-content {
    margin-bottom: 0.7rem;
}

.admin-toast-actions {
    display: flex;
    justify-content: flex-end;
}

.admin-toast-ok-btn {
    background: #1f2933;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.rule-bulk-layout {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 1rem;
}

.rule-bulk-column h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.92rem;
}

.rule-bulk-list {
    min-height: 280px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: #f8fafc;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rule-bulk-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    padding: 0.55rem 0.65rem;
    cursor: grab;
}

.rule-bulk-item-main {
    font-size: 0.9rem;
    font-weight: 600;
}

.rule-bulk-item-meta {
    font-size: 0.8rem;
    color: #6b7280;
}

.rule-bulk-item-actions {
    margin-top: 0.45rem;
    display: flex;
    justify-content: flex-end;
}

.rule-item-state-active,
.rule-item-state-inactive {
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    background: #f9fafb;
    color: #1f2933;
    cursor: pointer;
}

.rule-item-state-active {
    background: #ecfdf3;
    border-color: #bbf7d0;
    color: #166534;
}

.rule-item-state-inactive {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.rule-bulk-empty {
    font-size: 0.86rem;
    color: #6b7280;
    padding: 0.4rem 0.2rem;
}

.rule-bulk-header {
    margin-bottom: 0.75rem;
}

.rule-bulk-header-title {
    font-size: 0.8rem;
    color: #6b7280;
}

.rule-bulk-header-value {
    margin-top: 0.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.rule-table-primary {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
}

.rule-table-meta {
    font-size: 0.78rem;
    color: #6b7280;
    margin-top: 0.12rem;
}



.admin-toast-error {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #9f1239;
}

.admin-toast-success {
    background: #ecfdf3;
    border-color: #bbf7d0;
    color: #166534;
}


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

.modal-card {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    width: min(640px, 90vw);
    max-height: min(86vh, 760px);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.photo-page {
    background: #f8fafc;
}

.page-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.photo-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.photo-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.photo-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: stretch;
    justify-items: stretch;
}

.photo-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.photo-thumb-button {
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    width: 100%;
    display: block;
}

.photo-thumb-button img {
    width: 100%;
    aspect-ratio: 2 / 3;
    height: auto;
    display: block;
    border-radius: 8px;
    object-fit: cover;
}

.photo-meta {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: space-between;
    font-size: 0.85rem;
    min-width: 0;
}

.photo-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.photo-details {
    font-size: 0.75rem;
    color: #64748b;
    display: grid;
    gap: 0.2rem;
}

.photo-delete-button {
    align-self: start;
}

.photo-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 70;
}

.photo-modal.hidden {
    display: none;
}

.photo-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
}

.photo-modal-card {
    position: relative;
    z-index: 1;
    background: #fff;
    padding: 1rem;
    border-radius: 12px;
    max-width: min(900px, 90vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.photo-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.photo-modal-body {
    display: grid;
    gap: 0.75rem;
}

.photo-existing {
    display: grid;
    gap: 0.5rem;
}

.photo-existing-title {
    font-size: 0.85rem;
    color: #475569;
    font-weight: 600;
}

.photo-existing-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.photo-existing-item {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    border-radius: 999px;
}

.photo-modal-card img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}

.photo-modal-close {
    align-self: flex-end;
}

.photo-editor {
    display: grid;
    grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.photo-editor-left label {
    display: block;
    margin-bottom: 0.75rem;
}

.photo-canvas-wrapper {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    background: #fff;
    overflow: auto;
}

.photo-canvas-wrapper canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: #f1f5f9;
}

.slider-row {
    display: grid;
    gap: 0.5rem;
    margin: 1rem 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.8rem;
    min-width: 560px;
}

.data-table th,
.data-table td {
    padding: 0.6rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    font-size: 0.9rem;
}

.data-table th.actions-cell,
.data-table td.actions-cell {
    text-align: right;
}

.data-table td.actions-cell {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.data-table input {
    width: 100%;
}

.data-table .partner-secret-input {
    max-width: 220px;
}

.key-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.key-value {
    word-break: break-all;
}

.icon-button {
    padding: 0.35rem;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.assigned-profiles {
    display: grid;
    gap: 0.4rem;
}

.assigned-profile-item {
    font-weight: 600;
    color: #0f172a;
}

.assign-meta {
    color: #64748b;
    font-size: 0.85rem;
}

.assign-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.secret-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.operator-password-actions .partner-secret-input {
    flex: 1;
    min-width: 180px;
}

.inline-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.inline-actions input {
    flex: 1;
}

.detail-panel {
    flex: 1;
    display: grid;
    gap: 0.85rem;
    padding: 0.25rem 0.1rem;
    overflow-y: auto;
    max-height: 100%;
}

.detail-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "label action"
        "value action";
    column-gap: 1rem;
    row-gap: 0.25rem;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.detail-item .label {
    grid-area: label;
    color: #64748b;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.detail-item .value,
.detail-item .detail-edit {
    grid-area: value;
}

.detail-action-slot {
    grid-area: action;
    align-self: center;
    display: flex;
    justify-content: flex-end;
}

.detail-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 0.4rem;
}

.detail-photo-thumb {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.detail-item .value {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 600;
    word-break: break-word;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

.detail-actions button {
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
}

.detail-edit {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-edit input[type="text"],
.detail-edit input[type="password"] {
    width: 100%;
}

.mail-settings-panel {
    display: grid;
    gap: 0.65rem;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #eef6ff;
}

.mail-settings-panel-title {
    margin: 0;
    font-size: 0.9rem;
    color: #1e3a8a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.error-text {
    color: #b42318;
    margin: 0.5rem 0 0 0;
    min-height: 1.2rem;
    font-size: 0.9rem;
}

.success-text {
    color: #15803d;
    margin: 0.5rem 0 0 0;
    min-height: 1.2rem;
    font-size: 0.9rem;
}

.post-media-list {
    display: grid;
    gap: 0.75rem;
}

.post-media-item {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.7rem;
    background: #f8fafc;
    display: grid;
    gap: 0.65rem;
}

.post-media-preview img,
.post-media-preview video {
    width: 100%;
    max-width: 280px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #0f172a;
}

.post-media-meta {
    display: grid;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: #334155;
}

.post-media-actions {
    display: flex;
    justify-content: flex-start;
}

@media (max-width: 720px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabs {
        flex-wrap: wrap;
    }

    #admin-root {
        padding: 1.5rem 1rem 2.5rem;
    }

    .card {
        padding: 1.25rem;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .modal-card {
        width: min(520px, 92vw);
        max-height: 92vh;
        padding: 1.25rem;
    }

    .data-table th,
    .data-table td {
        font-size: 0.85rem;
        padding: 0.5rem;
    }

    #partners-table {
        min-width: 0;
    }

    #partners-table thead {
        display: none;
    }

    #partners-table tbody,
    #partners-table tr,
    #partners-table td {
        display: block;
        width: 100%;
    }

    #partners-table tr {
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 0.5rem 0.6rem;
        margin-bottom: 0.75rem;
        background: #ffffff;
    }

    #partners-table td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        border-bottom: 1px dashed #e5e7eb;
    }

    #partners-table td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: 600;
        flex-shrink: 0;
    }

    #partners-table .secret-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    #partners-table .key-cell {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
    }

    #partners-table button {
        width: auto;
    }

    #partners-table td:last-child {
        border-bottom: 0;
    }

    #partners-table td.actions-cell {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    #partners-table input,
    #partners-table .partner-secret-input {
        max-width: 100%;
    }

    button {
        width: 100%;
    }

    .button-row button {
        width: auto;
    }

    .data-table td.actions-cell button {
        width: auto;
    }

    .post-media-preview img,
    .post-media-preview video {
        max-width: 100%;
    }
}
