/* ═══════════════════════════════════════════════════════════════════════════
   ops.css — Slab Brain Ops (StoneFlow) — UI Phase 5
   Replaces style.css + timeclock.css. All colors via sb-design-system tokens.
   Load order: sb-design-system.css → ops.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── App-specific custom properties ────────────────────────────────────── */
:root {
  /* Ticket type colors — functional status indicators, not theme colors */
  --type-hs-border:    rgba(25, 118, 210, .85);
  --type-hs-bg:        rgba(25, 118, 210, .07);
  --type-lu-border:    rgba(46, 125, 50, .85);
  --type-lu-bg:        rgba(46, 125, 50, .08);
  --type-im-border:    var(--color-accent);
  --type-im-bg:        var(--color-accent-subtle);
  --type-issue-border: var(--color-danger);
  --type-issue-bg:     var(--color-danger-subtle);

  /* Time clock — intentional dark terminal panel (warehouse floor display) */
  --tc-bg:     #0F1923;
  --tc-bg2:    #152331;
  --tc-text:   #E8EDF2;
  --tc-border: #2E4058;
  --tc-amber:  #F59E0B;
  --tc-green:  #10B981;
  --tc-red:    #EF4444;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Base reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: var(--text-ui-lg);
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.modalOpen { overflow: hidden; }

h2 { margin: 0 0 var(--space-3); font-weight: 700; font-size: 18px; }

.hidden { display: none !important; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border-bottom: var(--border-hairline);
  box-shadow: var(--shadow-sm);
  min-height: 54px;
}

.topbar .left  { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.topbar .center { display: flex; justify-content: center; align-items: center; }
.topbar .right { display: flex; align-items: center; gap: var(--space-2); }

.brandWrap {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.brandLogo {
  height: 30px;
  width: auto;
  max-width: 148px;
  object-fit: contain;
  display: block;
}

.brand {
  font-size: var(--text-ui-lg);
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* When a tenant logo is present, the app name is a quieter companion label */
.brandWrap.hasLogo .brand {
  font-size: var(--text-ui-md);
  font-weight: 600;
  color: var(--color-text-secondary);
  padding-left: var(--space-2);
  border-left: var(--border-hairline);
}

/* ── User badge ─────────────────────────────────────────────────────────── */
.badge {
  font-size: var(--text-ui-sm);
  padding: 5px var(--space-3);
  border-radius: var(--radius-full);
  border: var(--border-hairline);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ── Desktop mode tabs ──────────────────────────────────────────────────── */
.desktopModeTabs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px;
  background: var(--color-bg);
  border: var(--border-hairline);
  border-radius: var(--radius-full);
}

.desktopModeTabs .desktopTab {
  min-width: 96px;
  border-color: transparent;
  background: transparent;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.desktopModeTabs .desktopTab:hover {
  opacity: 1;
  color: var(--color-text-primary);
}

@media (max-width: 1180px) {
  .desktopModeTabs { display: none !important; }
  /* Left column shrinks (brand truncates); right keeps its natural width so the
     control cluster never pushes the page wider than the viewport. */
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar .right { flex-shrink: 0; }
}

/* Phones: trim the top bar to essentials so the control cluster never crowds or
   overlaps the brand. Kept: role (admin only), logo, mode, language, mute, logout. */
@media (max-width: 560px) {
  .topbar { padding: var(--space-2) var(--space-3); }
  .topbar .left { gap: var(--space-1); }
  .topbar .right { gap: 4px; }
  .iconBtn { min-width: 44px; min-height: 44px; padding: 0 6px; }
  /* The logo already carries the brand on phones — drop the wordmark to save room */
  .brandWrap.hasLogo .brand { display: none; }
  /* Identity badge + Admin chip are non-essential here (Admin has its own mobile tab) */
  #meBadge,
  .topbar .right #adminBtn { display: none; }
}

/* ── Chips ──────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  border: var(--border-standard);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  padding: 6px var(--space-3);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: var(--text-ui-sm);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.chip:hover { opacity: 0.80; }

/* Active segment in the desktop tab track — a raised "selected" pill */
#liveBtn.active,
#pricelistsBtn.active,
#timeClockBtn.active {
  background: var(--color-surface-raised);
  border-color: transparent;
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
  opacity: 1;
}

/* ── Quiet utility buttons (mode / language / mute) ─────────────────────── */
.iconBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-2);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-secondary);
  border-radius: var(--radius-full);
  font-family: inherit;
  font-size: var(--text-ui-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.iconBtn:hover {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.iconBtn.active {
  color: var(--color-accent);
  background: var(--color-accent-subtle);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: var(--border-standard);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border-radius: var(--radius-md);
  padding: 9px var(--space-3);
  min-height: 44px;
  font-family: inherit;
  font-size: var(--text-ui-md);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { opacity: 0.82; }
.btn:active { transform: translateY(1px); }

.btn.sm {
  padding: 6px var(--space-3);
  font-size: var(--text-ui-sm);
}

.btn.gold {
  background: var(--color-accent);
  border-color: transparent;
  color: var(--color-accent-text);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-secondary);
}

.btn.ghost:hover { color: var(--color-text-primary); }

.btn.ok {
  background: var(--color-success-subtle);
  border-color: var(--color-success);
  color: var(--color-success);
}

.btn.danger {
  background: var(--color-danger-subtle);
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── App shell ──────────────────────────────────────────────────────────── */
.appShell {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: calc(100vh - 54px);
}

/* ── Cards (auth) ───────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
}

.authCard {
  max-width: 520px;
  margin: var(--space-6) auto 0;
}

/* ── Form elements ──────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: var(--text-ui-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: var(--space-3) 0 var(--space-1);
}

input, select, textarea {
  width: 100%;
  border: var(--border-standard);
  border-radius: var(--radius-md);
  padding: 9px var(--space-3);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: var(--text-ui-lg);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  padding-right: var(--space-6);
}

input:focus, select:focus, textarea:focus {
  border: var(--border-focus);
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-tertiary);
}

textarea { min-height: 90px; resize: vertical; }

/* ── Layout utilities ───────────────────────────────────────────────────── */
.row    { display: flex; }
.wrap   { flex-wrap: wrap; }
.between { justify-content: space-between; }
.gap    { gap: var(--space-2); }
.small  { font-size: var(--text-ui-sm); }
.muted  { color: var(--color-text-secondary); }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

@media (max-width: 680px) { .grid2 { grid-template-columns: 1fr; } }

.roleGrid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-2);
}

@media (max-width: 560px) { .roleGrid { grid-template-columns: 1fr; } }

/* ── Main view ──────────────────────────────────────────────────────────── */
.mainView {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
}

/* ── Role header ────────────────────────────────────────────────────────── */
.roleHeader {
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
}

.roleHeaderInner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.h1 { font-size: 18px; font-weight: 700; line-height: 1.1; }
.roleActions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ── Content wrap — split pane ──────────────────────────────────────────── */
.contentWrap {
  --tickets-pane-width: 1.6fr;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, var(--tickets-pane-width)) 10px minmax(320px, 1fr);
  gap: var(--space-2);
  align-items: start;
}

/* ── Desktop split handle ───────────────────────────────────────────────── */
.desktopSplitHandle {
  display: none;
  align-self: stretch;
  min-height: 80px;
  cursor: col-resize;
  position: relative;
  border: none;
  background: transparent;
  touch-action: none;
}

/* A vertically-centered floating grip — never a line that looks cut off */
.desktopSplitHandle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
  opacity: 0.5;
  transition: background 0.15s, opacity 0.15s, height 0.15s;
}

.desktopSplitHandle:hover::before,
.desktopSplitHandle:focus-visible::before,
body.is-resizing-split .desktopSplitHandle::before {
  background: var(--color-accent);
  opacity: 1;
  height: 64px;
}

.desktopSplitHandle:focus-visible { outline: none; }

body.is-resizing-split {
  cursor: col-resize;
  user-select: none;
}

/* ── Panels ─────────────────────────────────────────────────────────────── */
.panel {
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
}

.grow { min-width: 0; }
.adminPanel { width: 100%; }

/* ── Filters row ────────────────────────────────────────────────────────── */
.filtersRow { padding-bottom: env(safe-area-inset-bottom); }

.filtersBar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-sm);
}

