:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --line: #d9dde7;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #5f7ea7;
    --primary-dark: #48688e;
    --danger: #d32f2f;
    --danger-dark: #b71c1c;
    --soft: #eef3f9;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --max-width: 1500px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Rubik", "Segoe UI", Arial, sans-serif;
}

body {
    line-height: 1.4;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---------- Layout ---------- */

.page-shell {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 18px;
}

.page-title-card {
    margin-bottom: 16px;
    padding: 18px 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 800;
    font-family: "Rubik", "Segoe UI", Arial, sans-serif;
}

.main-layout {
    display: grid;
    grid-template-columns: 560px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.list-panel,
.details-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.list-panel {
    padding: 14px;
}

.details-panel {
    padding: 20px;
    min-height: 440px;
}

/* ---------- Search bar ---------- */

.searchbar-wrap {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.searchbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.search-inline-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

/* ---------- Inputs ---------- */

.search-input,
.text-input,
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .search-input:focus,
    .text-input:focus,
    textarea:focus,
    select:focus,
    .login-input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(95, 126, 167, 0.12);
    }

.search-input {
    width: 240px;
    min-width: 0;
    max-width: 100%;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

.rtl-text {
    direction: rtl;
    text-align: right;
}

.ltr-field {
    direction: ltr;
    text-align: left;
}

    .ltr-field::placeholder {
        text-align: left;
    }

/* ---------- Buttons ---------- */

.primary-btn,
.secondary-btn,
.danger-btn,
.icon-btn,
.login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.primary-btn {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

    .primary-btn:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
    }

.secondary-btn,
.icon-btn {
    background: #fff;
    color: var(--text);
}

    .secondary-btn:hover,
    .icon-btn:hover {
        background: #f8fafc;
    }

.danger-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

    .danger-btn:hover {
        background: var(--danger-dark);
        border-color: var(--danger-dark);
    }

button:disabled,
.login-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* ---------- Table ---------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
}

.adopter-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    background: #fff;
}

    .adopter-table th,
    .adopter-table td {
        padding: 14px 12px;
        border-bottom: 1px solid var(--line);
        vertical-align: middle;
        font-size: 0.96rem;
    }

    .adopter-table th {
        background: #f8fafc;
        font-weight: 700;
        white-space: nowrap;
    }

    .adopter-table tbody tr {
        cursor: pointer;
        transition: background 0.15s ease;
    }

        .adopter-table tbody tr:hover {
            background: #f8fbff;
        }

.selected-row {
    background: #eef4fb !important;
}

.sortable {
    cursor: pointer;
    user-select: none;
}

    .sortable:hover {
        background: #eef3f9;
    }

/* ---------- Details ---------- */

.details-section-title {
    margin: 0 0 16px 0;
    font-size: 1.3rem;
    font-weight: 800;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 16px;
}

.details-card {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafafa;
}

    .details-card strong {
        display: block;
        margin-bottom: 6px;
    }

.details-card-full {
    grid-column: 1 / -1;
}

.details-card div,
.section-block div {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.section-block {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

    .section-block h4 {
        margin: 0 0 10px 0;
        font-size: 1rem;
    }

.multiline-value {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.5;
    max-width: 100%;
}

.action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Phones ---------- */

.phone-chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.phone-chip-wrap-top {
    margin-top: 4px;
}

.phone-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef3f9;
    border: 1px solid var(--line);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
}

    .phone-chip:hover {
        background: #e4ebf4;
    }

.compact-chip {
    padding: 5px 11px;
    font-size: 0.9rem;
}

.phone-extra {
    color: var(--muted);
    font-size: 0.88rem;
}

.phone-edit-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: nowrap;
}

.phone-prefix-select {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
}

.phone-rest-input {
    flex: 1;
    min-width: 0;
}

.phone-remove-btn {
    min-width: 90px;
    white-space: nowrap;
}

/* ---------- Images ---------- */

.thumb-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.thumb-item {
    width: 120px;
}

.thumb {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.thumb-name {
    margin-top: 6px;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.small-btn {
    margin-top: 6px;
    padding: 6px 10px;
    font-size: 12px;
}

.image-viewer {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    margin: 0 auto;
}

/* ---------- States ---------- */

.empty-panel {
    padding: 24px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.empty-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.empty-subtitle {
    color: var(--muted);
    font-size: 0.95rem;
}

.message-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #f3bcbc;
    border-radius: var(--radius-sm);
    background: #fdeaea;
    color: #8a1f1f;
}

.success-box {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #b7e3c0;
    border-radius: var(--radius-sm);
    background: #eaf8ee;
    color: #1e6b35;
}

/* ---------- Modals ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1000;
}

.modal-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(760px, calc(100vw - 32px));
    max-height: 90vh;
    overflow: auto;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 1001;
}

    .modal-card h3 {
        margin-top: 0;
        margin-bottom: 16px;
    }

.modal-card-sm {
    width: min(520px, calc(100vw - 32px));
}

.modal-card-image {
    width: min(960px, calc(100vw - 32px));
}

.modal-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 15px;
}

    .form-row label {
        font-weight: 600;
        font-size: 0.94rem;
    }

/* ---------- Pagination ---------- */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px;
}

.page-indicator {
    font-weight: 600;
}

/* ---------- Login ---------- */

.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 16px;
}

.login-card {
    width: 100%;
    max-width: 520px;
    background: #fff;
    border: 1px solid #d9e0ea;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.login-title {
    margin: 0 0 20px 0;
    font-size: 2rem;
    line-height: 1.2;
}

.login-form-row {
    margin-bottom: 16px;
}

.login-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1f2937;
}

