/* Desk — Swartz Automation's ticketing for a client's staff.
   Same token set and topbar -> tab-bar -> panel > wrap > surface structure as
   the Organic Hub and the Swartz portals, so the apps read as one house.
   Accent is Swartz Automation blue (#0078d4), kept distinct from Swartz
   Communication red. */
:root {
  --bg: #1e1e1e;
  --bg2: #252526;
  --bg3: #2d2d2d;
  --fg: #d4d4d4;
  --fg-dim: #888888;
  --accent: #0078d4;
  --accent-hover: #0066b5;
  --success: #5fb87a;
  --warn: #dcdcaa;
  --error: #f44747;
  --border: #3c3c3c;
  --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ---- topbar ---- */
/* The bar's background spans the window; its contents sit in the same
   1080px column as the tabs and panels below, so the edges line up. */
.topbar {
  height: 52px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1080px; height: 100%; margin: 0 auto; padding: 0 24px;
}
.topbar-brand { font-size: 15px; font-weight: 700; }
.topbar-brand .accent { color: var(--accent); }
.topbar-brand .tenant { color: var(--fg-dim); font-weight: 500; margin-left: 10px; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; color: var(--fg-dim); }
.icon-btn {
  width: auto; padding: 6px 12px; background: none; border: 1px solid var(--border);
  color: var(--fg-dim); font-size: 13px; font-weight: 500; border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.icon-btn:hover { background: var(--bg3); color: var(--fg); }

/* ---- tab bar ---- */
.tab-bar { display: flex; gap: 2px; padding: 12px 24px 0; max-width: 1080px;
           width: 100%; margin: 0 auto; background: var(--bg); flex-shrink: 0; }
.tab-btn {
  padding: 9px 20px; background: none; border: 1px solid var(--border); border-bottom: none;
  color: var(--fg-dim); font-size: 13px; font-weight: 500; cursor: pointer;
  border-radius: 8px 8px 0 0; position: relative; bottom: -1px; font-family: inherit;
}
.tab-btn:hover { color: var(--fg); background: var(--bg3); }
.tab-btn.active { background: var(--bg2); color: var(--fg); font-weight: 600; border-bottom: 1px solid var(--bg2); }
.tab-btn .badge { display: inline-block; margin-left: 7px; font-size: 10px; font-weight: 700;
                  padding: 1px 6px; border-radius: 999px; background: rgba(0,120,212,.22); color: #6cb6ff; }
.tab-btn .badge:empty { display: none; }

/* ---- panels ---- */
.page-content { flex: 1; }
.panel { display: none; }
.panel.active { display: block; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px 32px; }
.surface {
  /* Both top corners square: tabs sit on the left AND right ends (Messages,
     Email), and a rounded corner would curve away under the end tab. */
  background: var(--bg2); border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  padding: 20px;
}
.row { display: flex; gap: 12px; align-items: center; }
.spread { justify-content: space-between; }
h2.section { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.sub { color: var(--fg-dim); font-size: 13px; margin: 0 0 18px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.chip {
  padding: 6px 12px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 999px; color: var(--fg-dim); font-size: 12px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toolbar .grow { flex: 1; }
/* Pill-shaped like the chips beside it. appearance:none drops Safari's glossy
   native control; the caret is drawn back in as an inline SVG. */
.toolbar select {
  width: auto; min-width: 180px; padding: 6px 32px 6px 14px; font-size: 12px; font-weight: 500;
  border-radius: 999px; color: var(--fg); background-color: var(--bg3);
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
.toolbar select:hover { border-color: #555; }

/* ---- tables ---- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
th { text-align: left; background: var(--bg3); color: var(--fg-dim); font-weight: 600;
     padding: 8px 10px; font-size: 12px; white-space: nowrap; }
th.num, td.num { text-align: right; }
td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
td.num { font-variant-numeric: tabular-nums; }
td.dim { color: var(--fg-dim); }
td.nowrap { white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg3); }
.tnum { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.ttitle { font-weight: 600; color: var(--fg); }
.counts { color: var(--fg-dim); font-size: 12px; white-space: nowrap; }
.empty { color: var(--fg-dim); font-size: 13px; padding: 16px 0; }

.pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.pill.new         { background: rgba(0,120,212,.2); color: #6cb6ff; }
.pill.in_progress { background: rgba(220,220,170,.16); color: var(--warn); }
.pill.blocked     { background: rgba(244,71,71,.14); color: var(--error); }
.pill.completed   { background: rgba(95,184,122,.16); color: var(--success); }
.pill.idle        { background: var(--bg2); color: var(--fg-dim); border: 1px solid var(--border); }

/* ---- buttons ---- */
button.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 11px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button.btn:hover { background: var(--accent-hover); }
button.btn:disabled { opacity: .6; cursor: default; }
button.btn.secondary { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); }
button.btn.secondary:hover { background: var(--border); }
button.btn.small { padding: 7px 13px; font-size: 13px; }
button.link { background: none; border: none; color: var(--fg-dim); font: inherit; font-size: 13px;
              cursor: pointer; padding: 0; }
button.link:hover { color: var(--fg); text-decoration: underline; }

/* ---- forms ---- */
label { display: block; font-size: 13px; margin: 16px 0 6px; color: var(--fg-dim); }
input[type="text"], input[type="email"], input[type="password"], textarea, select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; color: var(--fg); padding: 10px 12px; font-size: 14px; font-family: inherit;
}
select { cursor: pointer; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.hint { font-size: 12px; color: var(--fg-dim); margin-top: 6px; line-height: 1.5; }
.msg { font-size: 13px; margin: 12px 0 0; min-height: 18px; }
.msg.err { color: var(--error); }
.msg.ok { color: var(--success); }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
              align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-back.open { display: flex; }
.modal { position: relative; background: var(--bg2); border: 1px solid var(--border);
         border-radius: 10px; padding: 24px; width: 100%; max-width: 520px;
         max-height: 90vh; overflow-y: auto; }
.modal-x { position: absolute; top: 12px; right: 12px; width: auto; background: none; border: none;
           color: var(--fg-dim); font-size: 15px; line-height: 1; padding: 4px 8px; cursor: pointer; }
.modal-x:hover { color: var(--fg); }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .btn-row { display: flex; gap: 10px; margin-top: 20px; }
.modal .btn-row button { flex: 1; }
.linkbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
           background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
           padding: 10px 12px; word-break: break-all; user-select: all; margin-top: 8px; }

/* ---- ticket detail ---- */
.back { margin-bottom: 14px; }
.tk-head { display: flex; align-items: flex-start; gap: 12px; }
.tk-head h2 { margin: 0; font-size: 19px; font-weight: 600; flex: 1; line-height: 1.35; }
.tk-head .tnum { font-size: 19px; font-weight: 500; }
.tk-grid { display: grid; grid-template-columns: 1fr 280px; gap: 20px; margin-top: 18px; }
.side { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 4px 14px 14px;
        align-self: start; }
.side label { margin-top: 12px; font-size: 12px; }
.side select { padding: 8px 10px; font-size: 13px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 12.5px; margin-top: 14px; }
.kv dt { color: var(--fg-dim); }
.kv dd { margin: 0; }
.body-box { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
            padding: 14px 16px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.body-box.empty-body { color: var(--fg-dim); font-style: italic; }
.blk-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
             color: var(--fg-dim); margin: 22px 0 8px; display: flex; align-items: center; gap: 10px; }
.blk-title:first-child { margin-top: 0; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.cmt { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.cmt .by { font-size: 12.5px; color: var(--fg-dim); margin-bottom: 4px; }
.cmt .by b { color: var(--fg); font-weight: 600; }
.cmt .tx { font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.mention { color: #6cb6ff; font-weight: 600; }
.compose { margin-top: 12px; }
.compose .row { margin-top: 8px; justify-content: space-between; }

.files { display: flex; flex-direction: column; gap: 6px; }
.file { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.file .sz { color: var(--fg-dim); font-size: 12px; }

/* ---- notifications ---- */
/* Square corners: a radius here bends each row's top border up at both ends. */
.note { display: flex; gap: 12px; align-items: baseline; padding: 11px 12px; border-top: 1px solid var(--border);
        cursor: pointer; }
.note:first-child { border-top: none; }
.note:hover { background: var(--bg3); }
.note .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
             align-self: center; }
.note.read .dot { background: transparent; }
.note.read .what { color: var(--fg-dim); }
.note .what { flex: 1; font-size: 14px; }
.note .what b { font-weight: 600; }
.note .when { font-size: 12px; color: var(--fg-dim); white-space: nowrap; }

/* Messages and Email sit at the right end of the tab bar, apart from the
   task tabs. */
.tab-gap { flex: 1; }

/* Grouped notification rows (messages, emails): one row per kind. */
.note .count { display: inline-block; min-width: 22px; text-align: center; font-size: 11px; font-weight: 700;
               padding: 1px 7px; border-radius: 999px; background: rgba(0,120,212,.22); color: #6cb6ff; margin-right: 6px; }
.note.read .count { background: var(--bg3); color: var(--fg-dim); }

/* Every other select gets the same flat look and caret, minus the pill shape. */
select:not(.toolbar select) {
  -webkit-appearance: none; appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}

/* @ autocomplete */
.mention-wrap { position: relative; }
.mention-menu { position: absolute; left: 0; top: 100%; margin-top: 4px; z-index: 20; min-width: 260px;
                background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
                box-shadow: 0 8px 24px rgba(0,0,0,.45); padding: 4px; }
.mopt { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.mopt span { color: var(--fg-dim); margin-left: 6px; }
.mopt.sel, .mopt:hover { background: var(--accent); color: #fff; }
.mopt.sel span, .mopt:hover span { color: rgba(255,255,255,.8); }

/* ---- two-pane screens (Messages, Email) ---- */
.surface.split { display: grid; grid-template-columns: 320px 1fr; padding: 0; min-height: 560px; }
.split-list { border-right: 1px solid var(--border); padding: 16px 12px 16px 16px; overflow-y: auto; max-height: 76vh; }
.split-main { padding: 16px 20px; display: flex; flex-direction: column; min-width: 0; }
.split-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.split-head h2.section { margin: 0; }
.split-list > select { margin-bottom: 4px; padding: 7px 10px; font-size: 13px; }
.empty.pad { padding: 40px 0; text-align: center; }

.conv { display: flex; gap: 10px; align-items: flex-start; padding: 9px 8px; border-radius: 8px; cursor: pointer; }
.conv:hover { background: var(--bg3); }
.conv.sel { background: rgba(0,120,212,.16); }
.conv-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-subj { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-prev { font-size: 12px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-name, .conv.unread .conv-subj { font-weight: 700; color: #fff; }
.conv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.conv-side .when { font-size: 11px; color: var(--fg-dim); }
.conv-side .count { font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
                    background: var(--accent); color: #fff; }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center;
          justify-content: center; font-size: 12px; font-weight: 700; background: var(--bg3);
          border: 1px solid var(--border); color: var(--fg); }
.avatar.office { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 15px; }
.avatar.group { border-radius: 9px; }

.conv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
             padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.conv-title { font-size: 16px; font-weight: 600; }

.msg-scroll { flex: 1; overflow-y: auto; max-height: 56vh; min-height: 300px; display: flex;
              flex-direction: column; gap: 6px; padding-right: 4px; }
.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble { max-width: 72%; background: var(--bg3); border: 1px solid var(--border); border-radius: 12px;
          padding: 7px 11px 5px; }
.bubble-row.mine .bubble { background: var(--accent); border-color: var(--accent); color: #fff; }
.bubble .by { font-size: 11.5px; font-weight: 600; color: var(--fg-dim); margin-bottom: 2px; }
.bubble .tx { font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.bubble .at { font-size: 10.5px; color: var(--fg-dim); text-align: right; margin-top: 2px; }
.bubble-row.mine .bubble .at { color: rgba(255,255,255,.7); }
.msg-compose { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.msg-compose textarea { min-height: 44px; }

.mail-card { background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
             padding: 12px 14px; margin-bottom: 10px; position: relative; }
.mail-meta { font-size: 13px; display: flex; flex-direction: column; gap: 3px; padding-right: 170px; }
.mail-card > .when { position: absolute; top: 12px; right: 14px; font-size: 12px; color: var(--fg-dim); }
.mail-body { margin-top: 10px; }
.mail-body .tx { font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.mail-frame { width: 100%; height: 360px; border: none; border-radius: 6px; background: #fff; display: block; }

.pick-list { display: flex; flex-direction: column; gap: 2px; margin-top: 12px; max-height: 260px; overflow-y: auto; }
label.pick { display: flex; gap: 8px; align-items: center; margin: 0; padding: 7px 8px; border-radius: 6px;
             color: var(--fg); font-size: 13.5px; cursor: pointer; }
label.pick:hover { background: var(--bg3); }
.modal.wide { max-width: 680px; }

.n-badge { display: inline-block; font-size: 10.5px; font-weight: 600; color: var(--fg-dim); background: var(--bg3);
           border: 1px solid var(--border); border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 1px; }
.tab-btn:focus:not(:focus-visible) { outline: none; }
/* The conversation fills the pane so the message box sits at the bottom. */
#conv-view:not([hidden]) { display: flex; flex-direction: column; flex: 1; }

/* Drafts / Scheduled counts inside their folder chips. */
.chip-n { margin-left: 6px; font-weight: 700; }
.chip-n:empty { display: none; }
.mail-btns { align-items: center; }
.mail-btns .grow { flex: 1; }
.modal .btn-row.mail-btns button { flex: none; }
.sched { margin-top: 14px; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.sched-title { font-size: 13px; font-weight: 600; }
input[type="datetime-local"] { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; color: var(--fg);
  padding: 8px 10px; font: inherit; font-size: 13px; color-scheme: dark; }
.toolbar.folders { gap: 5px; flex-wrap: nowrap; }
.toolbar.folders .chip { padding: 6px 10px; }

/* ---- files ---- */
.file { align-items: center; }
.file-link { color: var(--fg); text-decoration: none; font-weight: 500; }
.file-link:hover { color: #6cb6ff; text-decoration: underline; }
.link-dl { margin-left: auto; font-size: 12px; color: var(--fg-dim); text-decoration: none; }
.link-dl:hover { color: var(--fg); text-decoration: underline; }
.blk-title .btn { text-transform: none; letter-spacing: 0; padding: 4px 10px; font-size: 12px; }
.drop-hint { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center;
             background: rgba(0,120,212,.18); border: 3px dashed var(--accent); color: #fff; font-size: 20px;
             font-weight: 600; pointer-events: none; }
.mail-files, .attach-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.attach-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 10px; }
.attach-row .attach-list { margin-top: 0; flex: 1; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 999px;
             background: var(--bg2); border: 1px solid var(--border); color: var(--fg); font-size: 12.5px;
             text-decoration: none; max-width: 100%; }
.file-chip span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-chip .sz { color: var(--fg-dim); font-size: 11.5px; }
a.file-chip:hover { border-color: var(--accent); }
.file-chip .x { background: none; border: none; color: var(--fg-dim); cursor: pointer; padding: 0 0 0 2px; font-size: 11px; }
.file-chip .x:hover { color: var(--error); }

.avatar.logo { background: #fff; border-color: #fff; padding: 0; overflow: hidden; }
.avatar.logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.conv-title { display: flex; align-items: center; gap: 10px; }
.attach-btn { display: flex; flex-direction: column; align-items: flex-start; flex-shrink: 0; }
