:root {
  --primary: #1F8A86;
  --primary-dark: #0E2A2E;
  --accent: #2BB6B0;
  --bg: #F5F7F8;
  --surface: #ffffff;
  --border: #E2E8EA;
  --text: #0E2A2E;
  --muted: #6B7A7C;
  --green: #1F8A86;
  --red: #C92A38;
  --amber: #B97509;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.07);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(160deg, #0E2A2E, #1F8A86); }
.login-card { background: #fff; border-radius: 20px; padding: 40px 32px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.25); text-align: center; }
.login-logo { font-size: 40px; }
.login-card h1 { margin: 12px 0 4px; font-size: 22px; }
.login-tagline { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
.login-error { color: var(--red); background: #FDECEC; padding: 10px; border-radius: 10px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: right; }
.login-card label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login-card input { padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; }
.login-card button { padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; }

/* topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 22px; height: 60px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 24px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.top-user { display: flex; align-items: center; gap: 12px; }
.role-pill { background: #EAF6F6; color: var(--primary); padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.logout-btn { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--red); font-family: inherit; font-size: 12.5px; }

/* layout */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 220px; background: var(--surface); border-left: 1px solid var(--border); padding: 16px 10px; flex-shrink: 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar a { padding: 10px 14px; border-radius: 10px; font-weight: 500; color: var(--text); }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: #EAF6F6; color: var(--primary); font-weight: 700; }
.content { flex: 1; padding: 24px; overflow-x: auto; }

/* cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-card .n { font-size: 28px; font-weight: 700; color: var(--primary-dark); }
.stat-card .t { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head .sub { color: var(--muted); font-size: 12px; }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: right; padding: 10px 12px; background: var(--bg); color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #F7FAFA; }
.mono { font-family: ui-monospace, monospace; direction: ltr; unicode-bidi: embed; }

/* badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.badge.green { background: #EAF6F6; color: var(--green); }
.badge.red { background: #FDECEC; color: var(--red); }
.badge.amber { background: #FFF8E6; color: var(--amber); }
.badge.gray { background: #EEF1F2; color: var(--muted); }
.badge.blue { background: #EAF1FB; color: #2563EB; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn:hover { opacity: .9; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; font-family: inherit; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #EAF6F6; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }

/* toast */
#toast { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast-item { padding: 12px 18px; border-radius: 10px; color: #fff; font-size: 13px; box-shadow: var(--shadow); }

/* empty */
.empty { text-align: center; color: var(--muted); padding: 40px; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 14px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