.filtersBar select { width: auto; min-width: 140px; }

/* ── Desktop height constraints ─────────────────────────────────────────── */
@media (min-width: 1181px) {
  /* Lock shell to viewport so child heights resolve correctly */
  .appShell { height: calc(100vh - 54px); overflow: hidden; }
  .desktopSplitHandle { display: block; }
  .contentWrap {
    height: calc(100vh - 54px - var(--space-4) * 2 - var(--space-3) * 2 - 60px);
    /* stretch so height:100% on panels actually resolves against this height */
    align-items: stretch;
  }
  .ticketsPanel,
  .chatPanel {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  #ticketsWrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
    padding-right: 2px;
  }
  .chatMessages { flex: 1; min-height: 0; overflow-y: auto; }
  .pricelistsPanel,
  .timeClockPanel,
  .adminPanel { height: 100%; min-height: 0; overflow: auto; }
}

@media (max-width: 1180px) {
  .contentWrap { grid-template-columns: 1fr; }
  .desktopSplitHandle { display: none !important; }
  .sidePanel { order: 2; }
  /* Cap chat messages in the stacked (non-tab) single-column view */
  #chatMessages { max-height: 55vh; overflow-y: auto; }
}

/* ── Mobile tabs ─────────────────────────────────────────────────────────── */
.mobileTabs {
  display: none;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-2);
}

.tabBtn {
  flex: 1;
  min-width: 80px;
  border: var(--border-hairline);
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-radius: var(--radius-full);
  padding: 8px var(--space-2);
  font-family: inherit;
  font-size: var(--text-ui-sm);
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  transition: opacity 0.15s;
}

.tabBtn.active {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.tabBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--color-danger);
  color: #fff;
  font-size: var(--text-ui-xs);
  font-weight: 700;
}

