:root {
  --bg: #f3f5fb; --card: #fff; --side: #f7f8fc; --text: #1c2438; --muted: #8791a7; --line: #e9edf5; --hover: #f1f4fb;
  --primary: #2f6bf0; --primary-soft: #e8f0ff; --danger: #e5484d; --ok: #12915f; --warn: #d98a06; --hot: #fdf3d0;
  --shadow: 0 1px 2px rgba(28, 36, 56, .04), 0 4px 14px rgba(28, 36, 56, .05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light; /* the browser's own controls follow the page's theme, never the system's when they differ */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --bg: #0e121a; --card: #161b26; --side: #121722; --text: #e6e9f2; --muted: #8a93a8; --line: #252c3a; --hover: #1d2432; --primary: #6b9bff; --primary-soft: #1c2a47; --danger: #ff7b80; --ok: #4ccf96; --warn: #f0b13a; --hot: #3a3416; --shadow: 0 1px 2px rgba(0, 0, 0, .3); }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #0e121a; --card: #161b26; --side: #121722; --text: #e6e9f2; --muted: #8a93a8; --line: #252c3a; --hover: #1d2432; --primary: #6b9bff; --primary-soft: #1c2a47; --danger: #ff7b80; --ok: #4ccf96; --warn: #f0b13a; --hot: #3a3416; --shadow: 0 1px 2px rgba(0, 0, 0, .3); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h3, h4, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.ico { display: inline-flex; flex: none; }
.muted { color: var(--muted); }
.dim { color: var(--muted); }
.pad { padding: 20px; }
.center { display: flex; justify-content: center; }
.grow { flex: 1; }

/* ---------- inputs ---------- */
/* every kind of text-like box (a new type such as tel/email must never fall back to the browser's own, dark-theme, look) */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):not([type=color]):not([type=image]), select, textarea) {
  width: 100%; min-height: 38px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
/* check boxes and radio buttons drawn by us, so they look the same in every browser and both themes */
input[type=checkbox] { appearance: none; -webkit-appearance: none; flex: none; width: 17px; height: 17px; margin: 0; border: 1.5px solid color-mix(in srgb, var(--muted) 70%, transparent); border-radius: 5px; background: var(--card); display: inline-grid; place-content: center; cursor: pointer; transition: background .12s, border-color .12s; vertical-align: middle; }
input[type=checkbox]:hover { border-color: var(--primary); }
input[type=checkbox]:checked, input[type=checkbox]:indeterminate { background: var(--primary); border-color: var(--primary); }
input[type=checkbox]:checked::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
input[type=checkbox]:indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border-radius: 1px; }
input[type=checkbox]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input[type=checkbox]:disabled { opacity: .5; cursor: not-allowed; }
select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238791a7' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 6px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; font-weight: 600; white-space: nowrap; transition: filter .15s, background .15s; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 32%, transparent); }
.btn-ghost { background: var(--card); color: var(--primary); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); filter: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-green { background: #17a869; color: #fff; }
.btn-blue { background: #2f6bf0; color: #fff; }
.btn-teal { background: #12a58a; color: #fff; box-shadow: 0 4px 12px rgba(18, 165, 138, .3); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--primary); }
.icon-btn.danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.round-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--muted); }
.round-btn:hover { color: var(--primary); }
.round-btn.dark { background: #262b3b; color: #fff; border-color: #262b3b; }
.dot { position: absolute; top: 5px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; border: 2px solid var(--card); }

/* ---------- chips / avatar ---------- */
.chip { display: inline-block; margin-top: 4px; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--hover); color: var(--muted); }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.bad { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chip.warn { background: color-mix(in srgb, var(--warn) 17%, transparent); color: var(--warn); }
.chip.wait { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.chip.off { background: var(--hover); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips .chip { margin: 0; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 14px; }
.avatar.c0 { background: #e4e8ff; color: #4a56d6; } .avatar.c1 { background: #ffe3ef; color: #d2347a; } .avatar.c2 { background: #dcf5ea; color: #138a5c; }
.avatar.c3 { background: #fff0d4; color: #b7700a; } .avatar.c4 { background: #e3f1fb; color: #1a76b5; } .avatar.c5 { background: #efe3fb; color: #8a3bc4; }
:root[data-theme="dark"] .avatar { filter: brightness(.85) saturate(1.1); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; position: relative; transition: grid-template-columns .2s; }
.shell.narrow { grid-template-columns: 68px minmax(0, 1fr); }
.side { position: sticky; top: 0; height: 100vh; background: var(--side); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 20px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 0 6px; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; flex: none; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px; color: var(--text); font-weight: 600; opacity: .85; white-space: nowrap; }
.nav-item:hover { background: var(--hover); }
.nav-item.on { background: var(--card); color: var(--primary); box-shadow: var(--shadow); opacity: 1; }
.collapse { position: fixed; left: 206px; top: 360px; z-index: 40; width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow); transition: left .2s; }
.shell.narrow .collapse { left: 50px; }
.shell.narrow .nav-item span:not(.ico), .shell.narrow .brand-name { display: none; }
.shell.narrow .nav-item { justify-content: center; padding: 11px 0; }
.shell.narrow .brand { justify-content: center; padding: 0; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 28px; background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.sep { width: 1px; height: 22px; background: var(--line); }
.wrap-pop { position: relative; display: inline-flex; }
.user { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 2px 4px; border-radius: 10px; color: var(--muted); }
.user-text { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.user-text b { color: var(--text); font-size: 13px; }
.user-text small { font-size: 10px; font-weight: 700; color: var(--primary); letter-spacing: .04em; text-transform: uppercase; }
.popover { position: absolute; top: calc(100% + 8px); right: 0; min-width: 190px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .16); padding: 6px; z-index: 50; }
.bell-panel { width: 310px; padding: 0; overflow: hidden; }
.popover-head { padding: 12px 14px; font-weight: 700; border-bottom: 1px solid var(--line); }
.bell-list { max-height: 340px; overflow: auto; }
.note { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--text); }
.note:hover { background: var(--hover); }
.note-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.note-text b { color: var(--primary); }
.note-text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; text-align: left; }
.menu-item:hover { background: var(--hover); }
.view { padding: 26px 28px 60px; display: flex; flex-direction: column; gap: 18px; outline: none; max-width: 1500px; width: 100%; }
.only-mobile { display: none; }
.scrim { display: none; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.pad-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head small { display: block; color: var(--muted); font-size: 12px; }
.plus-badge { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.page-head { display: flex; flex-direction: column; gap: 2px; }
.page-head.split { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 800; }
.live-dot { color: var(--ok); font-weight: 600; font-size: 12px; }
.live-dot::before { content: "• "; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }

/* stat cards */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stat { position: relative; overflow: hidden; border-radius: 16px; padding: 16px 20px 14px; color: #fff; min-height: 118px; box-shadow: 0 8px 22px rgba(0, 0, 0, .12); }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.stat.violet { background: linear-gradient(135deg, #6b7ae6, #7b4fb8); } .stat.pink { background: linear-gradient(135deg, #ee4d9a, #9b3fe0); }
.stat.teal { background: linear-gradient(135deg, #14a396, #16a8ea); } .stat.blue { background: linear-gradient(135deg, #2f8cf0, #3a62df); }
.stat.amber { background: linear-gradient(135deg, #f6a21a, #f5701f); } .stat.green { background: linear-gradient(135deg, #14b58a, #0f8f5e); }
.stat-ico { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .22); }
.stat-chip { position: absolute; right: 14px; top: 14px; z-index: 1; font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 10px; background: rgba(255, 255, 255, .22); }
.stat-value { font-size: 32px; font-weight: 800; line-height: 1.15; margin-top: 10px; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; opacity: .85; position: relative; z-index: 1; }

/* create post */
.create { padding: 0; overflow: hidden; }
.create .card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.form-rows { padding: 16px 20px 6px; display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.input-ico { position: relative; display: block; }
.input-ico .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-ico input { padding-left: 36px; }
.create .center { padding: 8px 20px 18px; }
.toolbar-card { padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.search { position: relative; display: block; flex: 1 1 260px; max-width: 420px; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 36px; }
.export { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { padding: 14px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.filters input[type=date], .filters select { width: auto; min-width: 130px; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 12px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 12px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: color-mix(in srgb, var(--muted) 35%, transparent); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch.inline { margin: 2px 0; }
.chips-row { display: flex; flex-wrap: wrap; gap: 14px; }
.mini { display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 170px; }
.mini small { display: block; font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--muted); }
.mini b { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; line-height: 1.2; }
.mini b.green { color: var(--ok); }
.mini-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 12px; }
.mini-ico.blue { background: #e1ecff; color: #2f6bf0; } .mini-ico.amber { background: #fff0d4; color: #d98a06; } .mini-ico.green { background: #dcf5ea; color: #138a5c; }
.tag-new { font-size: 11px; font-weight: 700; padding: 0 7px; border-radius: 8px; background: #fde4e4; color: #e5484d; }
.list-info { color: var(--muted); font-size: 13px; }
.select-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.select-bar .btn { height: 32px; }

/* ---------- tables ---------- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 13px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--hover) 60%, transparent); white-space: nowrap; }
table.data td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--hover) 55%, transparent); }
table.data tr.hot td { background: var(--hot); }
table.data tr.fresh { animation: pop 1.8s ease-out; }
@keyframes pop { from { box-shadow: inset 3px 0 0 var(--primary); } to { box-shadow: inset 3px 0 0 transparent; } }
tr.off td { opacity: .55; }
th.chk, td.chk { width: 34px; padding-right: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.time { font-weight: 700; white-space: nowrap; }
td.time small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.post-cell { max-width: 440px; }
.post-title { display: block; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.post-title:hover { color: var(--primary); }
.post-title.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; }
td.post-col { max-width: 190px; }
td.actions { white-space: nowrap; }
td.actions .btn-sm { margin: 0; }
.profile-cell { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.who a, .who .name { font-weight: 700; overflow-wrap: anywhere; }
.who small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
td.text { min-width: 180px; max-width: 320px; overflow-wrap: anywhere; }
td.phone { white-space: nowrap; }
.phone-btn { border: 0; background: transparent; padding: 2px 0; font-weight: 800; color: var(--primary); letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.phone-btn:hover { text-decoration: underline; }
.phone-n { color: var(--primary); font-weight: 700; font-variant-numeric: tabular-nums; }
td.code { color: var(--primary); font-weight: 700; white-space: nowrap; }
td.prod { min-width: 160px; max-width: 220px; font-weight: 500; overflow-wrap: anywhere; }
td.addr { min-width: 150px; max-width: 220px; overflow-wrap: anywhere; }
.status { width: auto; min-height: 30px; padding: 3px 28px 3px 12px; border-radius: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.status.s-new, .status.o-pending { border-color: color-mix(in srgb, var(--primary) 35%, transparent); color: var(--primary); background-color: var(--primary-soft); }
.status.s-processing, .status.o-shipping { border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); background-color: color-mix(in srgb, var(--warn) 12%, transparent); }
.status.s-done, .status.o-done, .status.o-confirmed { border-color: color-mix(in srgb, var(--ok) 40%, transparent); color: var(--ok); background-color: color-mix(in srgb, var(--ok) 12%, transparent); }
.status.s-ignored, .status.o-cancelled { border-color: var(--line); color: var(--muted); background-color: var(--hover); }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 6px; }
.page { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.page.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.page:disabled { opacity: .4; cursor: not-allowed; }
.gap { color: var(--muted); }

/* ---------- permissions page ---------- */
.perms { display: flex; flex-direction: column; gap: 12px; }
.presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.perm { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.perm:hover { background: var(--hover); }
.perm span { display: flex; flex-direction: column; line-height: 1.3; }
.perm small { color: var(--muted); font-size: 11px; }
.sub { font-size: 13px; margin: 16px 0 10px; }
.flags { display: flex; gap: 8px; flex-wrap: wrap; }
.flags .chip { margin: 0; }
.help p + p { margin-top: 10px; }

/* ---------- modal / toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(10, 14, 24, .5); backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.confirm-text { line-height: 1.55; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 36px)); }
.toast { padding: 11px 16px; border-radius: 12px; background: #1f2740; color: #fff; box-shadow: 0 10px 28px rgba(0, 0, 0, .25); animation: rise .2s ease-out; }
.toast.err { background: #c8343a; } .toast.warn { background: #a86a06; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 14%, var(--bg)), var(--bg)); }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; display: flex; flex-direction: column; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 20px 50px rgba(20, 30, 60, .12); text-align: center; }
.login-card .field { text-align: left; }
.login-card .btn { margin-top: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .shell, .shell.narrow { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; width: 240px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  .shell.open .side { transform: none; }
  .shell.open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(10, 14, 24, .45); }
  .shell.narrow .nav-item span:not(.ico), .shell.narrow .brand-name { display: inline; }
  .shell.narrow .nav-item { justify-content: flex-start; padding: 11px 14px; }
  .collapse { display: none; }
  .only-mobile { display: inline-flex; }
  .top { padding: 0 14px; } .view { padding: 18px 14px 50px; }
  .stats { grid-template-columns: 1fr; gap: 12px; }
  .stat { min-height: 104px; }
  .user-text { display: none; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .form-grid, .perm-grid { grid-template-columns: 1fr; }
  .search { max-width: none; flex-basis: 100%; }
  .filters input[type=date] { flex: 1 1 130px; min-width: 0; }
  .filters .dim { display: none; }
  .popover.bell-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
  /* comments: one card per comment */
  table.comments, table.comments tbody { display: block; }
  table.comments thead { display: none; }
  .table-card:has(table.comments) { background: none; border: 0; box-shadow: none; overflow: visible; }
  table.comments tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "time phone" "who who" "text text" "status act" "post post"; gap: 8px 12px; padding: 14px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
  table.comments td, table.comments tr.hot td { display: block; padding: 0; border: 0; background: none !important; max-width: none; min-width: 0; }
  table.comments tr.hot { background: var(--hot); }
  table.comments td:nth-child(1) { grid-area: time; } table.comments td:nth-child(2) { grid-area: post; font-size: 12px; }
  table.comments td:nth-child(3) { grid-area: who; } table.comments td:nth-child(4) { grid-area: text; }
  table.comments td:nth-child(5) { grid-area: phone; text-align: right; } table.comments td:nth-child(6) { grid-area: status; }
  table.comments td:nth-child(7) { grid-area: act; text-align: right; }
  td.time small { display: inline; margin-left: 6px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* orders has many columns: tighter cells so it fits a laptop screen without sideways scrolling */
table.orders th, table.orders td { padding: 12px 9px; }
table.orders td.num, table.orders td.time, table.orders td.code { white-space: nowrap; }
table.orders td.prod { min-width: 130px; max-width: 180px; }
table.orders td.addr { min-width: 120px; max-width: 180px; }
table.orders .status { padding-left: 9px; font-size: 11px; }

/* ---------- quick order form ---------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.order-form { display: flex; flex-direction: column; gap: 14px; }
.of-row { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 12px; align-items: start; }
.of-label { padding-top: 9px; font-size: 13px; font-weight: 600; color: var(--muted); text-align: right; }
.of-field { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.of-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.of-addr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.of-addr select, .of-addr input { min-width: 0; }
.of-cod { display: flex; align-items: center; gap: 10px; }
.of-cod .vnd { display: inline-flex; align-items: center; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 12px; }
.of-cod input[name=total] { flex: 1; min-width: 0; }
.of-qty { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.of-qty input { width: 76px; }
.chip-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font-size: 13px; font-weight: 600; }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.modal-actions.centered { flex-direction: column; align-items: center; gap: 10px; }
.modal-actions.centered .btn-primary { min-width: 200px; }
.btn-link { border: 0; background: none; padding: 4px 10px; color: var(--muted); font-weight: 600; }
.btn-link:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 700px) {
  .of-row { grid-template-columns: 1fr; gap: 6px; }
  .of-label { text-align: left; padding-top: 0; }
  .of-two, .of-addr { grid-template-columns: 1fr; }
}

/* date fields: our own calendar button; the native indicator is hidden so it never shows twice or not at all */
.date-field { position: relative; display: inline-flex; align-items: center; }
.date-field input[type=date] { padding-right: 62px; min-width: 150px; }
.date-field input[type=date]::-webkit-calendar-picker-indicator { display: none; }
.date-btn, .date-clear { position: absolute; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted); border-radius: 6px; }
.date-btn { right: 6px; width: 28px; height: 28px; }
.date-btn:hover { color: var(--primary); background: var(--hover); }
.date-clear { right: 34px; width: 22px; height: 22px; }
.date-clear:hover { color: var(--danger); }
@media (max-width: 900px) { .date-field { flex: 1 1 130px; } .date-field input[type=date] { width: 100%; min-width: 0; } }

.handler { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
td.actions .chip { margin: 0 6px 0 0; vertical-align: middle; }
.history { margin: 4px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--hover); }
.history h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.history ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.history li { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.history time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.history .who-name { font-weight: 600; }

.reply-tag { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }

/* list footer: rows per page + pages / load more */
.list-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.list-footer .pager { margin: 0; }
.size-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.size-pick select { width: auto; min-height: 32px; padding-top: 3px; padding-bottom: 3px; }
@media (max-width: 900px) { .list-footer { flex-direction: column-reverse; align-items: stretch; } .load-more { width: 100%; height: 42px; } .size-pick { justify-content: center; } }

/* Desktop tables: headers and cells share one alignment. Short columns (numbers, times, status, actions) are centred;
   long text columns (titles, comment text, addresses, names) stay left so they read naturally. */
@media (min-width: 901px) {
  table.data th, table.data td { text-align: center; }
  table.data .profile-cell, table.data .who { text-align: left; }
  table.posts :is(th, td):nth-child(4),
  table.comments :is(th, td):is(:nth-child(2), :nth-child(3), :nth-child(4)),
  table.orders :is(th, td):is(:nth-child(2), :nth-child(3), :nth-child(5), :nth-child(6)),
  table.users :is(th, td):is(:nth-child(1), :nth-child(2)) { text-align: left; }
  table.data td.chk, table.data th.chk { text-align: center; }
  table.data .chips { justify-content: flex-start; }
}

/* proxies */
.proxy-hosts { margin: -4px 0 2px; }
.host-chip { display: inline-flex; align-items: center; gap: 6px; padding-right: 4px; }
.chip-x { width: 18px; height: 18px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.chip-x:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.check-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.test-result p { margin: 2px 0; font-size: 13px; }
.ok-line { color: var(--ok); }

/* bell: sound controls */
.ico-wrap { display: inline-flex; }
.dot.warn { background: #f59e0b; }
.sound-box { display: flex; align-items: flex-end; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.sound-box label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sound-box select { min-height: 32px; padding-top: 3px; padding-bottom: 3px; font-weight: 500; color: var(--text); }
.sound-hint { margin: 0; padding: 8px 14px; font-size: 12px; background: color-mix(in srgb, #f59e0b 16%, transparent); color: var(--text); }
.note-text .plain { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

.sound-box + .sound-box { border-top: 0; padding-top: 0; }

/* phone: the number is a button (copy) or a link (call); both look the same */
a.phone-btn { text-decoration: none; }
.icon-btn.call { color: var(--ok); }
.icon-btn.call:hover { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
td.phone .phone-btn, td.phone-n .phone-btn { margin-right: 2px; }
@media (pointer: coarse) {
  /* thumbs: a bigger target for the number and its second action */
  td.phone .phone-btn, td.phone-n .phone-btn { display: inline-block; padding: 8px 2px; font-size: 15px; }
  td.phone .icon-btn, td.phone-n .icon-btn { width: 38px; height: 38px; }
}

/* searchable drop-down (address) */
.ss { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 38px; padding: 7px 10px 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); text-align: left; min-width: 0; }
.ss.has-value { color: var(--text); }
.ss:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.ss:disabled { opacity: .55; cursor: not-allowed; }
.ss:focus-visible, .ss[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); outline: none; }
.ss-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-pop { position: fixed; z-index: 150; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 36px rgba(0, 0, 0, .22); overflow: hidden; }
.ss-search { position: relative; padding: 8px; border-bottom: 1px solid var(--line); }
.ss-search .ico { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.ss-input { padding-left: 32px !important; min-height: 34px !important; }
.ss-list { overflow-y: auto; padding: 4px; }
.ss-opt { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.ss-opt.on { background: var(--primary-soft); color: var(--primary); }
.ss-opt.picked { font-weight: 700; }
.ss-opt.clear { color: var(--danger); font-size: 13px; }
.ss-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* "all": the end-of-list marker and the running count */
.load-rest { display: flex; align-items: center; gap: 12px; }
.load-marker { flex-basis: 100%; height: 1px; }

.list-footer { justify-content: space-between; }

/* order form: field errors */
.field-error { display: block; color: var(--danger); font-size: 12px; font-weight: 600; margin-top: -4px; }
.of-field input[aria-invalid="true"], .of-field textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent); }
.req { color: var(--danger); }
.order-form form { gap: 0; }

/* sortable column titles */
th.sortable { padding: 0; }
.sort-btn { display: inline-flex; align-items: center; justify-content: inherit; gap: 6px; width: 100%; padding: 13px 14px; border: 0; background: transparent; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; white-space: nowrap; }
.sort-btn:hover { color: var(--text); }
.sort-ico { position: relative; width: 10px; height: 14px; flex: none; }
.sort-ico::before, .sort-ico::after { content: ""; position: absolute; left: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; opacity: .35; }
.sort-ico::before { top: 0; border-bottom: 5px solid currentColor; }
.sort-ico::after { bottom: 0; border-top: 5px solid currentColor; }
th[data-sort=asc] .sort-ico::before, th[data-sort=desc] .sort-ico::after { opacity: 1; color: var(--primary); }
th[data-sort=asc] .sort-btn, th[data-sort=desc] .sort-btn { color: var(--primary); }
th.num .sort-btn { justify-content: flex-end; }
@media (min-width: 901px) { th.sortable .sort-btn { justify-content: center; } table.posts th.sortable:nth-child(4) .sort-btn { justify-content: flex-start; } }
