:root {
  --bg: #f5f6fa; --card: #fff; --text: #181b26; --muted: #6b7185; --line: #e6e8f0;
  --accent: #5b5bf0; --accent-2: #8b5cf6; --accent-soft: #eeeeff; --danger: #e5484d;
  --shadow: 0 1px 2px rgba(20,24,40,.05), 0 8px 24px rgba(20,24,40,.06);
}
/* dark: follows the device unless the visitor chose a theme (html[data-theme]) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0d0f17; --card: #151824; --text: #eceef6; --muted: #8b91a8; --line: #232738; --accent-soft: #1f2140; --shadow: 0 8px 28px rgba(0,0,0,.4); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0d0f17; --card: #151824; --text: #eceef6; --muted: #8b91a8; --line: #232738; --accent-soft: #1f2140; --shadow: 0 8px 28px rgba(0,0,0,.4); color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
h1 { font-size: 24px; margin: 18px 0 4px; } h2 { font-size: 22px; margin: 0; } h3 { font-size: 15px; margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono, code { font-family: ui-monospace, Consolas, monospace; }
code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-size: 12px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(900px 500px at 15% -10%, rgba(91,91,240,.18), transparent), radial-gradient(700px 400px at 100% 100%, rgba(139,92,246,.14), transparent), var(--bg); }
.center-text { text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.auth-card { width: 100%; max-width: 400px; padding: 30px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }

label, .lbl { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 0; color: var(--text); }
input, textarea, select { width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; transition: .15s; }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91,91,240,.18); background: var(--card); }
textarea { resize: vertical; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

.btn { border: 0; cursor: pointer; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 10px; transition: .15s; color: var(--text); background: var(--accent-soft); display: inline-block; }
.btn:hover { filter: brightness(.96); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 14px rgba(91,91,240,.35); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: 13px; } .btn.wide { width: 100%; margin-top: 8px; }
.icon { border: 0; background: transparent; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px 10px; border-radius: 8px; } .icon:hover { background: var(--accent-soft); }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.tab { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 8px 14px; border-radius: 10px; cursor: pointer; }
.tab.active { color: var(--accent); background: var(--accent-soft); }
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.view { max-width: 1100px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; } .page-head p { margin: 4px 0 0; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; } .toolbar.tight { margin-bottom: 10px; }
.search { max-width: 320px; margin: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 11px; border-radius: 999px; cursor: pointer; }
.chip.on { color: #fff; border-color: transparent; background: var(--c, var(--accent)); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.client { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; transition: .15s; }
.client:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.client .top { display: flex; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; background: var(--c, var(--accent)); }
.client .nm { font-weight: 650; } .client .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.empty { grid-column: 1/-1; text-align: center; padding: 60px 20px; color: var(--muted); border: 2px dashed var(--line); border-radius: 16px; }

.email-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.recipients { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.recip { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; margin: 0; font-weight: 500; }
.recip:last-child { border-bottom: 0; } .recip:hover { background: var(--accent-soft); }
.recip input { width: auto; margin: 0; } .recip .e { color: var(--muted); font-size: 13px; margin-left: auto; }
.queue-head { display: flex; justify-content: space-between; align-items: center; }
.progress { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; margin: 6px 0 16px; }
#bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.queue-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.queue-list { max-height: 260px; overflow: auto; }
.q { display: flex; justify-content: space-between; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.q.next { font-weight: 700; color: var(--accent); } .q.done { color: var(--muted); } .q.skipped { color: var(--muted); text-decoration: line-through; }

.scrim { position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 20; backdrop-filter: blur(2px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%); background: var(--card); z-index: 21; overflow: auto; box-shadow: -20px 0 50px rgba(0,0,0,.2); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); } .drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-body { padding: 8px 22px 22px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .row.end { display: flex; justify-content: space-between; margin-top: 12px; }
.notes { border-top: 1px solid var(--line); padding-top: 18px; }
.note-add { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 14px; } .note-add textarea { margin: 0; }
.note { background: var(--bg); border-radius: 12px; padding: 11px 14px; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; }
.note .when { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-top: 6px; white-space: normal; }
.note .when button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12px; } .note .when button:hover { color: var(--danger); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.dlg { border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(420px, 92vw); background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(10,12,20,.5); backdrop-filter: blur(2px); } .dlg h3 { font-size: 17px; } .dlg .row.end { margin-top: 18px; }
.wide-dlg { width: min(480px, 94vw); } .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 13px; margin-top: 16px; } .check input { width: auto; margin-top: 3px; }
.hint { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 14px 0 0; }
.set-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; } hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.set-grid .btn { margin-top: 14px; } @media (max-width: 760px) { .set-grid { grid-template-columns: 1fr; } }
.acct { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.acct .who { display: flex; align-items: center; gap: 12px; } .acct .dot { width: 10px; height: 10px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px rgba(16,185,129,.18); }
.acct .dot.off { background: var(--muted); box-shadow: none; } .acct p { margin: 2px 0 0; }
#view-admin .card { margin-bottom: 16px; }
.gen { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; } .gen label { margin: 0; } .gen input { width: 160px; }
.keys { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-family: ui-monospace, Consolas, monospace; user-select: all; margin: 14px 0 0; }
.tbl-wrap { overflow: auto; max-height: 380px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td .btn { margin-right: 4px; }
@media (max-width: 760px) {
  .email-layout { grid-template-columns: 1fr; } .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; } .user .muted { display: none; } .view { padding: 18px 14px; }
}
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; } .links a { background: var(--card); border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; font-weight: 600; font-size: 12.5px; }
.legal { max-width: 760px; margin: 0 auto; padding: 36px 20px 80px; } .legal h1 { font-size: 30px; margin: 18px 0 4px; } .legal h2 { font-size: 17px; margin: 28px 0 6px; } .legal p, .legal li { color: var(--text); opacity: .88; } .legal ul { padding-left: 20px; } .back { font-weight: 600; font-size: 14px; } .terms-check { margin-top: 16px; } .terms-check a { text-decoration: underline; }

/* ---- smoother transitions ---- */
:root { --ease: cubic-bezier(.22, .8, .3, 1); }
.view, #auth, #licence, #app { animation: viewIn .38s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
.scrim { animation: fadeIn .22s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.drawer { animation: slide .32s var(--ease) both; }
@keyframes slide { from { transform: translateX(48px); opacity: 0; } }
.drawer.closing { animation: slideOut .2s ease-in forwards; } .scrim.closing { animation: fadeOut .2s ease forwards; }
@keyframes slideOut { to { transform: translateX(48px); opacity: 0; } } @keyframes fadeOut { to { opacity: 0; } }
dialog.dlg[open] { animation: pop .28s var(--ease); } dialog.dlg[open]::backdrop { animation: fadeIn .25s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.client, .btn, .chip, .tab, input, textarea, .recip { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s ease, background-color .2s ease, color .2s ease, filter .2s ease, opacity .2s ease; }
.client:hover { transform: translateY(-3px); } .btn:active { transform: scale(.97); }
.toast { transition: opacity .3s var(--ease), transform .35s var(--ease); }
#bar { transition: width .5s var(--ease); }
/* reduced motion: from the device setting, unless the visitor chose "play animations" (html.motion-on); or when they chose "pause" (html.motion-off) */
@media (prefers-reduced-motion: reduce) { html:not(.motion-on) *, html:not(.motion-on) *::before, html:not(.motion-on) *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }
html.motion-off *, html.motion-off *::before, html.motion-off *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }

.banner { background: #7f1d1d; color: #fff; text-align: center; padding: 10px 16px; font-size: 14px; font-weight: 600; } .banner a { color: #fff; text-decoration: underline; }

/* phones: the tab bar scrolls sideways instead of stretching the whole page */
.topbar nav { min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.topbar nav::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex: none; }
@media (max-width: 760px) { .topbar nav { flex: 1 1 100%; order: 3; } }
body { overflow-x: clip; }
dialog.dlg, dialog.cdlg { max-width: calc(100vw - 24px); }
