:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #1c2321;
  --muted: #5f6b67;
  --line: #dfe3df;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --danger: #b4321f;
  --danger-soft: #fbe9e5;
  --warn-soft: #fdf3dc;
  --ok: #1f7a3a;
  --radius: 10px;
  --font: "Segoe UI", "Noto Sans Arabic", "Noto Sans", Tahoma, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131716;
    --surface: #1b201f;
    --ink: #e7ebe9;
    --muted: #9aa5a1;
    --line: #2e3533;
    --accent: #3fb59d;
    --accent-ink: #0d1a17;
    --accent-soft: #1d3530;
    --danger: #f0846f;
    --danger-soft: #3a211c;
    --warn-soft: #3a3120;
    --ok: #6cc98a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .75rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.5rem; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 2rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--ink); display: inline-flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem;
  border-radius: 7px; background: var(--accent); color: var(--accent-ink); font-size: 1rem;
}
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a, .link-btn {
  padding: .4rem .7rem; border-radius: 8px; color: var(--muted); font: inherit;
}
.nav a:hover, .link-btn:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); background: var(--accent-soft); font-weight: 600; }
.nav .lang { font-weight: 600; }
.link-btn { background: none; border: 0; cursor: pointer; }

/* layout */
.wrap { max-width: 1120px; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2rem) 4rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.5rem); margin-bottom: 1.25rem;
}
.narrow { max-width: 520px; }
.login-card { max-width: 380px; margin: 8vh auto 0; }
.guest .topbar { border-bottom: 0; background: transparent; }

/* forms */
label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .9rem; }
input[type=text], input[type=url], input[type=password], input[type=search], select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; min-width: 0;
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.ltr-input, .ltr-input input { direction: ltr; text-align: left; }
.prefixed {
  display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: var(--surface);
}
.prefixed:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.prefixed .prefix { padding: .55rem .2rem .55rem .7rem; color: var(--muted); font-weight: 400; white-space: nowrap; }
.prefixed input { border: 0; padding-left: 0; outline: none; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.stack { display: grid; gap: 1rem; }
.create-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.create-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.span-2, .span-all { grid-column: 1 / -1; }
.actions-end { display: flex; justify-content: flex-end; gap: .5rem; }
@media (max-width: 720px) {
  .create-grid, .create-grid.three { grid-template-columns: 1fr; }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer;
  padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-small { padding: .25rem .6rem; font-size: .8rem; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ok { color: var(--ok); }
.btn.is-copied { color: var(--ok); border-color: var(--ok); }
form.inline { display: inline; margin: 0; }

/* flashes */
.flash {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem;
  padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem;
  border: 1px solid var(--line); background: var(--surface);
}
.flash-success, .flash-created { background: var(--accent-soft); border-color: transparent; }
.flash-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.flash-warn, .flash-password { background: var(--warn-soft); border-color: transparent; }
.copy-row { display: inline-flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
code { font-family: var(--mono); font-size: .95rem; }

/* list */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs { display: inline-flex; background: var(--bg); padding: .2rem; border-radius: 9px; }
.tabs a { padding: .35rem .9rem; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.filters input[type=search] { max-width: 300px; }
.filters select { width: auto; }

.table-wrap { overflow-x: auto; }
table.links { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.links th {
  text-align: start; font-weight: 600; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .02em;
  padding: .5rem .6rem; border-bottom: 1px solid var(--line);
}
table.links td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.links tr:last-child td { border-bottom: 0; }
.is-deleted td { color: var(--muted); }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.short-cell { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dest { max-width: 380px; }
.dest a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: end; }
.row-actions > * + * { margin-inline-start: .25rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

@media (max-width: 760px) {
  table.links thead { display: none; }
  table.links, table.links tbody, table.links tr, table.links td { display: block; width: 100%; }
  table.links tr { border-bottom: 1px solid var(--line); padding: .6rem 0; }
  table.links td { border: 0; padding: .2rem 0; }
  table.links td[data-label]::before {
    content: attr(data-label); display: block; color: var(--muted); font-size: .72rem; font-weight: 600;
  }
  .num, .row-actions { text-align: start; }
  .dest { max-width: none; }
  .dest a { white-space: normal; word-break: break-all; }
}

/* misc */
.ltr { direction: ltr; unicode-bidi: isolate; }
.strong { font-weight: 600; }
.big { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.back { color: var(--muted); }
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 99px; background: var(--bg); font-size: .78rem; font-weight: 600; }
.pill-admin { background: var(--accent-soft); color: var(--accent); }
.edit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.danger-zone { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1rem; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.hist-meta { display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.hist-change { margin-top: .2rem; display: grid; gap: .15rem; word-break: break-all; }
.hist-change del { color: var(--muted); }

@media (max-width: 560px) {
  .filters { justify-content: stretch; }
  .filters input[type=search] { max-width: none; flex: 1 1 100%; }
  .list-head .tabs { order: -1; }
}

/* two-factor */
.setup-steps { padding-inline-start: 1.2rem; display: grid; gap: 1.1rem; }
.qr { width: 220px; max-width: 100%; margin: .75rem 0; background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--line); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { letter-spacing: .05em; word-break: break-all; }
.code-input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .3em; text-align: center !important; max-width: 12rem; }
.setup-form { margin-top: .6rem; }
.narrow { margin-inline: auto; }
