/* Behind the Sets — a production-office ledger: calm surfaces, condensed headings, one teal accent. */
:root {
  --bg: #F1F2EF; --surface: #FFFFFF; --sunk: #F7F8F5; --line: #DADDD6; --ink: #1A1E21; --muted: #646B6E;
  --accent: #1F5A60; --accent-ink: #FFFFFF; --accent-soft: #E3EEEE;
  --brass: #A87418; --warn: #9A3B12; --warn-soft: #FBEDE5; --ok: #2F6B3A; --ok-soft: #E6F1E7;
  --display: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --body: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131618; --surface: #1B1F22; --sunk: #171A1D; --line: #2C3236; --ink: #E7EAE6; --muted: #9AA2A4;
    --accent: #6FB3B8; --accent-ink: #0E1416; --accent-soft: #1E3133;
    --brass: #E0AE52; --warn: #F09A72; --warn-soft: #3A2219; --ok: #7CC48A; --ok-soft: #1C2C20;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131618; --surface: #1B1F22; --sunk: #171A1D; --line: #2C3236; --ink: #E7EAE6; --muted: #9AA2A4;
  --accent: #6FB3B8; --accent-ink: #0E1416; --accent-soft: #1E3133;
  --brass: #E0AE52; --warn: #F09A72; --warn-soft: #3A2219; --ok: #7CC48A; --ok-soft: #1C2C20;
  color-scheme: dark;
}
[dir="rtl"] { --body: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, sans-serif; --display: "IBM Plex Sans Arabic", "Barlow Condensed", sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
  white-space: nowrap; min-height: 42px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); border-color: var(--warn); background: transparent; }
.btn.small { padding: 6px 11px; min-height: 34px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .g { width: 18px; height: 18px; flex: none; }

.field { display: grid; gap: 6px; }
.field > label, .field > .lbl { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
[dir="rtl"] .field > label, [dir="rtl"] .field > .lbl { letter-spacing: 0; text-transform: none; font-size: 13px; }
.input, select.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunk); min-height: 42px; }
.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.err { font-size: 13px; color: var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 9px 12px; margin: 0; }
.okmsg { font-size: 14px; color: var(--ok); background: var(--ok-soft); border-radius: var(--radius); padding: 10px 12px; margin: 0; }