/* Mobile tab panel visibility */
@media (max-width: 1180px) {
  .mobileTabs { display: flex; }

  body.tabs-show-chat #ticketsPanel,
  body.tabs-show-chat #pricelistsPanel,
  body.tabs-show-chat #adminPanel,
  body.tabs-show-chat #timeClockPanel { display: none; }

  body.tabs-show-tickets #chatPanel,
  body.tabs-show-tickets #pricelistsPanel,
  body.tabs-show-tickets #adminPanel,
  body.tabs-show-tickets #timeClockPanel { display: none; }

  body.tabs-show-pricelists #ticketsPanel,
  body.tabs-show-pricelists #chatPanel,
  body.tabs-show-pricelists #adminPanel,
  body.tabs-show-pricelists #timeClockPanel { display: none !important; }
  body.tabs-show-pricelists #pricelistsPanel { display: flex !important; width: 100%; min-width: 0; }
  body.tabs-show-pricelists #filtersRow { display: none !important; }
  body.tabs-show-pricelists .contentWrap { grid-template-columns: 1fr; }

  body.tabs-show-admin #chatPanel,
  body.tabs-show-admin #pricelistsPanel { display: none; }
  body.tabs-show-admin #ticketsPanel { display: flex; }
  body.tabs-show-admin #ticketsWrap { display: none; }
  body.tabs-show-admin #adminUsersWrap { display: block !important; }

  body.tabs-show-chat #filtersRow { display: none !important; }

  body.tabs-show-tickets #ticketsPanel,
  body.tabs-show-chat #chatPanel { display: flex; }

  #filtersRow { display: none !important; }
  #filtersBar { display: none !important; }

  #ticketsPanel { min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
}

/* ── Chat panel ──────────────────────────────────────────────────────────── */
.chatPanel {
  display: flex;
  flex-direction: column;
}

.chatHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: var(--border-hairline);
  flex-shrink: 0;
}

.chatTitle { font-weight: 600; font-size: var(--text-ui-lg); }

.chatMessages {
  overflow: auto;
  padding: var(--space-2) 2px;
  flex: 1;
  min-height: 120px;
}

.chatMsg {
  padding: var(--space-2) var(--space-3);
  border: var(--border-hairline);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
}

.chatMeta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-ui-xs);
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}

.chatBody { white-space: pre-wrap; word-wrap: break-word; font-size: var(--text-ui-md); }

.chatComposer {
  border-top: var(--border-hairline);
  padding-top: var(--space-3);
  flex-shrink: 0;
}

.chatComposer textarea { min-height: 52px; resize: none; }

/* Emoji toggle / image-attach / send are frequently tapped on a gloved
   tablet — floor them at the 44px touch-target minimum (the shared .btn
   min-height covers height; these are narrow icon-only buttons that also
   need a min-width). */
#chatEmojiToggle,
#chatImageBtn,
#chatSend {
  min-width: 44px;
  min-height: 44px;
}

/* ── Chat reply bar ──────────────────────────────────────────────────────── */
.chatReplyBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: var(--space-2) 0;
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-subtle);
  border-radius: var(--radius-md);
}

.chatReplyText {
  min-width: 0;
  font-size: var(--text-ui-sm);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatMiniBtn {
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  font-size: var(--text-ui-sm);
  padding: 0;
  line-height: 1;
}

.chatMiniBtn:hover { color: var(--color-text-primary); }

/* ── Chat emoji / reactions ──────────────────────────────────────────────── */
.chatEmojiTray {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin: var(--space-2) 0;
}

.chatMsgActions {
  display: flex;
  gap: var(--space-2);
  margin-top: 4px;
}

.chatReplyPreview {
  margin: 4px 0 var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-left: 3px solid var(--color-accent);
  background: var(--color-accent-subtle);
  border-radius: var(--radius-md);
}

.chatReplyName {
  font-size: var(--text-ui-xs);
  font-weight: 600;
  opacity: .8;
  margin-bottom: 2px;
}

.chatReplySnippet {
  font-size: var(--text-ui-sm);
  opacity: .9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatReactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-2);
}

.chatReactionChip {
  border: var(--border-hairline);
  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
  padding: 3px var(--space-2);
  cursor: pointer;
  font-size: var(--text-ui-sm);
}

.chatReactionChip.mine {
  border-color: var(--color-accent);
  background: var(--color-accent-subtle);
}

