:root {
    --bg-deep: #ffffff;
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --card-border: #d4ebe6;
    --text-primary: #134e4a;
    --text-secondary: #3d6f66;
    --accent-gradient: linear-gradient(135deg, #0f766e, #042f2e);
    --badge-border: #cce8e3;
    --radius-card: 14px;
    --space-page: clamp(1rem, 4vw, 2rem);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] {
    display: none !important;
}

body.platform-body {
    font-family: 'Readex Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100dvh;
}

a { color: #115e59; text-decoration: none; }
a:hover { color: #0d9488; }

.wrap { max-width: 980px; margin: 0 auto; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    padding: clamp(18px, 3vw, 24px);
    box-shadow: 0 10px 30px rgba(15, 118, 110, 0.06);
}

.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); margin-bottom: 8px; color: #042f2e; }
h2 { font-size: 1.1rem; margin-bottom: 10px; color: #042f2e; }
.muted { color: var(--text-secondary); font-size: 0.9rem; }

.status-banner {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.84rem;
}

.status-banner--ok {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.status-banner--warn {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab-btn {
    border: 1px solid var(--card-border);
    background: #fff;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 8px 14px;
    cursor: pointer;
    font: inherit;
}
.tab-btn.is-active {
    background: var(--accent-gradient);
    color: #fff;
    border-color: transparent;
    font-weight: 700;
}
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.form-grid { display: grid; gap: 12px; }
.field label { display: block; font-size: 0.84rem; color: var(--text-secondary); margin-bottom: 6px; }
input[type="password"] {
    text-transform: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.field input, .field select, .field textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: #fff;
    color: var(--text-primary);
    padding: 11px 12px;
    font: inherit;
}
.field textarea { min-height: 110px; resize: vertical; }

.btn-primary, .btn-secondary, .btn-ghost, .btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.2);
}
.btn-secondary {
    background: #fff;
    color: #042f2e;
    border: 1px solid var(--badge-border);
}
.btn-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: #115e59;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.btn-link:hover { color: #0d9488; }
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}
.btn-logout {
    background: #dc2626;
    color: #fff;
    border: 1px solid #dc2626;
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.22);
}
.btn-logout:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}
.btn-logout:focus-visible {
    outline: 2px solid #fca5a5;
    outline-offset: 2px;
}

.form-message {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.86rem;
    display: block;
}
.form-message[hidden] {
    display: none !important;
}
.form-message.success { background: #ecfdf5; color: #065f46; }
.form-message.error { background: #fef2f2; color: #991b1b; }
.form-message.info { background: #f0fdfa; color: #115e59; }

.btn.is-loading {
    pointer-events: none;
    opacity: 0.85;
}

/* دوّرة التحميل تعلّق بعض نسخ Safari عند التركيز على حقول كلمة المرور */
.platform-body--admin .btn.is-loading::after {
    display: none;
}

.ticket-card {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: #fafafa;
}
.ticket-card--unread {
    border-color: #fca5a5;
    background: #fff7f7;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.08);
}
.ticket-card__badges {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.ticket-pill--new {
    color: #fff;
    background: #dc2626;
    border-color: #dc2626;
    font-weight: 700;
}
.stat--highlight strong {
    color: #dc2626;
}
.ticket-card__head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.ticket-card footer {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    color: #3d6f66;
    font-size: 0.78rem;
}
.ticket-pill {
    font-size: 0.72rem;
    border-radius: 999px;
    padding: 2px 8px;
    border: 1px solid var(--card-border);
    background: #fff;
}
.ticket-pill--high { color: #b91c1c; }
.ticket-pill--normal { color: #0f766e; }
.ticket-pill--low { color: #3d6f66; }

.ticket-card__meta {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    color: #3d6f66;
    font-size: 0.78rem;
}
.ticket-id { font-weight: 700; color: #0f766e; }

.ticket-thread {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--card-border);
}
.ticket-thread__title {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #134e4a;
}
.ticket-thread__empty,
.ticket-thread__closed {
    font-size: 0.85rem;
}
.ticket-msg {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}
.ticket-msg--client {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.ticket-msg--admin {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
}
.ticket-msg__meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.75rem;
    margin-bottom: 4px;
    color: #3d6f66;
}
.ticket-reply-form {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}
.ticket-reply-form textarea {
    width: 100%;
    min-height: 72px;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    resize: vertical;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.stat {
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    background: #fff;
}
.stat strong { display: block; font-size: 1.3rem; color: #0d9488; }

.nav-admin-link {
    font-weight: 600;
    color: #0f766e;
}

.admin-entry-card {
    margin-top: 1.25rem;
    border-color: #99f6e4;
    background: linear-gradient(180deg, #f0fdfa 0%, #fff 55%);
}

.admin-entry-card__head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.admin-entry-card__icon {
    font-size: 1.5rem;
    line-height: 1;
}

.admin-entry-card h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
}

.admin-entry-card__lead {
    margin: 0;
    font-size: 0.95rem;
}

.admin-entry-card__btn {
    display: inline-block;
    text-align: center;
}

.admin-hub {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0 20px;
}

.admin-hub__tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 108px;
    padding: 14px 10px;
    border: 2px solid var(--card-border, #e2e8f0);
    border-radius: 14px;
    background: #fff;
    color: #0f172a;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.admin-hub__tile:hover {
    border-color: #99f6e4;
    background: #f8fffe;
}

.admin-hub__tile.is-active {
    border-color: #0d9488;
    background: #f0fdfa;
    box-shadow: 0 0 0 1px #0d9488;
}

.admin-hub__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f766e;
}

.admin-hub__icon--whatsapp {
    color: #25d366;
}

.admin-hub__label {
    text-align: center;
    line-height: 1.35;
}

.admin-hub__badge {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    min-width: 1.4rem;
    padding: 2px 6px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
}

.admin-panel[hidden] {
    display: none !important;
}

.admin-panel .card {
    margin-top: 0;
}
