/* Sign-in page and users dashboard. Same colours as the editor. */
:root {
  --canvas: #ebecf0; --panel: #ffffff; --soft: #f3f4f7; --soft2: #e8eaef; --line: #e1e4ea; --line2: #d3d7de;
  --text: #0e1318; --muted: #5f6672; --accent: #8b3dff; --accent-dark: #7731d8; --accent-soft: #f1e8ff;
  --danger: #db1436; --ok: #0b8a4c; --ok-soft: #e2f6ea; --warn: #9a5b00; --warn-soft: #fff1d6;
  --brand: linear-gradient(90deg, #12b5c9 0%, #4a6cf7 45%, #8b3dff 100%);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Tajawal', 'Noto Sans Arabic', sans-serif;
  font-size: 14px; color: var(--text); background: var(--canvas); color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

button, .btn {
  font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line2); border-radius: 9px; padding: 8px 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
button:hover:not(:disabled), .btn:hover { background: var(--soft); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { background: var(--danger); border-color: var(--danger); color: white; }
button.danger:hover:not(:disabled) { background: #b90f2c; }
button.icon { padding: 7px; border-color: transparent; background: transparent; color: var(--muted); }
button.icon:hover:not(:disabled) { background: var(--soft2); color: var(--text); }
button.icon.red:hover:not(:disabled) { color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--accent); font-weight: 600; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }

input, select, textarea {
  font: inherit; color: inherit; background: white; border: 1px solid var(--line2); border-radius: 9px; padding: 8px 11px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label.field > * { font-weight: 400; color: var(--text); font-size: 14px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 6px; height: 54px; padding: 0 16px; color: white; background: var(--brand); }
.top .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.top .brand svg { width: 22px; height: 22px; }
.top .crumb { opacity: 0.85; font-weight: 500; padding-inline-start: 4px; }
.top button, .top .btn { background: transparent; border-color: transparent; color: white; padding: 7px 10px; }
.top button:hover:not(:disabled), .top .btn:hover { background: rgba(255, 255, 255, 0.16); }
.top .btn.solid { background: white; color: var(--text); padding: 8px 14px; }
.top .btn.solid:hover { background: #f0f1f5; }
.top .who { display: flex; align-items: center; gap: 8px; padding: 0 8px; font-weight: 600; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 24px; background: var(--brand); }
.signin .card { width: 380px; max-width: 100%; background: white; border-radius: 18px; padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 70px rgba(14, 19, 24, 0.3); }
.signin .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--accent); }
.signin .logo svg { width: 26px; height: 26px; }
.signin h1 { font-size: 22px; font-weight: 700; }
.signin button.primary { padding: 11px; font-size: 15px; }
.signin .foot { display: flex; justify-content: center; }

/* ---------- dashboard ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 26px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.head h1 { font-size: 24px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: white; border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 0 0 1px var(--line); }
.stat b { font-size: 28px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.live b { color: var(--ok); }
.stat.soon b { color: var(--warn); }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.card { background: white; border-radius: 14px; box-shadow: 0 0 0 1px var(--line); }
.tools { display: flex; align-items: center; gap: 8px; padding: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-inline-start: 34px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; }
.seg button { border: none; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 500; }
.seg button.on { background: white; color: var(--accent); box-shadow: 0 1px 3px rgba(14, 19, 24, 0.18); font-weight: 600; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
tr.off .person b, tr.off td.num { color: var(--muted); }
td.num { font-variant-numeric: tabular-nums; }
td.acts { white-space: nowrap; text-align: end; width: 1%; }
.person { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.person b { display: block; font-weight: 600; }
.person small { color: var(--muted); font-size: 12px; }
.avatar { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: white; font-weight: 700; font-size: 13px; flex: none; }
.avatar.on::after { content: ''; position: absolute; inset-inline-end: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #1fbf6b; box-shadow: 0 0 0 2px white; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { background: var(--ok-soft); color: var(--ok); }
.pill.disabled { background: var(--soft2); color: var(--muted); }
.pill.expired { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.tag.plain { background: var(--soft); color: var(--muted); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
td .sub.warn { color: var(--warn); font-weight: 600; }
.nw { white-space: nowrap; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.feed { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.feed h2 { font-size: 14px; font-weight: 700; }
.feed li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.35; }
.feed ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.feed .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--soft); color: var(--muted); }
.feed .dot svg { width: 14px; height: 14px; }
.feed .dot.login { background: var(--ok-soft); color: var(--ok); }
.feed .dot.failed, .feed .dot.deleted { background: #fde7ea; color: var(--danger); }
.feed .dot.created { background: var(--accent-soft); color: var(--accent); }
.feed time { display: block; font-size: 11.5px; color: var(--muted); }
.feed span { overflow-wrap: anywhere; }

/* ---------- dialogs ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(14, 19, 24, 0.45); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal { width: 460px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: white; border-radius: 16px; padding: 22px 24px; display: flex; flex-direction: column; gap: 13px; box-shadow: 0 20px 60px rgba(14, 19, 24, 0.3); }
.modal h2 { font-size: 19px; font-weight: 700; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inline { display: flex; gap: 6px; }
.inline input { flex: 1; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { padding: 4px 10px; font-size: 12px; font-weight: 500; background: var(--soft); border-color: transparent; }
.quick button:hover { background: var(--soft2); }
.btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 8px 26px rgba(14, 19, 24, 0.3); z-index: 20; }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .top .hide-s { display: none; }
}

/* ---------- phones ---------- */
body { -webkit-tap-highlight-color: transparent; }
@media (max-width: 720px) {
  input, select, textarea, label.field > input, label.field > select { font-size: 16px; } /* smaller text makes iPhones zoom the page on focus */
  .top { padding: 0 6px; gap: 2px; height: 50px; }
  .top .brand .name { display: none; }
  .top .crumb { opacity: 1; font-weight: 700; padding: 0; }
  .top button, .top .btn { padding: 7px 8px; font-size: 13px; }
  .top .btn.solid { padding: 7px 10px; }
  .wrap { padding: 16px 12px calc(40px + env(safe-area-inset-bottom, 0px)); gap: 14px; }
  .head h1 { font-size: 21px; }
  .head .muted { font-size: 13px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 24px; }
  .tools { padding: 10px; }
  .search { max-width: none; flex-basis: 100%; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 7px 6px; }

  /* every user becomes a card */
  .table-scroll { overflow: visible; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px 12px; border-top: 1px solid var(--line); }
  tbody tr:hover { background: none; }
  td { display: block; padding: 0; border: none; min-width: 0; }
  td:first-child { grid-column: 1 / -1; }
  td[data-l]::before { content: attr(data-l); display: block; margin-bottom: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
  td.nw { white-space: normal; }
  td.acts { width: auto; display: flex; justify-content: flex-end; align-items: flex-end; gap: 6px; }
  td.acts button.icon { padding: 9px; background: var(--soft); color: var(--text); }
  .person { min-width: 0; }
  .person > span:last-child { min-width: 0; overflow-wrap: anywhere; }

  .modal-bg { padding: 10px; align-items: end; }
  .modal { width: 100%; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 16px; max-height: calc(100dvh - 20px); }
  .btns button { flex: 1; padding: 11px; }
  .signin { padding: 14px; align-items: start; padding-top: 12vh; }
  .signin .card { padding: 24px 20px 18px; }
  .toast { left: 12px; right: 12px; transform: none; text-align: center; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