.login-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    font-size: 1rem;
    background: #fff;
}

.login-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-start;
}

.login-btn {
    min-width: 140px;
    height: 46px;
    border: none;
    background: #5f7ea9;
    color: #fff;
}

.login-error {
    margin-top: 12px;
    color: #b42318;
    font-size: 0.95rem;
}

.login-disclaimer-box {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.login-disclaimer-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.login-disclaimer-text {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.6;
}

    .login-disclaimer-text p {
        margin: 0 0 10px 0;
    }

.login-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 12px;
    font-size: 0.92rem;
    color: var(--text);
}

    .login-checkbox-row input[type="checkbox"] {
        margin-top: 3px;
        flex: 0 0 auto;
    }

.login-disclaimer {
    margin: 16px 0 18px 0;
    padding: 12px 14px;
    border: 1px solid #d7deea;
    border-radius: 12px;
    background: #f8fafc;
    color: #24364b;
    font-size: 0.95rem;
    line-height: 1.6;
}

.disclaimer-scroll {
    max-height: 140px;
    overflow-y: auto;
    padding: 12px;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid #dcdcdc;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 10px;
}

.disclaimer-accept {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    font-size: 0.95rem;
    color: #2c3a4f;
}

    .disclaimer-accept input {
        width: 18px;
        height: 18px;
        cursor: pointer;
    }

    .disclaimer-accept label {
        cursor: pointer;
    }

.hint-text {
    font-size: 12px;
    color: #777;
    margin-top: 4px;
}

/* ---------- App header / topbar ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.topbar-right,
.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-box {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--soft);
    border: 1px solid var(--line);
    font-weight: 800;
    font-size: 1rem;
    color: var(--text);
}

.app-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.app-title {
    font-family: "Rubik", sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
}

.user-label {
    font-weight: 700;
}

.app-disclaimer {
    margin-top: 20px;
    padding: 10px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.top-nav {
    margin-bottom: 10px;
}

.back-link {
    display: inline-block;
    padding: 8px 14px;
    background: #eef2ff;
    border-radius: 8px;
    border: 1px solid #c7d2fe;
    text-decoration: none;
    font-weight: 600;
    color: #1e3a8a;
}

    .back-link:hover {
        background: #e0e7ff;
    }

.top-userbar {
    max-width: 1680px;
    margin: 0 auto 16px auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.user-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-chip,
.role-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid #d5dce8;
    background: #ffffff;
    color: #1f3552;
    font-weight: 700;
}

.role-chip {
    background: #eef4ff;
}

.top-userbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- Links / request access ---------- */

.request-access-link {
    margin-top: 14px;
    text-align: center;
}

.request-access-btn {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
}

    .request-access-btn:hover {
        text-decoration: underline;
    }

/* ---------- RTL rules ---------- */

