/* ============================================================
   Everflow Practice OS — components.css  (u74-foundations)
   The ONE control system for "Cobalt Paper" (DESIGN-SYSTEM.md v3).
   Loaded after styles.css: it restyles the existing class names
   (btn-primary, btn-ghost, btn-small, seg-control, pill, sort-select,
   nav-item, topbar …) so nothing in app.js had to be rewired.
   Rules: one radius (--r), hairlines not shadows, two typefaces,
   six sizes, tabular numerals on every number, zero emoji in chrome.
   ============================================================ */

/* ---------- base ---------- */
body { font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); font-feature-settings: "ss01", "cv11"; }
.layout { background: var(--bg); }
.main { margin-left: 240px; padding: 0 28px 48px; max-width: none; min-width: 0; }
.main > *:not(.topbar) { max-width: 1240px; }
body.has-values-rail .main { margin-right: 0; }      /* the right rail is retired */
#valuesRail.values-rail { display: none !important; }
.num, .conv-time, .conv-count, .card-time, .counts, .rail-stat b, td, th { font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 18px; } h3 { font-size: 14px; font-weight: 700; }
a { color: var(--accent-ink); }
::selection { background: var(--accent-soft); }
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible, .btn-primary:focus-visible, .btn-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }
.ti { font-size: 16px; line-height: 1; vertical-align: -3px; }

/* ---------- sidebar ---------- */
.sidebar { width: 240px; background: var(--sidebar-bg); border-right: 1px solid var(--border); color: var(--sidebar-text); }
.brand-wrap { padding: 20px 20px 12px; border-bottom: 0; flex-direction: row; align-items: baseline; gap: 8px; }
.brand-wrap .ef-wordmark { font-size: 22px !important; text-align: left !important; color: var(--text); }
.brand-wrap .ef-wordmark.ef-reversed { color: var(--text); }
.brand-wrap .ef-wordmark .ef-flow { color: var(--accent); }
.brand-caption { text-align: left; font-size: 10.5px; letter-spacing: .12em; color: var(--ink-3); }
.nav { padding: 4px 12px 12px; }
.nav-search { margin: 4px 0 6px; color: var(--ink-3); }
.nav-group { margin-top: 10px; }
.nav-group-flat { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.nav-group-h {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: 0; cursor: pointer; padding: 6px 8px 4px;
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
  border-radius: 6px;
}
.nav-group-h:hover { color: var(--text); }
.nav-group-h .ti { font-size: 12px; color: var(--ink-4); transition: transform var(--t) var(--ease); }
.nav-group-closed .nav-group-h .ti { transform: rotate(-90deg); }
.nav-group-closed .nav-group-items { display: none; }
.nav-group-empty { display: none; }
.nav-label { display: none; }
.nav-item, .filter-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 32px; padding: 0 8px 0 10px; margin: 0; border-radius: var(--r);
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.nav-item:hover { background: var(--sunken); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; box-shadow: none; }
.nav-item .ti { color: var(--ink-3); font-size: 16px; width: 18px; opacity: 1; }
.nav-item.active .ti { color: var(--accent-ink); }
.nav-pill, .nav-item .pill {
  margin-left: auto; background: none; color: var(--ink-3); font-weight: 500; font-size: 12px;
  padding: 0 2px; min-width: 0; line-height: 18px; font-variant-numeric: tabular-nums;
}
.nav-item .nav-pill:not(.nav-pill-muted) { background: var(--accent); color: #fff; font-weight: 600; padding: 0 7px; border-radius: var(--r-pill); }
.nav-item .nav-pill:empty { display: none; }
.nav-item.active .nav-pill.nav-pill-muted { color: var(--accent-ink); }
.sidebar-footer { padding: 10px 12px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--ink-3); position: relative; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; cursor: pointer;
  padding: 6px 8px; border-radius: var(--r); font: inherit; color: inherit; text-align: left;
}
.sidebar-user:hover { background: var(--sunken); }
.sidebar-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: 0 0 auto;
}
.sidebar-user-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sidebar-user-text #userStatus { font-size: 13px; font-weight: 600; color: var(--text); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-conn-summary { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.sidebar-user > .ti { color: var(--ink-4); font-size: 16px; }
.sidebar-conn {
  display: none; position: absolute; left: 12px; right: 12px; bottom: calc(100% - 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-pop);
  padding: 10px 12px; z-index: 60;
}
.sidebar-conn.open { display: block; }
.sidebar-conn .status-row { margin-bottom: 6px; font-size: 12.5px; color: var(--text-2); }
.sidebar-conn .status-row:last-child { margin-bottom: 0; padding-top: 6px; border-top: 1px solid var(--border); }
.sidebar-conn a { color: var(--accent-ink); font-weight: 500; }
.dot { width: 7px; height: 7px; }
.dot-live { background: var(--green); } .dot-warn { background: var(--amber); } .dot-off { background: var(--ink-4); }