.chatReactionPicker {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

/* ── Chat images ────────────────────────────────────────────────────────── */
.chatPendingImages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chatPendingItem {
  position: relative;
  width: 72px;
  height: 72px;
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
}

.chatPendingItem img { width: 100%; height: 100%; object-fit: cover; display: block; }

.chatPendingRemove {
  position: absolute;
  top: 3px;
  right: 3px;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: rgba(15,18,22,.82);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chatAttachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.chatImageThumb {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
}

/* ── Chat mobile scroll fix ─────────────────────────────────────────────── */
@media (max-width: 1180px) {
  body.tabs-show-chat { overflow: auto !important; }
  body.tabs-show-chat .chatPanel { height: auto !important; overflow: hidden !important; }
  body.tabs-show-chat #chatMessages {
    flex: 1;
    min-height: 0;
    max-height: 50vh;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: var(--space-3);
  }
  body.tabs-show-chat .chatComposer {
    position: relative;
    z-index: 2;
    background: var(--color-surface-raised);
    border-top: var(--border-hairline);
    padding: var(--space-3) 0 calc(14px + var(--safe-bottom)) 0;
    margin-bottom: 0;
  }
  body.tabs-show-chat .chatComposer textarea { min-height: 52px; max-height: 120px; }
}

/* ── Ticket items ────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: var(--space-2); }

.item {
  background: var(--color-surface);
  border: var(--border-hairline);
  border-left: 6px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
}

.item.type-hand_select   { border-left-color: var(--type-hs-border);    background: var(--type-hs-bg); }
.item.type-load_up       { border-left-color: var(--type-lu-border);    background: var(--type-lu-bg); }
.item.type-internal_move { border-left-color: var(--type-im-border);    background: var(--type-im-bg); }
.item.type-issue         { border-left-color: var(--type-issue-border); background: var(--type-issue-bg); }

.item.status-unacked,
.item.status-new { box-shadow: 0 0 0 1px var(--color-accent) inset; }

.itemTop {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}

.itemTitle { font-weight: 600; font-size: var(--text-ui-md); }

/* ── Status pills ────────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-ui-xs);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  border: var(--border-hairline);
  background: var(--color-surface-raised);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.3;
}

.pill.urgent {
  border-color: var(--color-danger);
  background: var(--color-danger-subtle);
  color: var(--color-danger);
}

.pill.unacked, .pill.warn {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
}

.pill.ready,
.pill.completed,
.pill.completed_hs,
.pill.closed {
  border-color: var(--color-success);
  background: var(--color-success-subtle);
  color: var(--color-success);
}

/* Board-card ownership chip: "Claimed: <name>" — informational, not
   clickable, so no hover/cursor treatment like .chip. Token-only.
   Background is the OPAQUE --color-surface-raised (matching .pill's base
   rule), not --color-accent-subtle: .item.type-internal_move's own card
   background is ALSO --color-accent-subtle, so a chip on that card type
   stacked two semi-transparent accent tints on top of each other — measured
   ~4.09:1 in dark mode, below WCAG AA's 4.5:1 (tests/test_assignment_frontend.py
   ::test_claimed_chip_meets_aa_contrast). An opaque background fully occludes
   the card tint underneath, so the chip's contrast no longer depends on
   which ticket type it's rendered on. */
.claimedChip {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-ui-xs);
  padding: 3px var(--space-2);
  border-radius: var(--radius-sm);
  border: var(--border-hairline);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.3;
}

/* ── Separators / section blocks ────────────────────────────────────────── */
.sep {
  border: none;
  border-top: var(--border-hairline);
  margin: var(--space-3) 0;
}

.sectionBlock { margin-bottom: var(--space-5); }
.sectionBlock:last-child { margin-bottom: 0; }

.sectionHeader,
.summaryRow {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: var(--border-hairline);
}

.summaryRow { cursor: pointer; }
details:not([open]) > .summaryRow { margin-bottom: 0; }

.sectionTitle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-ui-md);
  letter-spacing: 0.01em;
}

/* Colored marker gives each section a calm, distinct identity */
.sectionTitle::before {
  content: "";
  flex: none;
  width: 4px;
  height: 15px;
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
}

.sectionBlock.live      .sectionTitle::before { background: var(--color-accent); }
.sectionBlock.scheduled .sectionTitle::before { background: var(--color-warning); }
.sectionBlock.older     .sectionTitle::before { background: var(--color-text-tertiary); }

/* Count / status shown as a soft pill instead of loose muted text */
.sectionCount {
  font-size: var(--text-ui-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

/* Collapsible-section caret (scheduled / older) */
.summaryRow .caret {
  display: inline-flex;
  color: var(--color-text-tertiary);
  font-size: 13px;
  transition: transform 0.15s ease;
}
details[open] > .summaryRow .caret { transform: rotate(90deg); }

details > summary::-webkit-details-marker { display: none; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  display: flex;
  /* flex-start + margin:auto on the panel centers it when it fits AND keeps the
     top reachable when it overflows — align-items:center clips the top on iOS. */
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-4);
  z-index: 200;                 /* above the sticky top bar (z-index 100) */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.modalPanel {
  width: min(920px, 100%);
  max-height: 90vh;
  margin: auto;                 /* centers vertically; top-anchors on overflow */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-4);
}

/* Ticket / create modal: fixed head + wrapping action row, only the body scrolls.
   Keeps Close always reachable and stops the action buttons forcing a super-wide,
   horizontally-scrolling header. */
#modal .modalPanel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modalHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: none;
}

.modalActions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}
.modalActions:not(:empty) { margin-top: var(--space-3); }

#modalBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-3);
}

/* Phones: 80% tall, 90% wide, centered. */
@media (max-width: 768px) {
  .modal { padding: var(--space-2); }
  #modal .modalPanel { width: 90vw; height: 80vh; max-height: 80vh; }
}

#modalClose { padding: 8px var(--space-4) !important; font-size: var(--text-ui-sm) !important; min-height: 44px !important; min-width: 44px !important; }

/* Sticky action bar inside ticket modal */
.ticketTopBar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--color-surface-raised);
  border-bottom: var(--border-hairline);
  padding: var(--space-2) 0;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.ticketTopRight { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }
.ticketTopLeft  { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  top: var(--space-4);
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(15, 18, 22, .92); /* intentionally always dark */
  color: #fff;
  padding: 9px var(--space-4);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  max-width: min(720px, calc(100% - 22px));
  font-size: var(--text-ui-md);
}

