:root {
      --bg: #09090b; --surface: #18181b; --surface2: #27272a;
      --border: #3f3f46; --text: #fafafa; --muted: #a1a1aa;
      --accent: #c9a84c; --accent-bg: #1c1a0e;
      --success: #22c55e; --warning: #f59e0b; --error: #ef4444;
      color-scheme: dark;
    }
    body {
      background: var(--bg); color: var(--text); min-height: 100vh;
      font-family: system-ui, -apple-system, sans-serif;
    }
    /* ── Buttons ─────────────────────────────────────────────────── */
    .btn-primary { background:var(--accent); color:#000; font-weight:600;
      padding:9px 20px; border-radius:8px; border:none; cursor:pointer;
      font-size:14px; transition:opacity .15s; text-decoration:none; display:inline-block; }
    .btn-primary:hover { opacity:.88; }
    .btn-secondary { background:var(--surface2); color:var(--text);
      padding:9px 20px; border-radius:8px; border:1px solid var(--border);
      cursor:pointer; font-size:14px; transition:border-color .15s;
      text-decoration:none; display:inline-block; }
    .btn-secondary:hover { border-color:var(--muted); }
    .btn-danger { background:transparent; color:var(--error);
      padding:9px 20px; border-radius:8px; border:1px solid var(--error);
      cursor:pointer; font-size:14px; }
    /* ── Layout ──────────────────────────────────────────────────── */
    .card { background:var(--surface); border:1px solid var(--border);
            border-radius:12px; padding:20px; }
    .input { width:100%; padding:9px 13px; border-radius:8px;
             border:1px solid var(--border); background:var(--surface2);
             color:var(--text); font-size:14px; box-sizing:border-box;
             outline:none; transition:border-color .15s;
             font-family:inherit; }
    .input:focus { border-color:var(--accent); }
    [dir="rtl"] .input { text-align:right; }
    .label { font-size:12px; font-weight:600; color:var(--muted);
             text-transform:uppercase; letter-spacing:.05em;
             display:block; margin-bottom:5px; }
    /* ── Badges ──────────────────────────────────────────────────── */
    .badge-draft  { background:#422006; color:#fbbf24;
      padding:2px 9px; border-radius:999px; font-size:11px; font-weight:600; }
    .badge-final  { background:#052e16; color:#4ade80;
      padding:2px 9px; border-radius:999px; font-size:11px; font-weight:600; }
    .badge-admin  { background:var(--accent-bg); color:var(--accent);
      padding:2px 8px; border-radius:4px; font-size:11px; font-weight:700; }
    .credit-pill  { background:var(--accent-bg); border:1px solid var(--accent);
      border-radius:8px; padding:5px 12px;
      display:inline-flex; align-items:center; gap:8px; }
    /* ── Topbar ──────────────────────────────────────────────────── */
    .topbar { background:var(--surface); border-bottom:1px solid var(--border);
              padding:0 24px; height:56px; display:flex;
              align-items:center; justify-content:space-between;
              position:sticky; top:0; z-index:50; }
    /* ── Sidebar ─────────────────────────────────────────────────── */
    .sidebar { width:220px; flex-shrink:0; background:var(--surface);
               border-inline-end:1px solid var(--border);
               padding:16px 12px; min-height:calc(100vh - 56px); }
    .sidebar-link { display:flex; align-items:center; gap:10px;
                    padding:8px 10px; border-radius:8px; font-size:14px;
                    color:var(--muted); text-decoration:none;
                    transition:background .12s, color .12s; }
    .sidebar-link:hover  { background:var(--surface2); color:var(--text); }
    .sidebar-link.active { background:var(--accent-bg); color:var(--accent); font-weight:600; }
    /* ── Flash messages ──────────────────────────────────────────── */
    .flash { padding:10px 16px; border-radius:8px; margin-bottom:12px;
             font-size:14px; border:1px solid; }
    .flash-success { background:#052e16; border-color:#166534; color:#4ade80; }
    .flash-error   { background:#450a0a; border-color:#991b1b; color:#f87171; }
    .flash-info    { background:#0c1a3a; border-color:#1e40af; color:#93c5fd; }
    /* ── Table ───────────────────────────────────────────────────── */
    .tbl { width:100%; border-collapse:collapse; font-size:13px; }
    .tbl th { text-align:start; padding:9px 14px;
              border-bottom:1px solid var(--border);
              color:var(--muted); font-weight:600;
              font-size:11px; text-transform:uppercase; letter-spacing:.05em; }
    .tbl td { padding:11px 14px; border-bottom:1px solid var(--border); }
    .tbl tr:last-child td { border-bottom:none; }
    .tbl tr:hover td { background:var(--surface2); }
    /* ── Utilities ───────────────────────────────────────────────── */
    .spinner { animation:spin 1s linear infinite; }
    @keyframes spin { to { transform:rotate(360deg); } }
    .drop-zone { border:2px dashed var(--border); border-radius:10px;
                 padding:20px; text-align:center; cursor:pointer;
                 transition:border-color .15s; }
    .drop-zone:hover, .drop-zone.dragover { border-color:var(--accent); }
    /* ── Lang switcher ───────────────────────────────────────────── */
    .lang-btn { font-size:12px; font-weight:600; padding:4px 10px;
                border-radius:6px; border:1px solid var(--border);
                color:var(--muted); text-decoration:none;
                transition:border-color .12s, color .12s; }
    .lang-btn.active { border-color:var(--accent); color:var(--accent); }
    .lang-btn:hover  { border-color:var(--muted); color:var(--text); }
    /* ── RTL number/email inputs stay LTR ───────────────────────── */
    [dir="rtl"] input[type="email"],
    [dir="rtl"] input[type="number"],
    [dir="rtl"] input[type="password"] { direction:ltr; text-align:start; }
    @media (max-width: 768px) {
      .sidebar { display:none; }
    }
  
/* Arabic typography */
html[lang="ar"] body {
    font-family: 'Cairo', system-ui, -apple-system, sans-serif;
}

/* ── Shared Brand Logo ───────────────────────────────────────── */

.brand-logo {
    display: block;
    width: auto;
    height: auto;
    object-fit: contain;
}

.brand-logo--header {
    max-width: 140px;
    max-height: 48px;
}

.brand-logo--login {
    width: 200px;
    max-width: 100%;
    margin-inline: auto;
}


/* ── Shared Application Layout ─────────────────────────────── */

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-credit-label {
    font-size: 12px;
    color: var(--muted);
}

.topbar-credit-value {
    font-weight: 700;
    color: var(--accent);
    font-size: 16px;
}

.topbar-language-switcher {
    display: flex;
    gap: 4px;
}

.topbar-username {
    font-size: 13px;
    color: var(--muted);
}

.topbar-logout {
    font-size: 13px;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: 7px;
    text-decoration: none;
}

.app-layout {
    display: flex;
}

.main-content {
    flex: 1;
    padding: 28px 28px 48px;
    min-height: calc(100vh - 56px);
}

/* ── Toast Notifications ───────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 72px;
    inset-inline-end: 20px;
    z-index: 1000;
    width: min(380px, calc(100vw - 40px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-inline-start: 4px solid var(--muted);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    font-size: 13px;
    line-height: 1.5;
    pointer-events: auto;
    animation: toast-in .2s ease-out;
    transition: opacity .25s ease, transform .25s ease;
}

.toast-success { border-inline-start-color: var(--success); }
.toast-error   { border-inline-start-color: var(--error); }
.toast-warning { border-inline-start-color: var(--warning); }
.toast-info    { border-inline-start-color: var(--muted); }

.toast-dismiss {
    flex-shrink: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.toast-dismiss:hover { color: var(--text); }

.toast.toast-hiding {
    opacity: 0;
    transform: translateY(-8px);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
    .toast-container {
        top: 12px;
        inset-inline: 12px;
        width: auto;
    }
}
