/* Xeetek portal. Logical properties (inline-start/end) throughout, so Arabic mirrors without extra rules. */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --text: #172033;
  --muted: #5a6478;
  --border: #dde3eb;
  --primary: #0b5c8e;
  --primary-hover: #094c75;
  --primary-ink: #ffffff;
  --primary-soft: #e3f0f8;
  --ok: #067647;
  --ok-soft: #e6f4ec;
  --warn: #9a4a06;
  --warn-soft: #fdf1e3;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --surface: #171e29;
    --surface-2: #1e2633;
    --text: #e7ebf2;
    --muted: #9aa5b8;
    --border: #2b3544;
    --primary: #4ea3db;
    --primary-hover: #6db5e4;
    --primary-ink: #08131c;
    --primary-soft: #16334a;
    --ok: #4fc58a;
    --ok-soft: #12301f;
    --warn: #f0a252;
    --warn-soft: #3a2810;
    --bad: #f07067;
    --bad-soft: #3b1714;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

:lang(ar) body { font-size: 16px; line-height: 1.7; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; unicode-bidi: embed; }
.hidden { display: none; }

/* Shell: sidebar and main area */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 1.25rem .875rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand { display: flex; align-items: baseline; gap: .375rem; padding-inline: .5rem; color: var(--text); font-weight: 700; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--primary); font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: .125rem; }
.nav a {
  display: block;
  padding: .5rem .75rem;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav-title { padding-inline: .75rem; margin-top: .75rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .scope { font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }

.content { padding: 2rem; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

/* Cards and grids */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1.25rem; }
.grid > .card, .choice > .card { margin-top: 0; }
.auth-card form + p { margin: 1rem 0 0; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat .label { color: var(--muted); font-size: .875rem; }
.stat .value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field .hint { color: var(--muted); font-size: .825rem; }
.input, .select {
  width: 100%;
  padding: .625rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.input:focus, .select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.input[readonly] { background: var(--surface-2); }
.inline-form { display: inline; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .575rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: var(--border); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .75rem; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: none; }
.table .actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-block;
  padding: .125rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--primary-soft); color: var(--primary); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--primary-soft); color: var(--text); }
.alert ul { margin: .25rem 0 0; padding-inline-start: 1.25rem; }

/* A secret shown once: invitation links, recovery codes */
.secret { display: flex; gap: .5rem; align-items: stretch; }
.secret .input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; direction: ltr; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; padding: 1rem; background: var(--surface-2); border-radius: 8px; direction: ltr; }
.codes code { font-size: 1rem; }
.qr { display: block; width: 180px; height: 180px; border-radius: 8px; background: #fff; padding: 8px; image-rendering: pixelated; }

.choice { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.choice .card { display: flex; flex-direction: column; gap: .5rem; }
.choice .card .grow { flex: 1; }
.recommended { border-color: var(--primary); }

.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* Sign-in pages */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; gap: 1.25rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 760px; }
.auth .brand { font-size: 1.35rem; }
.auth-foot { display: flex; gap: 1rem; color: var(--muted); font-size: .85rem; }

.lang { color: var(--muted); font-weight: 500; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { border-inline-end: none; border-bottom: 1px solid var(--border); padding: .75rem 1rem; gap: .75rem; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-title { display: none; }
  .topbar { padding: .75rem 1rem; flex-wrap: wrap; }
  .content { padding: 1rem; }
  .codes { grid-template-columns: 1fr; }
}