.toast.hidden { display: none; }
.toast strong { font-weight: 600; }

/* ── Flash overlay ──────────────────────────────────────────────────────── */
.flashOverlay {
  position: fixed;
  inset: 0;
  background: var(--color-accent-subtle);
  pointer-events: none;
  z-index: 9999;
}

.flashOverlay.pulse { animation: flashPulse 700ms ease-out 1; }

@keyframes flashPulse {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Image lightbox ─────────────────────────────────────────────────────── */
.imageLightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 18, 22, .92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.imageLightboxImg {
  max-width: min(1200px, 100%);
  max-height: 90vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.imageLightboxClose {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Misc form utils ─────────────────────────────────────────────────────── */
.visuallyHiddenFile {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.chatImageLabel { display: inline-flex; align-items: center; justify-content: center; }

.etaOverdue { color: var(--color-danger); }

/* ── SO / pricelist PDF page-image viewer ────────────────────────────────── */
/* Android Chrome won't render application/pdf inline in an <iframe>, so pages
   render as PNGs (see main.py /pdfimg/uploads/* + /api/pricelists/*/page/*
   routes) inside a scrollable container. .pdf-page-img is shared by both the
   ticket sales-order viewer and the pricelist viewer; .pdfPagesWrap sizes the
   ticket-modal viewer specifically (the pricelist viewer uses its own
   .pricelistPagesWrap below, sized for a full-width tab rather than a modal). */
.pdfPagesWrap {
  width: 100%;
  max-height: 68vh;
  overflow-y: auto;
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-2);
}

.pdf-page-img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto var(--space-2);
}

@media (max-width: 560px) { .pdfPagesWrap { max-height: 56vh; } }

/* ── Pricelists panel ────────────────────────────────────────────────────── */
.pricelistsPanel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.deliveriesToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-hairline);
  background: var(--color-surface-raised);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border: var(--border-hairline);
  border-bottom: none;
  flex-shrink: 0;
}

.deliveriesTitle { font-weight: 700; font-size: var(--text-ui-xl); line-height: 1.1; }

.pricelistsWrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--space-3);
  background: var(--color-bg);
  border: var(--border-hairline);
  border-top: none;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.deliveryEmpty { padding: var(--space-4); color: var(--color-text-secondary); }

/* Desktop full-width pricelists */
@media (min-width: 1181px) {
  body.desktop-show-pricelists .contentWrap { grid-template-columns: 1fr; height: 100%; }
  body.desktop-show-pricelists #desktopSplitHandle { display: none !important; }
  body.desktop-show-pricelists #ticketsPanel,
  body.desktop-show-pricelists #chatPanel,
  body.desktop-show-pricelists #adminPanel,
  body.desktop-show-pricelists #timeClockPanel { display: none !important; }
  body.desktop-show-pricelists #pricelistsPanel { display: flex !important; height: 100%; min-height: 0; width: 100%; }
  body.desktop-show-pricelists .filtersRow { display: none !important; }
}

/* ── Pricelist cards ──────────────────────────────────────────────────────── */
.pricelistCards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.pricelistCard {
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.pricelistCard.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle), var(--shadow-sm);
}

.pricelistCard.missing { opacity: 0.7; cursor: default; }
.pricelistCardTitle { font-weight: 600; line-height: 1.15; }
.pricelistCardMeta {
  margin-top: 4px;
  color: var(--color-text-secondary);
  font-size: var(--text-ui-sm);
  line-height: 1.35;
}

/* ── Pricelist search ────────────────────────────────────────────────────── */
.pricelistSearchPanel {
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
}

.pricelistSearchHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.pricelistSearchTitle { font-weight: 600; font-size: var(--text-ui-lg); }

.pricelistSearchCount {
  border: var(--border-hairline);
  border-radius: var(--radius-full);
  padding: 4px var(--space-3);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--text-ui-sm);
  font-weight: 600;
  white-space: nowrap;
}

.pricelistSearchInputRow { display: flex; gap: var(--space-2); align-items: center; }

.pricelistSearchInput {
  flex: 1;
  min-width: 0;
  width: auto;
}

.pricelistSearchResults { margin-top: var(--space-3); }

.pricelistSearchEmpty {
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  line-height: 1.4;
  font-size: var(--text-ui-md);
}

.pricelistSearchSummary {
  color: var(--color-text-tertiary);
  font-size: var(--text-ui-sm);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.pricelistSearchResultList { display: grid; gap: var(--space-2); }

.pricelistSearchResult {
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--color-surface-raised);
}

.pricelistSearchResultTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.pricelistSearchColor { font-weight: 600; line-height: 1.2; }
.pricelistSearchSource { margin-top: 2px; color: var(--color-text-secondary); font-size: var(--text-ui-sm); font-weight: 600; }
.pricelistSearchMeta { margin-top: var(--space-2); color: var(--color-text-secondary); font-size: var(--text-ui-sm); line-height: 1.35; }
.pricelistThickness { color: var(--color-text-primary); font-weight: 600; }
.pricelistSearchNotes { margin-top: 5px; color: var(--color-text-secondary); font-size: var(--text-ui-sm); font-style: italic; }

