* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: #f5f6f8;
  margin: 0;
  color: #1c1e21;
}

.login-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box { background: #fff; padding: 32px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.1); width: 320px; display: flex; flex-direction: column; gap: 8px; }
.login-box h1 { margin: 0 0 12px; font-size: 20px; }
.login-box input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.login-box button { margin-top: 12px; padding: 10px; background: #2563eb; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.error { color: #c0392b; font-size: 13px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e0e2e6; }
.search-wrap { position: relative; width: 420px; }
#client-search { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.search-results { position: absolute; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid #ddd; border-radius: 4px; max-height: 420px; overflow-y: auto; z-index: 10; }
.search-result { padding: 8px; border-bottom: 1px solid #eee; font-size: 14px; }
.hidden { display: none; }

.lookup-client { padding: 10px 12px; border-bottom: 1px solid #eee; }
.lookup-client-name { font-weight: 700; margin-bottom: 6px; }
.lookup-ticket { padding: 4px 0; font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.lookup-ticket a { color: #2563eb; }
.lookup-meta { font-size: 11px; color: #888; }
.user-info { font-size: 13px; color: #555; }
.user-info a { color: #2563eb; }

.summary-cards { display: flex; gap: 16px; padding: 16px 20px; }
.card { flex: 1; background: #fff; border-radius: 8px; padding: 16px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card .num { display: block; font-size: 28px; font-weight: 700; }
.card .label { font-size: 13px; color: #666; }
.card.urgent .num { color: #c0392b; }
.card.review .num { color: #b7791f; }
.card.covered .num { color: #2f855a; }

.main-layout { display: flex; height: calc(100vh - 170px); padding: 0 20px 20px; gap: 16px; }
.sidebar { width: 340px; background: #fff; border-radius: 8px; overflow-y: auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.case-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #eee; cursor: pointer; font-size: 14px; }
.case-row:hover { background: #f0f4ff; }
.case-row.handled { opacity: .55; }
.row-main { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.row-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-category { font-size: 11px; color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urgent-tag { background: #c0392b; color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 10px; }
.empty, .empty-detail { padding: 24px; color: #888; text-align: center; }

.urgency-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  background: #f5f6f8;
  border-bottom: 1px solid #e0e2e6;
  position: sticky;
  top: 0;
}

/* Category left-border accent — quick visual scan without reading the label */
.case-row.cat-no_ticket { border-right: 3px solid #c0392b; }
.case-row.cat-untagged { border-right: 3px solid #b7791f; }
.case-row.cat-flagged { border-right: 3px solid #b7791f; }
.case-row.cat-covered { border-right: 3px solid #2f855a; }

.detail-pane { flex: 1; background: #fff; border-radius: 8px; padding: 24px; overflow-y: auto; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.detail-pane h2 { margin-top: 0; }
.badge-row { display: flex; gap: 8px; margin-bottom: 12px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: #eee; }
.badge.conf-high { background: #d4f4dd; color: #1e6b3a; }
.badge.conf-low, .badge.conf-ambiguous { background: #fdecc8; color: #8a5a00; }
.badge.cat-no_ticket { background: #f8d7da; color: #842029; }
.badge.cat-untagged, .badge.cat-flagged { background: #fdecc8; color: #8a5a00; }
.badge.cat-covered { background: #d4f4dd; color: #1e6b3a; }
.badge.state-confirmed, .badge.state-handled { background: #d4f4dd; color: #1e6b3a; }
.badge.state-wrong { background: #f8d7da; color: #842029; }
.badge.state-review { background: #fdecc8; color: #8a5a00; }

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c1e21;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.urgent-badge { background: #f8d7da; color: #842029; }
.summary-line { background: #f8f9fa; padding: 10px; border-radius: 6px; font-size: 14px; }
.links a { color: #2563eb; }

.action-row, .handled-row { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.action-row button, .handled-row button { padding: 8px 14px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; }
.btn-confirm { background: #2f855a; color: #fff; }
.btn-reject { background: #c0392b; color: #fff; }
.btn-fix { background: #b7791f; color: #fff; }
.btn-dismiss { background: #555; color: #fff; }
.handled-row button { background: #e2e8f0; }

.fix-form { margin: 8px 0; padding: 10px; background: #f8f9fa; border-radius: 6px; }
.fix-form input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.fix-result { padding: 6px 4px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 13px; }
.fix-result:hover { background: #eef2ff; }
.current-state { font-size: 13px; color: #555; }
.no-ticket-tag { color: #b7791f; font-size: 11px; }