/* ---------- topbar: a slim bar, not a card ---------- */
.topbar {
  background: var(--bg); border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none;
  margin: 0 -28px 18px; padding: 10px 28px; min-height: 56px; top: 0; z-index: 40;
}
.topbar h1 { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.topbar-right { gap: 8px; }
.topbar .counts { color: var(--ink-3); font-size: 13px; }
.topbar .btn-ghost { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.topbar .btn-ghost:hover { color: var(--text); border-color: var(--ink-4); }
.topbar .btn-ghost.btn-gold, #briefingBtn { border-color: var(--border-2); color: var(--text-2); }
#briefingBtn:hover { color: var(--accent-ink); border-color: var(--accent); }
.topbar select, .topbar input[type="search"], .topbar input[type="text"] { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.topbar #searchBox, #searchBox { background: var(--surface); border-color: var(--border-2); height: 32px; padding: 0 12px; font-size: 13px; }
.channel-seg .filter-item { width: auto; height: 28px; padding: 0 10px; margin: 0; color: var(--ink-3); }
.channel-seg .filter-item:hover { background: none; color: var(--text); }
.channel-seg .filter-item.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.channel-seg .filter-item .ti { font-size: 14px; width: auto; color: inherit; }
.ai-emoji .ti, .conv-avatar .ti { font-size: 15px; }
.conv-row.sent-urgent .ai-emoji { color: var(--red); } .conv-row.sent-angry .ai-emoji { color: var(--red); } .conv-row.sent-worried .ai-emoji { color: var(--amber); } .conv-row.sent-happy .ai-emoji { color: var(--green); }

/* ---------- buttons ---------- */
.btn-primary, .btn-ghost, .btn-small, .btn-link, .row-act, .cv-replyall, .cv-sq, .es-kindbtn {
  font-family: var(--font-body); font-size: 13px; font-weight: 500; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--r); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; vertical-align: middle;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease);
}
.btn-primary:active, .btn-ghost:active { transform: translateY(.5px); }
.btn-primary { background: var(--cta); color: #fff; border-color: var(--cta); font-weight: 600; }
.btn-primary:hover { background: var(--cta-ink); border-color: var(--cta-ink); }
.btn-primary[disabled], .btn-ghost[disabled] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover { color: var(--text); border-color: var(--ink-4); background: var(--surface); }
.btn-ghost.btn-gold { color: var(--amber); border-color: var(--border-2); }
.btn-ghost.danger, .btn-danger { color: var(--red); }
.btn-small { height: 28px; padding: 0 10px; font-size: 12.5px; margin-left: 6px; }
.btn-small.btn-primary { font-weight: 600; }
.btn-link { height: auto; padding: 0; border: 0; background: none; color: var(--accent-ink); font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.row-act { height: 28px; min-width: 28px; padding: 0 8px; background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.row-act:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.cv-replyall, .cv-sq { background: var(--surface); border-color: var(--border-2); color: var(--text-2); }
.cv-replyall:hover, .cv-sq:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.cv-ib { border-radius: var(--r); }
.cv-ib:hover { background: var(--sunken); }

/* ---------- inputs ---------- */
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="date"], input[type="time"],
input[type="password"], input[type="tel"], input[type="url"], select, textarea, .sort-select, .auth-input {
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r);
  transition: border-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="date"], input[type="time"],
input[type="password"], input[type="tel"], input[type="url"], select, .sort-select { height: 32px; padding: 0 10px; }
textarea { padding: 8px 10px; line-height: 1.5; min-height: 72px; }
select, .sort-select { padding-right: 28px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23697077' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; cursor: pointer; }
input:focus, select:focus, textarea:focus, .sort-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 15px; height: 15px; }
.auth-input { height: 40px; font-size: 14px; }

/* ---------- segmented control (one tab system) ---------- */
.seg-control, .feed-tabs, .reply-tabs, .ceo-tabs {
  display: inline-flex; gap: 2px; padding: 2px; background: var(--sunken); border-radius: var(--r); border: 0; flex-wrap: wrap;
}
.seg-control button, .feed-tabs button, .reply-tabs button, .ceo-view-pill {
  height: 28px; padding: 0 12px; border-radius: calc(var(--r) - 2px); border: 1px solid transparent; background: none;
  font-family: var(--font-body); font-size: 13px; font-weight: 500; color: var(--ink-3); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin: 0;
  transition: background var(--t) var(--ease), color var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.seg-control button:hover, .feed-tabs button:hover, .reply-tabs button:hover, .ceo-view-pill:hover { color: var(--text); border-color: transparent; }
.seg-control button.active, .feed-tabs button.active, .reply-tabs button.active, .ceo-view-pill.active {
  background: var(--surface); color: var(--text); font-weight: 600; border-color: transparent; box-shadow: var(--shadow);
}
.reply-tabs #tabComment.active { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.ceo-view-pill { background: none; }
.on-tabs { gap: 4px; border-bottom: 1px solid var(--border); }
.on-tabs button { height: 36px; padding: 0 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-3); border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; border-radius: 0; }
.on-tabs button.active { color: var(--text); border-bottom-color: var(--text); background: none; }

/* ---------- pills & chips ---------- */
.pill, .conv-pill, .mks-chip, .cat-chip, .important-chip, .tag-chip, .attach-chip, .folder-chip, .card-tag-chip, .group-tag, .source-tag, .mailbox-tag, .wk-chip-wait, .th-docchip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 500; line-height: 1; background: var(--sunken); color: var(--text-2); border: 1px solid transparent; white-space: nowrap;
}
.pill-open, .conv-pill.mention { background: var(--accent-soft); color: var(--accent-ink); }
.conv-pill.important, .important-chip, .wk-chip-wait { background: var(--amber-soft); color: var(--amber); }
.assignee-chip { background: var(--text); color: #fff; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; padding: 2px 8px; }
.conv-mention-chip { background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-pill); }
.count-badge { background: var(--accent); color: #fff; border-radius: var(--r-pill); font-variant-numeric: tabular-nums; }
.gmail-state.connected { color: var(--green); }

/* ---------- surfaces ---------- */
.card, .modal, .settings-card, .stat-card, .chart-card, .mk-card, .mks-card, .wk-card, .on-card, .qt-card, .ob-card, .mks-tile, .on-tile, .folder-tile, .cs-table, .mks-table, .wk-table, .contacts-table, .data-table {
  border-radius: var(--r); box-shadow: none; border-color: var(--border);
}
.card { box-shadow: none; }
.card:hover { box-shadow: none; border-color: var(--border-2); transform: none; }
.conv-page .modal, .modal-backdrop .modal, .cv-dock { box-shadow: none; }
.popover, .cv-pop, .dropdown, .menu-pop { box-shadow: var(--shadow-pop); border: 1px solid var(--border); border-radius: var(--r); }
table.cs-table th, table.mks-table th, table.wk-table th, table.contacts-table th, table.data-table th {
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); font-weight: 600;
}
.empty-state { padding: 48px 20px; color: var(--ink-3); font-size: 13.5px; }
.empty-state b, .empty-state strong { display: block; color: var(--text); font-weight: 600; font-size: 14px; margin-bottom: 4px; }

/* ---------- the TODAY stat strip (ex right rail) ---------- */
.stat-strip { margin-bottom: 18px; }
.stat-strip:empty { display: none; }
.rail-stats {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; padding: 0; margin: 0;
}
.rail-stats.hidden + .rail-owner { border-top-left-radius: var(--r); border-top-right-radius: var(--r); }
.rail-stat {
  display: flex; flex-direction: column-reverse; gap: 2px; padding: 12px 18px; border: 0; border-right: 1px solid var(--border);
}
.rail-stat:last-child { border-right: 0; }
.rail-stat span { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.rail-stat b { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); }
.rail-stat b.up { color: var(--green); } .rail-stat b.warn { color: var(--amber); }
.rail-owner {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px; margin: 0;
  background: var(--surface); border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--r) var(--r); font-size: 12.5px;
}
.rail-owner .rail-owner-head { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; margin: 0; }
.rail-owner .rail-stat { flex-direction: row; align-items: baseline; gap: 10px; padding: 0; border: 0; }
.rail-owner .rail-stat b { font-size: 16px; }
.rail-owner-note { margin: 0; margin-left: auto; color: var(--ink-4); font-size: 11.5px; }