.pricelistSearchPrices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-2); }

.pricelistPriceChip {
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 6px var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}

.pricelistPriceChip span {
  color: var(--color-text-tertiary);
  font-size: var(--text-ui-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pricelistPriceChip strong { font-size: 15px; font-weight: 700; line-height: 1; }

/* ── Pricelist PDF viewer ────────────────────────────────────────────────── */
.pricelistViewer {
  border: var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--color-surface-raised);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.pricelistViewerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-hairline);
  background: var(--color-surface-raised);
}

.pricelistViewerTitle { font-weight: 600; }

.pricelistPagesWrap {
  display: block;
  width: 100%;
  height: calc(100vh - 295px);
  min-height: 520px;
  overflow-y: auto;
  background: var(--color-surface);
  padding: var(--space-2);
}

/* ── Delivery table ──────────────────────────────────────────────────────── */
.deliveryTable {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-ui-sm);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-md);
  border: var(--border-standard);
}

.deliveryTable thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--color-surface);
  font-weight: 600;
  font-size: var(--text-ui-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  text-align: center;
  padding: var(--space-2);
  border-right: var(--border-hairline);
  border-bottom: var(--border-standard);
  white-space: nowrap;
}

.deliveryTable thead th:last-child { border-right: none; }

.deliveryTableStyled tbody tr:nth-child(odd) td  { background-color: var(--color-surface-raised); }
.deliveryTableStyled tbody tr:nth-child(even) td { background-color: var(--color-surface); }

.deliveryTableStyled td {
  color: var(--color-text-primary);
  border-right: var(--border-hairline);
  border-bottom: var(--border-hairline);
}

.deliveryTableStyled td:last-child { border-right: none; }
.deliveryTableStyled tbody tr:hover td { background: var(--color-accent-subtle); }

.deliveryCellWrap {
  min-width: 90px;
  padding: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
}

.deliveryCellText { text-align: inherit; line-height: 1.2; word-break: break-word; width: 100%; }
.deliveryCellClickable { cursor: pointer; transition: background-color .15s, transform .08s; }
.deliveryCellClickable:hover { box-shadow: inset 0 0 0 9999px rgba(0,0,0,.04); }
.deliveryCellClickable:active { transform: scale(.995); }
.deliveryCellClickable:focus { outline: 2px solid var(--color-border-strong); outline-offset: -2px; }
.deliveryQtyClickable { font-weight: 700; }
.deliveryTextClickable { justify-content: flex-start; }
.incomingPoClickable { justify-content: center; font-weight: 600; color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px; }
.incomingPoNoFolder { justify-content: center; font-weight: 600; }
.deliveryQtyClickable.isSaving { opacity: .72; pointer-events: none; }

/* ── Ticket history tools ────────────────────────────────────────────────── */
.ticketHistoryTools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 160px 160px auto;
  gap: var(--space-2);
  align-items: end;
  padding: var(--space-2);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  margin-top: var(--space-2);
}

.ticketHistoryTools label { margin-top: 0; }
.ticketHistorySearchWrap { min-width: 0; }
.ticketHistoryButtons { display: flex; gap: var(--space-2); align-items: center; }
.ticketHistoryLoadMore { display: flex; justify-content: center; margin-top: var(--space-3); }

/* ── Mobile compact ticket cards ────────────────────────────────────────── */
@media (max-width: 680px) {
  .itemTop { flex-direction: column; align-items: stretch; gap: var(--space-2); }
  .itemTop > div:first-child { min-width: 0; }
  .itemTop > .row { justify-content: flex-start !important; flex-wrap: wrap; }
  .itemTitle { font-size: var(--text-ui-md); line-height: 1.25; word-break: break-word; }
  .item .btn.sm { width: 100%; }
  .etaInlineWrap { align-items: stretch !important; }
  .ticketHistoryTools { grid-template-columns: 1fr; }
  .ticketHistoryButtons { align-items: stretch; }
  .ticketHistoryButtons .btn { flex: 1; }
}

/* ── Pricelist mobile ────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .pricelistsWrap { padding: var(--space-2); }
  .pricelistSearchHeader { flex-direction: column; }
  .pricelistSearchInputRow { flex-direction: column; align-items: stretch; }
  .pricelistViewerHeader { align-items: flex-start; flex-direction: column; }
  .pricelistPagesWrap { height: 70vh; min-height: 420px; }
  .deliveryCellWrap { min-width: 82px; font-size: var(--text-ui-sm); }
  .deliveryTable thead th { font-size: var(--text-ui-xs); }
}

/* ── Dark mode toggle button ─────────────────────────────────────────────── */
#modeToggleBtn { font-size: 15px; padding: 5px 9px; line-height: 1; }

/* ═══════════════════════════════════════════════════════════════════════════
   TIME CLOCK — ClockWork module
   Outer shell uses design system tokens.
   .tc-industrial is an intentional dark terminal panel (warehouse display).
   ═══════════════════════════════════════════════════════════════════════════ */

.timeClockPanel { overflow: auto; min-height: 0; }
.timeClockWrap  { min-height: 100%; }

.tc-shell { display: grid; gap: var(--space-3); }

