/* ==========================================================================
   TicketBot dashboard — stylesheet
   Dark, Discord-like. Everything keys off the CSS variables in :root.
   ========================================================================== */
:root {
  --bg-0: #1e1f22;        /* sidebar / darkest */
  --bg-1: #2b2d31;        /* cards */
  --bg-2: #313338;        /* page background */
  --bg-3: #383a40;        /* inputs, hover */
  --bg-4: #404249;        /* active / pressed */
  --border: #3f4147;
  --border-strong: #4e5058;
  --text: #dbdee1;
  --text-bright: #f2f3f5;
  --text-muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --accent-soft: rgba(88, 101, 242, 0.18);
  --green: #57f287;
  --green-dark: #23a559;
  --green-soft: rgba(87, 242, 135, 0.16);
  --yellow: #fee75c;
  --yellow-soft: rgba(254, 231, 92, 0.16);
  --red: #ed4245;
  --red-hover: #c03537;
  --red-soft: rgba(237, 66, 69, 0.16);
  --pink: #eb459e;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --font: "gg sans", "Noto Sans", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg-2); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--text-bright); margin: 0 0 8px; font-weight: 700; line-height: 1.25; }
h1 { font-size: 24px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-top: 18px; }
p { margin: 0 0 10px; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--bg-0); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 18px; }
.pad { padding: 16px; }
.pad-h { padding: 0 16px; }
.hidden { display: none !important; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: -4px; }
.ic.flip { transform: rotate(180deg); }
.ic.big { width: 40px; height: 40px; color: var(--text-muted); }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-0); border-radius: 6px; border: 2px solid var(--bg-2); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- app shell ------------------------------------------------------------ */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--bg-0); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--bg-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 700; color: var(--text-bright); font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-avatar { display: inline-flex; }
.menu-btn { display: none; }
.view { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }
.view-login { display: flex; align-items: center; justify-content: center; }
body.logged-out .sidebar, body.logged-out .topbar-right { display: none; }
body.logged-out .menu-btn { display: none !important; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 29; }

.brand { padding: 16px 14px 12px; border-bottom: 1px solid var(--border); }
.brand a { display: flex; align-items: center; gap: 10px; color: var(--text-bright); }
.brand a:hover { text-decoration: none; }
.brand small { display: block; color: var(--text-muted); font-size: 12px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text-muted); font-weight: 500; }
.nav-item:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-4); color: var(--text-bright); }
.nav-item .ic { width: 20px; height: 20px; }
.nav-item span:not(.nav-count):not(.avatar) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.nav-section { padding: 14px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; }
.nav-guild { display: flex; align-items: center; gap: 8px; padding: 12px 10px 6px; color: var(--text-bright); font-weight: 700; }
.nav-guild > span:not(.avatar):not(.pill) { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: rgba(0, 0, 0, 0.15); }
.nav-user-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.live-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #80848e; box-shadow: 0 0 0 3px rgba(128, 132, 142, 0.25); transition: background .2s; }
.live-dot::after { content: "Live"; }
.live-dot.on::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.live-dot.on { color: var(--green); }