/* ---------- motion & accessibility ---------- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (max-width: 1300px) { .main { padding: 0 20px 40px; } .topbar { margin: 0 -20px 16px; padding: 10px 20px; } }

/* ---------- toolbar row under a topbar / stat strip ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-spacer { flex: 1; }
.toolbar #searchBox { width: 300px; }
.topbar > .counts { margin-left: 4px; }

/* u110-triage-tagged-ui: Triage → Tagged count and its "Tagged in" row */
.tagged-n { display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 3px; border-radius: 9px; background: var(--accent, #3b5bdb); color: #fff; font-size: 10.5px; line-height: 16px; font-weight: 700; text-align: center; }
.tagged-n.hidden { display: none; }
#view-inbox .seg-control.tag-sub { align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border: 1px solid var(--accent-line, #c9d4f5); border-radius: 10px; background: var(--accent-soft, #eef2fd); }
#view-inbox .seg-control.tag-sub.hidden { display: none; }
#view-inbox .tag-sub .tag-sub-l { font-size: 12px; font-weight: 600; color: var(--accent-ink, #2c3e8c); margin-right: 4px; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
#view-inbox .seg-control.tag-sub > button { height: 28px; padding: 0 10px; font-size: 12.5px; border-color: transparent; background: transparent; }
#view-inbox .seg-control.tag-sub > button.active { background: var(--surface, #fff); border-color: var(--accent-line, #c9d4f5); }
#view-inbox .seg-control.tag-sub > button .ti { font-size: 13px; }
@media (max-width: 600px) {
  #view-inbox .seg-control.tag-sub { flex-basis: 100%; max-width: 100%; box-sizing: border-box; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-left: 8px; }
  #view-inbox .tag-sub .tag-sub-l { font-size: 11.5px; }
  #view-inbox .seg-control.tag-sub > button { padding: 0 8px; flex: 0 0 auto; }
}