.tc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.tc-title { font-size: 20px; font-weight: 700; }
.tc-sub { color: var(--color-text-secondary); font-size: var(--text-ui-sm); font-weight: 600; }

.tc-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.tc-tab {
  border: var(--border-standard);
  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
  padding: 7px var(--space-3);
  font-family: inherit;
  font-weight: 500;
  font-size: var(--text-ui-sm);
  cursor: pointer;
  color: var(--color-text-primary);
  transition: opacity 0.15s;
}

.tc-tab.active {
  background: var(--color-text-primary);
  color: var(--color-bg);
  border-color: transparent;
}

.tc-grid { display: grid; grid-template-columns: minmax(280px, 430px) 1fr; gap: var(--space-3); align-items: start; }

/* Non-industrial card */
.tc-card {
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}

/* ─── Industrial / terminal dark panel ─────────────────────────────────────
   This dark aesthetic is intentional: the timeclock face is designed for
   warehouse/showroom floor display — dark background improves legibility
   in bright overhead lighting and makes large clock digits "pop."          */
.tc-industrial {
  background: var(--tc-bg);
  color: var(--tc-text);
  border: 1px solid var(--tc-border);
  border-radius: 0;
  box-shadow: none;
}

.tc-industrial .muted,
.tc-industrial .tc-sub { color: rgba(232, 237, 242, .68); }

.tc-brand {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--tc-amber);
  font-weight: 600;
  letter-spacing: .16em;
  font-size: var(--text-ui-xs);
}

.tc-clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: clamp(46px, 12vw, 76px);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.06em;
  text-align: center;
  padding: 22px 6px 8px;
}

.tc-date {
  text-align: center;
  color: rgba(232, 237, 242, .7);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  text-transform: uppercase;
  font-size: var(--text-ui-xs);
  padding-bottom: var(--space-4);
}

.tc-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.tc-status-box {
  background: var(--tc-bg2);
  border: 1px solid var(--tc-border);
  padding: var(--space-3);
  min-height: 84px;
}

.tc-status-box span {
  display: block;
  font-size: var(--text-ui-xs);
  color: rgba(232, 237, 242, .62);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tc-status-box strong { display: block; margin-top: 6px; font-size: 15px; }
.tc-status-box em {
  display: block;
  margin-top: 5px;
  color: var(--tc-amber);
  font-style: normal;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tc-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  background: var(--tc-border);
}

.tc-dot.in  { background: var(--tc-green); box-shadow: 0 0 0 0 rgba(16,185,129,.65); animation: tcPulse 1.6s infinite; }
.tc-dot.out { background: var(--tc-red); }

@keyframes tcPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,.65); }
  70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

.tc-good  { color: var(--tc-green) !important; }
.tc-bad   { color: var(--tc-red) !important; }
.tc-amber { color: var(--tc-amber) !important; }

.tc-gps {
  width: 100%;
  min-height: 48px;
  margin-top: var(--space-2);
  background: var(--tc-bg2);
  border: 1px solid var(--tc-border);
  color: var(--tc-text);
  font-weight: 600;
  cursor: pointer;
  border-radius: 0;
  font-family: inherit;
  font-size: var(--text-ui-md);
}

.tc-gps.on  { color: var(--tc-green); }
.tc-gps.off { color: var(--tc-red); }

.tc-reminder {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--tc-amber);
  background: rgba(245, 158, 11, .16);
  color: var(--tc-text);
}

.tc-big-btn {
  width: 100%;
  margin-top: var(--space-3);
  min-height: 86px;
  border: 0;
  border-radius: 0;
  color: #04130c;
  background: var(--tc-green);
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
}

.tc-big-btn.out      { background: var(--tc-red); color: #260303; }
.tc-big-btn:disabled { opacity: .5; cursor: not-allowed; }
.tc-big-btn.punch    { animation: tcPunch .22s ease-out; }

@keyframes tcPunch {
  0%   { transform: scale(1); }
  50%  { transform: scale(.96); }
  100% { transform: scale(1); }
}

.tc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); margin-top: var(--space-2); }

.tc-btn {
  border: var(--border-standard);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border-radius: var(--radius-md);
  padding: 10px var(--space-3);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  font-size: var(--text-ui-md);
}

.tc-btn:hover { opacity: 0.82; }
.tc-btn.gold   { background: var(--color-accent); border-color: transparent; color: var(--color-accent-text); }
.tc-btn.dark   { background: var(--tc-bg2); color: var(--tc-text); border-color: var(--tc-border); border-radius: 0; }
.tc-btn.danger { background: var(--color-danger-subtle); border-color: var(--color-danger); color: var(--color-danger); }
.tc-btn.sm     { padding: 6px var(--space-2); font-size: var(--text-ui-sm); }
.tc-btn:disabled { opacity: .55; cursor: not-allowed; }

.tc-table-wrap {
  overflow: auto;
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  background: var(--color-surface-raised);
}

.tc-table { width: 100%; border-collapse: collapse; min-width: 740px; }

.tc-table th,
.tc-table td {
  padding: var(--space-2);
  border-bottom: var(--border-hairline);
  text-align: left;
  vertical-align: top;
}

.tc-table th {
  font-size: var(--text-ui-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-tertiary);
  font-weight: 600;
  background: var(--color-surface);
}

