/* HybridMSP Tickets app styles (from the v15 theme style.css). */
:root {
  --navy-950: #060e1a;
  --navy-900: #0a1628;
  --navy-800: #11223d;
  --blue-600: #0066ff;
  --blue-700: #0052cc;
  --sky-500: #0ea5e9;
  --teal-500: #14b8a6;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--slate-100);
  color: var(--slate-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.container { max-width: 1480px; margin: 0 auto; padding: 0 20px; }

.app-header {
  background: var(--navy-900);
  color: var(--white);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.header-bar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand-wrap { display: flex; align-items: center; gap: 12px; }
.brand-wrap img { width: 38px; height: 38px; border-radius: 9px; }
.brand-title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.1; }
.brand-title span { color: var(--sky-500); }
.brand-sub { font-size: 11px; color: rgba(255,255,255,0.68); font-weight: 600; }

.nav-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-pill {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.06);
  transition: all 0.15s ease;
}
.nav-pill:hover, .nav-pill.active { background: var(--blue-600); color: var(--white); }

.gear-wrap { position: relative; display: inline-block; }
.btn-gear {
  background: var(--navy-800);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-gear:hover, .btn-gear.active { background: var(--blue-600); border-color: var(--blue-600); }
.gear-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--white);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px;
  width: 265px;
  box-shadow: 0 16px 36px rgba(10, 22, 40, 0.22);
  z-index: 1500;
}
.gear-menu.open { display: block; }
.gear-item {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-700);
}
.gear-item:hover, .gear-item.active { background: #eff6ff; color: var(--blue-600); }
.gear-divider { height: 1px; background: var(--slate-200); margin: 6px 0; }

.sidebar-layout { display: grid; grid-template-columns: 240px 1fr; gap: 22px; align-items: start; }
.admin-sidebar { background: var(--slate-50); border: 1px solid var(--slate-200); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.admin-side-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--slate-700); }
.admin-side-link:hover { background: #e2e8f0; color: var(--navy-900); }
.admin-side-link.active { background: var(--navy-900); color: var(--white); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 700; border: none; cursor: pointer; }
.btn-primary { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: var(--blue-700); }
.btn-teal { background: var(--teal-500); color: var(--white); }
.btn-teal:hover { background: #0d9488; }
.btn-danger { background: #dc2626; color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-dark { background: var(--navy-800); color: var(--white); border: 1px solid rgba(255,255,255,0.16); }
.btn-outline { background: var(--white); color: var(--slate-700); border: 1px solid #cbd5e1; }
.btn-outline:hover { border-color: var(--blue-600); color: var(--blue-600); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.btn-mic {
  background: rgba(255,255,255,0.12);
  color: #38bdf8;
  border: 1px solid rgba(56,189,248,0.4);
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-mic.listening { background: #dc2626; color: #ffffff; border-color: #f87171; }

.ai-copilot-bar {
  background: linear-gradient(135deg, var(--navy-900) 0%, #152c4e 100%);
  border-radius: 14px;
  padding: 14px 18px;
  color: var(--white);
  margin: 18px 0;
  border: 1px solid rgba(56, 189, 248, 0.25);
}
.ai-input-row { display: flex; gap: 10px; align-items: center; }
.ai-label-pill { font-size: 13px; font-weight: 800; color: #38bdf8; white-space: nowrap; }
.ai-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.09);
  color: var(--white);
  font-size: 14px;
}
.ai-input::placeholder { color: rgba(255,255,255,0.55); }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-box { background: var(--white); border: 1px solid var(--slate-200); border-radius: 12px; padding: 14px 18px; display: block; }
a.stat-box:hover { border-color: var(--blue-600); }
.stat-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--slate-500); font-weight: 700; display: flex; justify-content: space-between; }
.stat-num { font-size: 24px; font-weight: 800; color: var(--navy-900); margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--slate-500); margin-top: 4px; font-weight: 600; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stat-chip { display: inline-block; padding: 2px 7px; border-radius: 6px; background: #eff6ff; color: #1d4ed8; font-weight: 700; font-size: 11px; }

.gauge-track { width: 100%; height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.gauge-fill-billable { height: 100%; background: linear-gradient(90deg, #0066ff, #0ea5e9); }
.gauge-fill-nonbill { height: 100%; background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.panel { background: var(--white); border: 1px solid var(--slate-200); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--slate-200); flex-wrap: wrap; gap: 10px; }
.panel-head h2 { font-size: 18px; font-weight: 800; color: var(--navy-900); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-main { display: grid; grid-template-columns: 1.45fr 0.85fr; gap: 20px; align-items: start; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; padding: 10px; background: var(--slate-50); color: var(--slate-600); font-weight: 700; border-bottom: 1px solid var(--slate-200); white-space: nowrap; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: var(--slate-700); cursor: pointer; }
.sort-link:hover { color: var(--blue-600); }
.sort-active { color: var(--blue-600); font-weight: 800; }
.data-table td { padding: 11px 10px; border-bottom: 1px solid var(--slate-200); vertical-align: middle; }
.ticket-row { cursor: pointer; }
.ticket-row:hover td { background: #eff6ff; }
.ticket-num-link { color: var(--blue-600); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }

.filter-bar { display: flex; gap: 8px; align-items: center; background: var(--slate-50); border: 1px solid var(--slate-200); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; flex-wrap: wrap; }

.sel-menu-wrap { position: relative; display: none; }
.sel-menu-wrap.visible { display: inline-block; }
.sel-dropdown { display: none; position: absolute; left: 0; top: calc(100% + 6px); background: var(--white); border: 1px solid #cbd5e1; border-radius: 10px; padding: 8px; width: 230px; box-shadow: 0 16px 36px rgba(10, 22, 40, 0.22); z-index: 600; }
.sel-dropdown.open { display: block; }
.sel-action-btn { width: 100%; text-align: left; background: none; border: none; padding: 9px 12px; border-radius: 7px; font-size: 13px; font-weight: 700; color: var(--slate-700); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.sel-action-btn:hover { background: #eff6ff; color: var(--blue-600); }
.sel-action-btn.danger { color: #dc2626; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-dp { background: #e0f2fe; color: #0369a1; }
.badge-hmsp { background: #dcfce7; color: #15803d; }
.badge-ai { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.badge-hours { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.status-new { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.status-in-progress { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.status-customer-note { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.status-waiting-customer { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.status-waiting-materials { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.status-reopened { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.status-closed { background: #e2e8f0; color: #475569; border: 1px solid #cbd5e1; }
.status-default { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }

.prio-high { color: #b91c1c; font-weight: 800; }
.prio-p2 { color: #c2410c; font-weight: 700; }
.prio-med { color: #475569; font-weight: 600; }

.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(6, 14, 26, 0.65); z-index: 2000; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal-card { background: var(--white); border-radius: 14px; max-width: 580px; width: 100%; padding: 24px; box-shadow: 0 24px 48px rgba(0,0,0,0.28); max-height: 92vh; overflow-y: auto; }

.col-picker-wrap { position: relative; display: inline-block; }
.col-picker-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: var(--white); border: 1px solid #cbd5e1; border-radius: 10px; padding: 14px; width: 240px; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14); z-index: 500; }
.col-picker-menu.open { display: block; }
.col-picker-item { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--slate-700); padding: 5px 0; cursor: pointer; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 700; color: var(--slate-700); margin-bottom: 4px; }
.input-ctrl { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px; font-family: inherit; background: var(--white); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.alert-ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-err { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.thread-entry { border-left: 4px solid #64748b; background: var(--slate-50); padding: 12px 14px; border-radius: 0 8px 8px 0; margin-bottom: 12px; }
.thread-entry.thread-ai { border-left-color: #0d9488; background: #f0fdfa; }
.thread-entry.thread-agent { border-left-color: var(--blue-600); background: #eff6ff; }
.thread-meta { font-size: 12px; font-weight: 700; color: var(--navy-900); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.thread-body { font-size: 13px; color: var(--slate-700); white-space: pre-wrap; }

.login-box { max-width: 430px; margin: 56px auto; background: var(--white); border-radius: 16px; padding: 34px; box-shadow: 0 20px 40px rgba(10,22,40,0.1); border: 1px solid var(--slate-200); }

@media print {
  .app-header, .ai-copilot-bar, .no-print { display: none !important; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
}

@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-main, .grid-2, .sidebar-layout { grid-template-columns: 1fr; }
  .ai-input-row { flex-direction: column; align-items: stretch; }
}

/* ---- Plugin additions (v17-v21 screens on the v15 look) ---- */
.alert-warn { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.badge-transit { background: #fef3c7; color: #b45309; }
.badge-review { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-nonbill { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.totals-strip { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0 14px; }
.totals-strip .tot { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px 14px; font-size: 12px; color: #475569; }
.totals-strip .tot strong { display: block; font-size: 17px; color: #0f172a; }
.row-review td { background: #fff7ed; }
