:root {
    --cs-bg: #f4f6f8;
    --cs-surface: #ffffff;
    --cs-ink: #16212e;
    --cs-muted: #61707f;
    --cs-line: #e3e8ee;
    --cs-brand: #0d7a6f;
    --cs-brand-dark: #0a5f57;
    --cs-side: #10222b;
    --cs-side-ink: #c9d6dd;
    --cs-accent: #f2b134;
    --cs-danger: #c0392b;
    --cs-radius: 12px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Noto Kufi Arabic", system-ui, -apple-system, sans-serif;
    background: var(--cs-bg);
    color: var(--cs-ink);
    font-size: 15px;
}
a { color: var(--cs-brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* guest (install / login) */
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.guest-card { background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: var(--cs-radius); padding: 32px; width: 100%; max-width: 440px; box-shadow: 0 8px 30px rgba(16, 34, 43, .08); }
.guest-card h1 { margin: 0 0 4px; font-size: 22px; }
.guest-brand { color: var(--cs-brand); }
.guest-sub { color: var(--cs-muted); margin: 0 0 24px; font-size: 14px; }

/* app layout */
.app-shell { display: flex; min-height: 100vh; }
.app-side { width: 240px; flex-shrink: 0; background: var(--cs-side); color: var(--cs-side-ink); display: flex; flex-direction: column; }
.app-side .brand { padding: 20px 20px 16px; color: #fff; font-size: 19px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08); }
.app-side .brand span { color: var(--cs-accent); }
.app-nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.app-nav a { color: var(--cs-side-ink); padding: 10px 12px; border-radius: 8px; display: block; font-size: 14px; }
.app-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.app-nav a.active { background: var(--cs-brand); color: #fff; }
.app-nav a.soon { opacity: .45; cursor: default; }
.app-side .side-foot { padding: 14px 20px; font-size: 12px; color: #7d919c; border-top: 1px solid rgba(255,255,255,.08); }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-top { background: var(--cs-surface); border-bottom: 1px solid var(--cs-line); padding: 12px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.app-top .spacer { flex: 1; }
.app-content { padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.page-title { font-size: 20px; margin: 0 0 4px; }
.page-sub { color: var(--cs-muted); margin: 0 0 20px; font-size: 14px; }

.card { background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: var(--cs-radius); padding: 20px; margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat { background: var(--cs-surface); border: 1px solid var(--cs-line); border-radius: var(--cs-radius); padding: 18px 20px; }
.stat .stat-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .stat-label { color: var(--cs-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat .stat-note { color: var(--cs-muted); font-size: 12px; margin-top: 4px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select {
    width: 100%; padding: 9px 12px; border: 1px solid var(--cs-line); border-radius: 8px; font-size: 14px; background: #fff; color: var(--cs-ink);
}
input:focus, select:focus { outline: 2px solid var(--cs-brand); outline-offset: -1px; border-color: var(--cs-brand); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--cs-brand); color: #fff; }
.btn:hover { background: var(--cs-brand-dark); }
.btn.secondary { background: #eef2f5; color: var(--cs-ink); }
.btn.secondary:hover { background: #e2e8ee; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.flash { background: #e7f6f3; border: 1px solid #bfe6df; color: #0a5f57; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.errors { background: #fdecea; border: 1px solid #f5c6c0; color: var(--cs-danger); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.errors ul { margin: 4px 0 0; padding-inline-start: 18px; }

table.list { width: 100%; border-collapse: collapse; background: var(--cs-surface); }
table.list th, table.list td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--cs-line); font-size: 14px; }
table.list th { color: var(--cs-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
table.list tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #e7f6f3; color: var(--cs-brand-dark); }
.tag.muted { background: #eef2f5; color: var(--cs-muted); }
.inline-form { display: inline; }
.topbar-select { padding: 7px 10px; border: 1px solid var(--cs-line); border-radius: 8px; font-size: 13px; background: #fff; }
.locale-switch a { font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.locale-switch a.active { background: var(--cs-brand); color: #fff; text-decoration: none; }
.empty { color: var(--cs-muted); padding: 24px; text-align: center; }
/* mobile : menu hamburger + tiroir */
.nav-toggle { display: none; }
.nav-overlay { display: none; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        min-width: 42px; height: 42px; border: 1px solid var(--cs-line); border-radius: 8px;
        background: #fff; font-size: 20px; color: var(--cs-ink); cursor: pointer; padding: 0 10px;
    }
    .app-side {
        position: fixed; inset-inline-start: 0; top: 0; bottom: 0; width: 270px; z-index: 40;
        transform: translateX(-105%); transition: transform .2s ease; overflow-y: auto;
        box-shadow: 0 0 40px rgba(16, 34, 43, .35);
    }
    [dir="rtl"] .app-side { transform: translateX(105%); }
    body.nav-open .app-side { transform: translateX(0); }
    .nav-overlay {
        display: block; position: fixed; inset: 0; background: rgba(16, 34, 43, .45); z-index: 30;
        opacity: 0; pointer-events: none; transition: opacity .2s;
    }
    body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }
    .app-top { padding: 10px 12px; gap: 10px; position: sticky; top: 0; z-index: 20; }
    .app-content { padding: 16px 12px; max-width: 100%; }
    .grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .grid.cols-2 { grid-template-columns: 1fr; }
    input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select {
        font-size: 16px; padding: 11px 12px;
    }
    .btn { min-height: 44px; padding: 12px 18px; }
    .btn.small { min-height: 38px; padding: 8px 14px; }
    .form-actions { flex-wrap: wrap; }
    table.list { min-width: 560px; }
    .topbar-select { max-width: 150px; }
    img, video, canvas { max-width: 100%; height: auto; }
}

@media (max-width: 480px) {
    .grid.cols-4 { grid-template-columns: 1fr 1fr; }
    .stat .stat-value { font-size: 19px; }
    .page-title { font-size: 18px; }
    .card { padding: 14px; }
}