.rtl-app,
.rtl-modal {
    direction: rtl;
    text-align: right;
}

    .rtl-app .page-title,
    .rtl-app .details-section-title,
    .rtl-app .empty-panel,
    .rtl-app .message-error,
    .rtl-app .details-card,
    .rtl-app .section-block,
    .rtl-modal h3,
    .rtl-modal .form-row,
    .rtl-modal .form-row label,
    .rtl-modal .message-error {
        text-align: right;
    }

    .rtl-app .adopter-table th,
    .rtl-app .adopter-table td {
        text-align: right;
    }

    .rtl-app .searchbar-wrap {
        flex-direction: row;
    }

    .rtl-app .searchbar-wrap,
    .rtl-app .searchbar-right,
    .rtl-app .search-inline-group,
    .rtl-app .action-row,
    .rtl-app .phone-chip-wrap,
    .rtl-app .pagination-bar,
    .rtl-modal .modal-header-row,
    .rtl-modal .modal-actions {
        direction: rtl;
    }

    .rtl-app .phone-extra {
        margin-left: 0;
        margin-right: 6px;
    }

    .rtl-modal .phone-edit-row {
        flex-direction: row-reverse;
    }

    .rtl-modal .phone-prefix-select,
    .rtl-modal .phone-rest-input {
        direction: ltr;
        text-align: left;
    }

    .rtl-modal .modal-actions {
        flex-direction: row-reverse;
        justify-content: flex-start;
    }

    .rtl-modal .modal-header-row {
        flex-direction: row-reverse;
    }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .page-shell {
        padding: 12px;
    }

    .searchbar-wrap {
        flex-direction: column !important;
        align-items: stretch;
    }

    .searchbar-right {
        width: 100%;
    }

    .search-inline-group {
        width: 100%;
        display: flex;
        align-items: stretch;
    }

        .search-inline-group .search-input {
            flex: 1;
            width: auto;
        }

    .details-grid {
        grid-template-columns: 1fr;
    }

    .details-card-full {
        grid-column: auto;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-right,
    .topbar-left {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 10px;
    }

    .page-title-card {
        padding: 14px 16px;
        margin-bottom: 12px;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .searchbar-wrap {
        flex-direction: column !important;
        align-items: stretch;
        padding: 12px;
        gap: 12px;
        margin-bottom: 14px;
    }

    .searchbar-right {
        width: 100%;
    }

    .search-inline-group {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .search-input {
        width: 100%;
        min-width: 0;
    }

    .search-inline-group .secondary-btn,
    .searchbar-right .primary-btn,
    .searchbar-right .secondary-btn,
    .searchbar-right .danger-btn {
        width: 100%;
    }

    .list-panel {
        padding: 12px;
    }

    .table-wrap {
        overflow: visible;
    }

    .adopter-table {
        min-width: 0;
        background: transparent;
    }

        .adopter-table thead {
            display: none;
        }

        .adopter-table,
        .adopter-table tbody,
        .adopter-table tr,
        .adopter-table td {
            display: block;
            width: 100%;
        }

            .adopter-table tr {
                background: #fff;
                border: 1px solid var(--line);
                border-radius: 14px;
                padding: 12px;
                margin-bottom: 12px;
                box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
            }

            .adopter-table td {
                padding: 0;
                border: none;
                font-size: 0.92rem;
                text-align: right;
            }

                .adopter-table td + td {
                    margin-top: 8px;
                }

                .adopter-table td:nth-child(1) {
                    font-size: 1rem;
                    font-weight: 700;
                    color: var(--text);
                }

                .adopter-table td:nth-child(2) {
                    display: flex;
                    align-items: center;
                    gap: 6px;
                    flex-wrap: wrap;
                }

                .adopter-table td:nth-child(3) {
                    color: var(--muted);
                    font-size: 0.92rem;
                }

    .details-panel {
        padding: 14px;
        min-height: auto;
    }

    .details-section-title {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    .section-block {
        margin-top: 14px;
        padding-top: 12px;
    }

    .pagination-bar {
        gap: 10px;
        padding: 10px 0 2px 0;
        flex-wrap: wrap;
    }

    .modal-card,
    .modal-card-sm,
    .modal-card-image {
        width: calc(100vw - 20px);
        max-height: 92vh;
        padding: 16px;
        border-radius: 16px;
    }

    .phone-edit-row {
        flex-direction: column !important;
        align-items: stretch;
    }

    .phone-prefix-select,
    .phone-rest-input,
    .phone-remove-btn {
        width: 100%;
        max-width: 100%;
    }

    .login-page {
        padding: 20px 12px;
    }

    .login-card {
        max-width: 100%;
        padding: 18px;
        border-radius: 14px;
    }

    .login-title {
        font-size: 1.7rem;
    }

    .login-input {
        height: 44px;
        font-size: 0.98rem;
    }

    .login-btn {
        width: 100%;
    }

    .login-actions {
        display: block;
    }

    .login-checkbox-row {
        font-size: 0.88rem;
    }

    .login-disclaimer-text {
        font-size: 0.84rem;
    }

    .topbar {
        padding: 12px;
    }

    .topbar-right,
    .topbar-left {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-title-group {
        justify-content: flex-start;
    }

    .user-chip,
    .danger-btn {
        width: 100%;
        justify-content: center;
    }
}
.phone-cell {
    direction: ltr;
    text-align: center;
    vertical-align: middle;
}

.phone-inline-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
    color: #1f2a37;
}

.details-phone-list {
    direction: ltr;
    text-align: right;
    font-weight: 600;
    color: #1f2a37;
    line-height: 1.8;
    word-break: break-word;
}