/* ---- generic components --------------------------------------------------- */
.card { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-head { padding: 14px 16px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.section-title { margin: 8px 0 12px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 2px 0 0; }
.page-head-guild { display: flex; align-items: center; gap: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; background: var(--bg-3); color: var(--text-bright); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; line-height: 1.2; transition: background .12s, opacity .12s; white-space: nowrap; }
.btn:hover { background: var(--bg-4); text-decoration: none; }
.btn:disabled, .btn.busy { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; } .btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-3); border-color: var(--border-strong); }
.btn-success { background: var(--green-dark); color: #fff; } .btn-success:hover { background: #1f8f4d; }
.btn-danger { background: var(--red); color: #fff; } .btn-danger:hover { background: var(--red-hover); }
.btn-ghost { background: transparent; color: var(--text); } .btn-ghost:hover { background: var(--bg-3); }
.btn-ghost.danger, .icon-btn.danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.btn-block { width: 100%; margin-top: 10px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--bg-3); color: var(--text-bright); text-decoration: none; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; line-height: 1.5; margin-right: 4px; white-space: nowrap; }
.pill-grey { background: var(--bg-4); color: var(--text-muted); }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-yellow { background: var(--yellow-soft); color: var(--yellow); }
.pill-red { background: var(--red-soft); color: #ff6b6e; }
.pill-blurple { background: var(--accent-soft); color: #a5b0ff; }
.badge { display: inline-flex; align-items: center; padding: 1px 5px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: .04em; margin-left: 6px; line-height: 1.5; vertical-align: 1px; }
.badge-bot { background: var(--accent); color: #fff; }
.badge-staff { background: var(--green-dark); color: #fff; }
.badge-dash { background: var(--bg-4); color: var(--text-muted); }
.badge-deleted { background: var(--red-soft); color: var(--red); }

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; overflow: hidden; color: #fff; font-weight: 700; font-size: 14px; flex: none; position: relative; vertical-align: middle; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 22px; height: 22px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 16px; }
.avatar-lg { width: 56px; height: 56px; font-size: 22px; border-radius: 16px; }
.avatar-xl { width: 96px; height: 96px; font-size: 36px; }
.user-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.mention { background: var(--accent-soft); color: #c9cdfb; border-radius: 3px; padding: 0 3px; font-weight: 500; }
.spoiler { background: var(--bg-0); color: transparent; border-radius: 3px; cursor: pointer; }
.spoiler:hover { color: var(--text); }
.timestamp { background: var(--bg-4); border-radius: 3px; padding: 0 4px; }
.emoji { width: 22px; height: 22px; vertical-align: -5px; }
.md-h1, .md-h2, .md-h3 { display: block; font-weight: 700; color: var(--text-bright); margin: 6px 0 2px; }
.md-h1 { font-size: 1.5em; } .md-h2 { font-size: 1.3em; } .md-h3 { font-size: 1.1em; }
.md-quote { display: block; border-left: 4px solid var(--border-strong); padding-left: 10px; color: var(--text-muted); }
.codeblock { background: var(--bg-0); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; margin: 6px 0; overflow: auto; font-size: 13px; white-space: pre; }
.codeblock code { background: transparent; padding: 0; }
.inline-code { background: var(--bg-0); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { background: var(--bg-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; border-top: 3px solid var(--border-strong); }
.tile-blurple { border-top-color: var(--accent); } .tile-green { border-top-color: var(--green); } .tile-yellow { border-top-color: var(--yellow); } .tile-red { border-top-color: var(--red); }
.tile-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.tile-value { font-size: 26px; font-weight: 800; color: var(--text-bright); margin-top: 4px; line-height: 1.1; }
.tile-value small { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.tile-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -6px 0 18px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.two-col-narrow { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.quick-link { display: flex; gap: 12px; align-items: center; margin: 0; color: var(--text); padding: 14px 16px; }
.quick-link:hover { border-color: var(--accent); text-decoration: none; }
.quick-link .ic { width: 24px; height: 24px; color: var(--accent); }
.quick-link small { display: block; color: var(--text-muted); }
.guild-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.guild-card { display: flex; align-items: center; gap: 14px; color: var(--text); margin: 0; }
.guild-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.guild-card-body { flex: 1; min-width: 0; }
.guild-card-body b { display: block; font-size: 16px; color: var(--text-bright); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guild-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); color: var(--text); }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--bg-3); text-decoration: none; }
.list-row b { display: block; color: var(--text-bright); }
.list-row small { display: block; }
.list-row p { margin: 4px 0; }
.card > .list .list-row { padding-left: 0; padding-right: 0; }
.ticket-no { font-family: var(--mono); font-weight: 700; color: var(--text-bright); background: var(--bg-0); padding: 2px 7px; border-radius: 5px; font-size: 13px; white-space: nowrap; }
.ticket-no.big { font-size: 18px; padding: 4px 10px; }
a.ticket-no:hover { background: var(--accent); color: #fff; text-decoration: none; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--bg-3); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .w-check { width: 36px; text-align: center; }
.table.compact th, .table.compact td { padding: 8px 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.search-box { position: relative; min-width: 260px; }
.search-box .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box .input { padding-left: 36px; }
.empty { text-align: center; padding: 36px 16px; color: var(--text-muted); }
.empty-icon { width: 40px; height: 40px; opacity: .6; margin-bottom: 8px; }
.empty-title { font-weight: 700; color: var(--text); font-size: 16px; }
.empty-text { margin-top: 4px; font-size: 13.5px; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 0; color: var(--text-muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--bg-4); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { display: flex; align-items: center; gap: 16px; border-color: var(--red); }
.banner { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius); margin: 0 0 12px; font-size: 14px; border: 1px solid; }
.banner-yellow { background: var(--yellow-soft); border-color: rgba(254, 231, 92, 0.35); color: #f5e9a3; }
.banner-red { background: var(--red-soft); border-color: rgba(237, 66, 69, 0.4); color: #ffb3b4; }
.banner .ic { flex: none; }
.stars { display: inline-flex; gap: 1px; }
.stars .ic { width: 16px; height: 16px; }
.stars .ic.on { color: var(--yellow); fill: var(--yellow); }
.stars .ic.off { color: var(--border-strong); }

/* ---- forms --------------------------------------------------------------- */
.input { width: 100%; background: var(--bg-0); color: var(--text-bright); border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; font: inherit; font-size: 14px; transition: border-color .12s; }
.input:focus { outline: none; border-color: var(--accent); }
.input:disabled { opacity: .5; }
.input-sm { padding: 6px 9px; font-size: 13px; width: auto; }
textarea.input { resize: vertical; min-height: 40px; line-height: 1.4; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23949ba4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
input[type="color"] { width: 42px; height: 38px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-0); padding: 3px; cursor: pointer; }
input[type="file"].input { padding: 7px; }
input[type="time"].input { width: auto; }
.field { display: block; margin-bottom: 14px; min-width: 0; }
.field-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.field-label-row .field-label { margin: 0; }
.field-help { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.field-help code { font-size: 11.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 6px; background: var(--bg-0); border: 1px solid var(--border); cursor: pointer; font-size: 13.5px; user-select: none; }
.check.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text-bright); }
.check input { accent-color: var(--accent); margin: 0; }
.check .dot { width: 10px; height: 10px; border-radius: 50%; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; margin-bottom: 4px; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { flex: none; width: 40px; height: 24px; border-radius: 12px; background: #80848e; position: relative; transition: background .15s; margin-top: 1px; }
.toggle .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + .track { background: var(--green-dark); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle-text b { display: block; color: var(--text-bright); font-weight: 600; }
.toggle-text small { display: block; color: var(--text-muted); font-size: 12.5px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.color-field .input { flex: 1; font-family: var(--mono); text-transform: uppercase; }
.editor { border-color: var(--border-strong); }
.editor h2 { margin-top: 4px; }
.editor h2:not(:first-child) { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.editor-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 24px; }
.editor-preview { position: sticky; top: calc(var(--topbar-h) + 16px); align-self: start; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-bright); border-bottom-color: var(--accent); }
.range-select .field { margin: 0; min-width: 180px; }
.hours-grid { display: grid; grid-template-columns: 1fr; gap: 6px; }
.hours-head, .hours-row { display: grid; grid-template-columns: 120px 140px 140px 1fr; gap: 12px; align-items: center; }
.hours-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; padding: 0 0 4px; }
.hours-row { padding: 6px 0; border-top: 1px solid var(--border); }
.hours-row.off .hours-day { color: var(--text-muted); }
.hours-day { font-weight: 600; }
.form-field-row { background: var(--bg-0); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 0; margin-bottom: 10px; }
.form-field-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.md-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.upload-row { display: flex; gap: 16px; align-items: center; }
.banner-preview { width: 180px; height: 72px; border-radius: 8px; background: var(--bg-0) center/cover no-repeat; border: 1px solid var(--border); flex: none; }

/* ---- login --------------------------------------------------------------- */
.login-wrap { width: 100%; display: flex; justify-content: center; align-items: center; min-height: calc(100vh - var(--topbar-h) - 48px); }
.login-card { max-width: 420px; width: 100%; text-align: center; padding: 36px 32px; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 8px; }
.login-card .btn { margin-top: 12px; }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.login-logo .ic { width: 32px; height: 32px; color: #fff; }

/* ---- toasts -------------------------------------------------------------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-1); border: 1px solid var(--border-strong); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 12px 12px 14px; box-shadow: var(--shadow); font-size: 14px; opacity: 0; transform: translateX(20px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast .ic { flex: none; margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; word-wrap: break-word; }
.toast-body a { font-weight: 700; margin-left: 4px; }
.toast-x { background: none; border: 0; color: var(--text-muted); cursor: pointer; padding: 0; display: inline-flex; }
.toast-info { border-left-color: var(--accent); }
.toast-info .ic:first-child { color: var(--accent); }
.toast-success { border-left-color: var(--green); }
.toast-success .ic:first-child { color: var(--green); }
.toast-warn { border-left-color: var(--yellow); }
.toast-warn .ic:first-child { color: var(--yellow); }
.toast-error { border-left-color: var(--red); }
.toast-error .ic:first-child { color: var(--red); }

/* ---- modals -------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .15s; }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--bg-1); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); width: 100%; max-width: 440px; box-shadow: var(--shadow); transform: scale(.96); transition: transform .15s; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-backdrop.show .modal { transform: none; }
.modal-wide { max-width: 640px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.modal-title { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.modal-body { padding: 14px 18px; overflow-y: auto; }
.modal-body p { color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; background: var(--bg-0); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.member-results { margin-top: 10px; max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-0); }
.member-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; background: transparent; border: 0; border-bottom: 1px solid var(--border); color: var(--text); font: inherit; cursor: pointer; }
.member-row:last-child { border-bottom: 0; }
.member-row:hover { background: var(--bg-3); }
.member-row.selected { background: var(--accent-soft); }
.member-row b { display: block; color: var(--text-bright); }
.member-row small { display: block; font-size: 12px; }

/* ---- live ticket view ----------------------------------------------------- */
.view-ticket { padding: 0; max-width: none; display: flex; height: calc(100vh - var(--topbar-h)); overflow: hidden; }
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; width: 100%; height: 100%; }
.ticket-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ticket-head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg-2); flex-wrap: wrap; }
.ticket-head-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.page-head .ticket-head-main { flex-direction: row; align-items: center; gap: 12px; }
.ticket-title { display: flex; align-items: center; gap: 10px; }
.ticket-panel { font-weight: 700; color: var(--text-bright); font-size: 16px; }
.ticket-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#ticket-head .banner { margin: 10px 20px 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px 20px 8px; min-height: 0; }
.messages-empty { text-align: center; padding: 40px 0; }
.msg { display: flex; gap: 14px; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; }
.msg:hover { background: rgba(0, 0, 0, 0.12); }
.msg.staff { border-left: 2px solid var(--green-dark); }
.msg.deleted { opacity: .55; }
.msg.deleted .msg-text { text-decoration: line-through; }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; margin-bottom: 2px; }
.msg-author { font-weight: 600; color: var(--text-bright); }
.msg-time { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.msg-text { word-wrap: break-word; overflow-wrap: anywhere; white-space: normal; }
.edited { font-size: 11px; color: var(--text-muted); }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.attachment { display: inline-flex; align-items: center; gap: 8px; background: var(--bg-1); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text); }
.attachment small { margin-left: 4px; }
.attachment-img img { max-width: min(420px, 100%); max-height: 320px; border-radius: 6px; display: block; }
.embed { display: flex; background: var(--bg-1); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 14px 10px 12px; margin-top: 6px; max-width: 520px; gap: 12px; }
.embed-inner { flex: 1; min-width: 0; }
.embed-author { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.embed-title { font-weight: 700; color: var(--text-bright); margin-bottom: 4px; }
.embed-desc { font-size: 14px; }
.embed-fields { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }
.embed-field { flex: 1 1 100%; min-width: 0; }
.embed-field.inline { flex: 1 1 30%; }
.embed-field-name { font-weight: 700; color: var(--text-bright); font-size: 13px; }
.embed-field-value { font-size: 13.5px; }
.embed-image { display: block; margin-top: 10px; }
.embed-image img { max-width: 100%; max-height: 300px; border-radius: 4px; display: block; }
.embed-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 4px; flex: none; }
.embed-footer { font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--bg-2); }
.composer.disabled { align-items: center; justify-content: center; padding: 14px; gap: 6px; }
.composer textarea { flex: 1; }
.composer-actions { display: flex; gap: 8px; align-items: center; }
.composer-actions select { max-width: 180px; }
.ticket-aside { border-left: 1px solid var(--border); background: var(--bg-1); padding: 16px 18px; overflow-y: auto; min-height: 0; }
.aside-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.aside-head h3 { margin: 0; }
.aside-toggle { display: none; }
.kv { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv-k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
.kv-v { color: var(--text); word-wrap: break-word; }
.participants { display: flex; flex-direction: column; gap: 6px; }
.participant { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.form-answers .fa { padding: 8px 0; border-bottom: 1px solid var(--border); }
.fa-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.fa-value { display: block; font-size: 14px; white-space: pre-wrap; }
.survey-box { background: var(--bg-0); border-radius: 6px; padding: 10px 12px; }
.survey-box p { margin: 6px 0 0; font-size: 14px; }

/* ---- transcript viewer ---------------------------------------------------- */
.transcript-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.transcript-frame { height: calc(100vh - var(--topbar-h) - 140px); min-height: 480px; margin: 0; background: #fff; }
.transcript-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.transcript-info { position: sticky; top: calc(var(--topbar-h) + 16px); margin: 0; max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; }

/* ---- bulk ----------------------------------------------------------------- */
.bulk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.bulk-panel { position: sticky; top: calc(var(--topbar-h) + 16px); }
.bulk-panel .btn-block { margin-top: 12px; }
.feedback p { margin: 2px 0; }

/* ---- panels --------------------------------------------------------------- */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.panel-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.panel-card-head { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.panel-card-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-bright); }
.panel-card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-muted); align-items: center; }
.panel-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.panel-card-meta .ic { width: 15px; height: 15px; }
.dbtn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 4px; font-size: 14px; font-weight: 600; color: #fff; background: var(--accent); }
.dbtn-secondary { background: #4e5058; } .dbtn-success { background: var(--green-dark); } .dbtn-danger { background: var(--red); }
.panel-card-meta .dbtn { padding: 3px 10px; font-size: 12.5px; }
.dpreview { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.dpreview-msg { display: flex; gap: 12px; }
.dpreview-body { flex: 1; min-width: 0; }
.dpreview .embed { margin-top: 4px; max-width: none; }
.dpreview-row { margin-top: 8px; }
.dselect { display: flex; align-items: center; justify-content: space-between; background: var(--bg-0); border: 1px solid var(--border); border-radius: 4px; padding: 8px 12px; color: var(--text-muted); max-width: 400px; }
.dselect-opts { background: var(--bg-0); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 4px 4px; max-width: 400px; }
.dselect-opt { padding: 8px 12px; border-top: 1px solid var(--border); font-size: 14px; }

/* ---- knowledge base ------------------------------------------------------- */
.kb-url { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kb-url > div { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.kb-url a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-url .banner { margin: 0; padding: 6px 10px; }
.kb-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.kb-list { position: sticky; top: calc(var(--topbar-h) + 16px); max-height: calc(100vh - var(--topbar-h) - 40px); overflow-y: auto; padding: 6px 0; }
.kb-cat { padding: 12px 14px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 700; }
.kb-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 14px; background: transparent; border: 0; color: var(--text); font: inherit; cursor: pointer; }
.kb-item:hover { background: var(--bg-3); }
.kb-item.active { background: var(--accent-soft); }
.kb-item b { display: block; color: var(--text-bright); font-weight: 600; }
.kb-item small { display: block; font-size: 12px; }
.kb-article h1 { font-size: 26px; }
.kb-content { font-size: 15px; line-height: 1.6; }
.kb-content h2, .kb-content h3, .kb-content h4 { margin-top: 18px; text-transform: none; letter-spacing: 0; color: var(--text-bright); }
.kb-content h2 { font-size: 20px; } .kb-content h3 { font-size: 17px; } .kb-content h4 { font-size: 15px; }
.kb-content ul { padding-left: 22px; }
.kb-content blockquote { border-left: 4px solid var(--accent); margin: 8px 0; padding-left: 12px; color: var(--text-muted); }
.kb-content img { max-width: 100%; }
.kb-preview-box { background: var(--bg-0); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; min-height: 200px; }

/* ---- analytics ------------------------------------------------------------ */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.chart-card { margin: 0; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-box { height: 260px; position: relative; }
.chart-card.wide .chart-box { height: 280px; }
.chart-card .chart-box.fallback, .chart-card.wide .chart-box.fallback { height: auto; max-height: 420px; overflow: auto; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 40px; align-items: center; gap: 8px; font-size: 12.5px; }
.bar-label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--bg-0); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 1100px) {
  .editor-grid { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
  .transcript-layout, .bulk-layout { grid-template-columns: 1fr; }
  .transcript-info, .bulk-panel { position: static; max-height: none; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .view { padding: 16px; }
  .two-col, .two-col-narrow, .chart-grid, .kb-layout { grid-template-columns: 1fr; }
  .kb-list { position: static; max-height: 260px; }
  .tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ticket-layout { grid-template-columns: 1fr; position: relative; }
  .ticket-aside { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 90%); transform: translateX(100%); transition: transform .2s; z-index: 5; box-shadow: var(--shadow); }
  .ticket-layout.show-aside .ticket-aside { transform: none; }
  .aside-toggle { display: inline-flex; }
  .ticket-head { padding: 10px 12px; }
  .messages, .composer { padding-left: 12px; padding-right: 12px; }
  .composer { flex-wrap: wrap; }
  .composer textarea { flex: 1 1 100%; }
  .composer-actions { width: 100%; justify-content: flex-end; }
  .hours-head { display: none; }
  .hours-row { grid-template-columns: 1fr 1fr; }
  .hours-day { grid-column: 1 / -1; }
  .transcript-frame { height: 70vh; }
}
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile-value { font-size: 20px; }
  .page-head { flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .modal-foot { flex-wrap: wrap; }
  .ellipsis { max-width: 140px; }
  .topbar { padding: 0 12px; }
  .upload-row { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .001s !important; }
}