.tc-table tr.clickable { cursor: pointer; }
.tc-table tr.clickable:hover td { background: var(--color-accent-subtle); }

.tc-stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }

.tc-stat strong {
  display: block;
  font-size: 28px;
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.tc-stat span {
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  font-size: var(--text-ui-xs);
  font-weight: 600;
}

.tc-toolbar { display: flex; gap: var(--space-2); align-items: end; flex-wrap: wrap; margin-bottom: var(--space-3); }
.tc-toolbar label { margin-top: 0; }
.tc-toolbar input, .tc-toolbar select { min-width: 150px; width: auto; }

.tc-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); align-items: end; }

.tc-shift-list { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.tc-shift {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--tc-border);
  background: var(--tc-bg2);
  color: var(--tc-text);
}

.tc-badge { display: inline-block; font-size: var(--text-ui-xs); font-weight: 600; padding: 2px 5px; border: var(--border-hairline); border-radius: var(--radius-full); }
.tc-badge.auto { border-color: var(--tc-amber); color: var(--tc-amber); }
.tc-badge.ok   { border-color: var(--tc-green); color: var(--tc-green); }
.tc-badge.muted { color: var(--color-text-secondary); }

.tc-pay-employee {
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: var(--space-3);
  background: var(--color-surface-raised);
}

.tc-pay-employee h3 {
  margin: 0;
  padding: var(--space-3);
  background: var(--color-surface);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-ui-lg);
  font-weight: 600;
}

.tc-rfid-list { display: grid; gap: var(--space-2); margin: var(--space-2) 0; }

.tc-rfid-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--color-surface-raised);
}

.tc-qr-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.tc-qr-row img { width: 180px; height: 180px; background: var(--color-surface-raised); padding: var(--space-2); border: var(--border-hairline); }

.tc-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--color-overlay);
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.tc-modal-panel {
  width: min(100%, 520px);
  max-height: 90vh;
  overflow: auto;
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border: var(--border-hairline);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-4);
}

.tc-modal-head { display: flex; justify-content: space-between; gap: var(--space-2); align-items: center; }
.tc-modal-head h2 { margin: 0; }

.tc-scanner {
  width: 240px;
  height: 240px;
  margin: var(--space-3) auto;
  position: relative;
  background: #000;
  overflow: hidden;
}

.tc-scanner video { width: 100%; height: 100%; object-fit: cover; }

.tc-scanner::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 3px solid var(--tc-amber);
  pointer-events: none;
}

.tc-edit-box {
  border: var(--border-hairline);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  background: var(--color-surface);
  margin-bottom: var(--space-3);
}

.tc-check { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; margin: 0 0 var(--space-2); }
.tc-check input { width: auto; }

.tc-muted { color: var(--color-text-secondary) !important; }
.tc-industrial .tc-muted { color: rgba(232, 237, 242, .55) !important; }

.tc-access-list { display: grid; gap: var(--space-2); margin: var(--space-2) 0; }

.tc-access-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--color-surface-raised);
}

.tc-access-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 980px) {
  .tc-grid { grid-template-columns: 1fr; }
  .tc-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tc-form-grid { grid-template-columns: 1fr; }
  .tc-status-grid, .tc-actions { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .tc-access-row { align-items: flex-start; flex-direction: column; }
  .tc-access-actions { justify-content: flex-start; }
}

@media print {
  body * { visibility: hidden !important; }
  .tc-print-area, .tc-print-area * { visibility: visible !important; }
  .tc-print-area { position: absolute !important; left: 0; top: 0; }
}

/* ── Urgent toggle switch (create-ticket forms) ─────────────────────────── */
/* The global `input { width:100%; appearance:none }` rule erases native
   checkboxes, so the URGENT control is a real switch component instead. */
.urgentToggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
  margin: var(--space-2) 0;
  min-height: 44px;
}
.urgentToggle input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}
.urgentToggle .urgentSwitch {
  flex: 0 0 auto;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-strong);
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}
.urgentToggle .urgentSwitch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  transition: transform 0.15s, background 0.15s;
}
.urgentToggle input:checked + .urgentSwitch {
  background: var(--color-danger-subtle);
  border-color: var(--color-danger);
}
.urgentToggle input:checked + .urgentSwitch::after {
  transform: translateX(20px);
  background: var(--color-danger);
}
.urgentToggle input:focus-visible + .urgentSwitch {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.urgentToggle .urgentLabel {
  font-weight: 800;
  font-size: var(--text-ui);
  color: var(--color-text-secondary);
  letter-spacing: 0.03em;
}
.urgentToggle input:checked ~ .urgentLabel {
  color: var(--color-danger);
}

/* Restored-draft notice in the create modals */
.draftNote{
  display:flex; align-items:center; gap:6px;
  margin:0 0 10px; padding:8px 10px;
  border:1px solid var(--color-border);
  border-radius:8px;
  background:var(--color-accent-subtle);
  color:var(--color-text-secondary);
  font-size:13px; font-weight:600;
}
.draftNote .linkBtn{
  background:none; border:none; padding:0;
  color:var(--color-accent);
  font:inherit; font-weight:800; cursor:pointer;
  text-decoration:underline; width:auto;
}