/* ---------- Public pages (sign in, invite, welcome) ---------- */
.public { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.public .side { background: var(--ink); color: var(--bg); padding: 48px clamp(24px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
:root[data-theme="dark"] .public .side, :root:not([data-theme="light"]) .public .side { }
.public .side::after { content: ""; position: absolute; inset: auto -40px -60px auto; width: 340px; height: 340px;
  background: repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.06) 22px 44px); transform: rotate(-8deg); border-radius: 8px; }
[dir="rtl"] .public .side::after { inset: auto auto -60px -40px; }
.wordmark { font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: .12em; text-transform: uppercase; display: flex; align-items: center; gap: 10px; }
[dir="rtl"] .wordmark { letter-spacing: .04em; }
.wordmark .mark { width: 28px; height: 22px; border: 2px solid currentColor; border-radius: 3px; position: relative; flex: none; }
.wordmark .mark::before { content: ""; position: absolute; left: -2px; right: -2px; top: -9px; height: 7px; border: 2px solid currentColor; border-radius: 2px;
  background: repeating-linear-gradient(110deg, currentColor 0 4px, transparent 4px 9px); }
.public .side h1 { font-family: var(--display); font-weight: 700; font-size: clamp(40px, 5.2vw, 68px); line-height: .98; margin: 0 0 18px; max-width: 12ch; text-wrap: balance; }
.public .side p { font-size: 17px; max-width: 40ch; opacity: .78; margin: 0; }
.public .side .foot { font-size: 13px; opacity: .6; position: relative; z-index: 1; }
.public .main { display: grid; place-items: center; padding: 40px 20px; }
.card { width: min(420px, 100%); display: grid; gap: 18px; }
.card h2 { font-family: var(--display); font-size: 34px; font-weight: 700; margin: 0; line-height: 1.05; }
.card .lead { color: var(--muted); margin: 0; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.langswitch { position: fixed; top: 14px; inset-inline-end: 14px; z-index: 5; }
.invite-badge { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 16px; display: grid; gap: 4px; }
.invite-badge b { font-family: var(--display); font-size: 24px; }
@media (max-width: 860px) {
  .public { grid-template-columns: 1fr; }
  .public .side { padding: 28px 20px 32px; min-height: auto; gap: 28px; }
  .public .side h1 { font-size: 38px; }
  .public .side .foot { display: none; }
}

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar .wordmark { font-size: 18px; color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { padding: 8px 12px; border-radius: var(--radius); text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.topbar nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.topbar .spacer { flex: 1; }
.wsselect { max-width: 220px; min-height: 36px; padding: 6px 10px; }
.usermenu { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who { display: grid; line-height: 1.2; font-size: 13px; max-width: 200px; }
.who small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 20px 64px; display: grid; gap: 24px; }
.eyebrow { font-family: var(--display); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; color: var(--muted); }
[dir="rtl"] .eyebrow { letter-spacing: 0; }
.page h1 { font-family: var(--display); font-weight: 700; font-size: 44px; line-height: 1; margin: 4px 0 6px; }
.page .lead { color: var(--muted); margin: 0; max-width: 60ch; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
@media (max-width: 720px) {
  .who { display: none; }
  .topbar nav a { padding: 8px 9px; }
  .page h1 { font-size: 34px; }
  .wsselect { max-width: 160px; }
}

/* ---------- Home tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 10px; align-content: start; position: relative; }
.tile h3 { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.tile .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.tile .ico { width: 40px; height: 40px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.lvl-manage { border-color: var(--accent); color: var(--accent); }
.pill.lvl-edit { border-color: var(--brass); color: var(--brass); }
.pill.lvl-view { border-color: var(--muted); }
.pill.lvl-none { opacity: .7; border-style: dashed; }
.pill.role-owner { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.role-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Team ---------- */
.panelbox { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panelbox > header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--accent-soft); gap: 10px; flex-wrap: wrap; }
.panelbox > header h2 { margin: 0; font-family: var(--display); font-size: 20px; letter-spacing: .06em; text-transform: uppercase; }
[dir="rtl"] .panelbox > header h2 { letter-spacing: 0; }
.rows .row { display: grid; grid-template-columns: minmax(0, 2fr) 110px minmax(0, 1.3fr) minmax(0, 1.5fr) 190px; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.rows .row .c-a { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rows .row:first-child { border-top: 0; }
.rows .colhead { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-block: 8px; }
.person { display: flex; gap: 10px; align-items: center; min-width: 0; }
.person .nm { font-weight: 600; overflow-wrap: anywhere; }
.person .em { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.access { display: grid; gap: 3px; font-size: 13px; justify-items: start; }
.access small { color: var(--muted); }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; }
.mlabel { display: none; }
@media (max-width: 820px) {
  .rows .colhead { display: none; }
  .rows .row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "p a" "r r" "c c" "b b"; gap: 8px; }
  .rows .row .c-p { grid-area: p; } .rows .row .c-r { grid-area: r; } .rows .row .c-c { grid-area: c; }
  .rows .row .c-b { grid-area: b; } .rows .row .c-a { grid-area: a; }
  .mlabel { display: inline-block; min-width: 96px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .access { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
}

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10,12,14,.45); z-index: 30; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-end: 0; width: min(480px, 100%); background: var(--surface); z-index: 31; display: flex; flex-direction: column; border-inline-start: 1px solid var(--line); }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.drawer h3 { margin: 0; font-family: var(--display); font-size: 26px; font-weight: 700; }
.drawer form, .drawer .body { flex: 1; overflow: auto; padding: 18px 20px; display: grid; gap: 18px; align-content: start; }
.drawer footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.x { all: unset; cursor: pointer; padding: 8px; border-radius: var(--radius); color: var(--muted); line-height: 1; }
.x:hover { background: var(--accent-soft); color: var(--ink); }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg label { position: relative; text-align: center; padding: 9px 6px; cursor: pointer; font-size: 13px; font-weight: 600; border-inline-start: 1px solid var(--line); background: var(--sunk); }
.seg label:first-child { border-inline-start: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -3px; }
.sysblock { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; }
.sysblock h4 { margin: 0; font-family: var(--display); font-size: 20px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.projlist { display: grid; gap: 6px; max-height: 180px; overflow: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--sunk); }
.linkbox { font-family: var(--mono); font-size: 13px; padding: 12px; background: var(--sunk); border: 1px dashed var(--line); border-radius: var(--radius); overflow-wrap: anywhere; user-select: all; }
.sharebtns { display: grid; gap: 8px; }

/* ---------- Toast & misc ---------- */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 11px 16px; border-radius: var(--radius); font-weight: 500; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.toast.bad { background: var(--warn); color: #fff; }
.center { min-height: 60vh; display: grid; place-items: center; text-align: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media (prefers-reduced-motion: no-preference) { .drawer { animation: slide .18s ease-out; } @keyframes slide { from { transform: translateX(24px); opacity: .6; } } [dir="rtl"] .drawer { animation-name: slidertl; } @keyframes slidertl { from { transform: translateX(-24px); opacity: .6; } } }
