/* =====================================================================
   Amberley Support Portal — Asana-style design system (app.css)
   Adopted in-scope (staff) pages during the redesign. See
   Docs/asana-redesign-prd.md. Light theme only.
   ===================================================================== */

:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;     /* table headers, hover, chips */
  --bg-hover: #f1f1f3;

  /* Dark sidebar (Amberley brand dark) */
  --sidebar-bg: #1f1e2a;
  --sidebar-text: #e7e7ea;
  --sidebar-muted: #9b9ba6;
  --sidebar-hover: #2b2a38;
  --sidebar-active: #34323f;

  /* Borders / text */
  --border: #ededed;
  --border-strong: #e0e0e0;
  --text: #1f1e2a;
  --muted: #6d6e6f;

  /* Brand / accents */
  --primary: #ef7b5c;       /* Amberley orange */
  --primary-hover: #e26a4b;
  --accent: #796eff;        /* purple — focus, selection, links */
  --danger: #e8384f;
  --green: #14a44d;

  /* Priority / status */
  --urgent: #e8384f;
  --high: #ec8b00;
  --medium: #4186e0;
  --low: #8a8f98;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-pop: 0 12px 40px rgba(0,0,0,.16);
}

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

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.35rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }

/* ----- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.5rem 0.9rem; border: 1px solid transparent; border-radius: 7px;
  font-size: 0.875rem; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--bg-subtle); color: var(--text); line-height: 1;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg-subtle); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: transparent; color: var(--muted);
  border-radius: 7px; cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ----- Forms ---------------------------------------------------------- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.82rem; font-weight: 600; color: var(--text); }
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
input, select, textarea {
  width: 100%; padding: 0.55rem 0.65rem; font-size: 0.875rem; font-family: inherit;
  color: var(--text); background: #fff; border: 1px solid var(--border-strong);
  border-radius: 7px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(121,110,255,.18); }
textarea { resize: vertical; min-height: 90px; }
.required { color: var(--danger); }

/* ----- App shell (sidebar + content) ---------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 14px 12px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 0.5rem; padding: 6px 8px 14px; font-size: 1.05rem; font-weight: 700; color: #fff; }
.sidebar-brand img { height: 26px; width: auto; }
.sidebar-section { padding: 14px 10px 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left;
  padding: 8px 10px; margin-bottom: 2px; border: none; background: transparent;
  color: var(--sidebar-text); border-radius: 7px; font-size: 0.9rem; font-weight: 500; cursor: pointer;
  text-decoration: none; position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav-item .nav-ico { width: 18px; text-align: center; font-size: 0.95rem; }
.nav-item .nav-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { background: rgba(255,255,255,0.1); color: var(--sidebar-text); border-radius: 10px; font-size: 0.72rem; font-weight: 600; padding: 1px 8px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 0.55rem; padding: 6px 8px; overflow: hidden; }
.sidebar-user .meta { min-width: 0; flex: 1; display: block; overflow: hidden; }
/* who/sub are block-level so text-overflow:ellipsis can engage (it never does on
   inline spans) — otherwise a long email overflows the sidebar into the content. */
.sidebar-user .who { display: block; max-width: 100%; font-size: 0.82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .sub { display: block; max-width: 100%; font-size: 0.72rem; color: var(--sidebar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout { display: block; width: 100%; text-align: left; padding: 8px 10px; margin-top: 4px; border: none; background: transparent; color: var(--sidebar-muted); border-radius: 7px; font-size: 0.85rem; cursor: pointer; }
.sidebar-logout:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }

.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 600; flex-shrink: 0; }

/* Content area */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.view-header { position: sticky; top: 0; z-index: 5; background: rgba(255,255,255,0.92); backdrop-filter: saturate(1.2) blur(4px); border-bottom: 1px solid var(--border); padding: 16px 28px; display: flex; align-items: center; gap: 1rem; }
.view-header h1 { font-size: 1.25rem; }
.view-header .spacer { flex: 1; }
.view-body { padding: 22px 28px 80px; max-width: 1500px; width: 100%; }

/* Mobile top bar + drawer */
.mobile-topbar { display: none; }
@media (max-width: 860px) {
  .mobile-topbar { display: flex; align-items: center; gap: 0.6rem; background: var(--sidebar-bg); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
  .mobile-topbar .hamburger { background: transparent; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s ease; }
  .app.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .app.nav-open .sidebar-backdrop { display: block; }
  .view-body { padding: 16px; }
  .view-header { padding: 14px 16px; }
}

/* ----- Cards ---------------------------------------------------------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .cards-2 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ----- Lists (Asana-style flex table) --------------------------------- */
.list { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.list-head, .list-row { display: grid; align-items: center; gap: 10px; padding: 9px 16px; }
.list-head { background: var(--bg-subtle); font-size: 0.75rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.list-row { border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-subtle); }
.list-row .t-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .t-sub { color: var(--muted); font-size: 0.8rem; }
.cell-num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }

/* ----- Pills / badges ------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 0.3rem; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.status { color: #475569; background: #eef2f6; }
.status.open { background: #e7f0ff; color: #2c5fb3; }
.status.in_progress { background: #fdf2d6; color: #946b00; }
.status.waiting_customer, .status.waiting_amberley { background: #fde4ee; color: #b13a72; }
.status.resolved { background: #e6f4ea; color: #197b46; }
.status.closed { background: #ececf0; color: #5b5b66; }
.prio { }
.prio.low { background: color-mix(in srgb, var(--low) 16%, #fff); color: #555b63; }
.prio.medium { background: color-mix(in srgb, var(--medium) 16%, #fff); color: #285fa6; }
.prio.high { background: color-mix(in srgb, var(--high) 18%, #fff); color: #9a6200; }
.prio.urgent { background: color-mix(in srgb, var(--urgent) 16%, #fff); color: #b3293b; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ----- Summary mini-table (by product & status) ----------------------- */
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.summary-table th, .summary-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.summary-table th { color: var(--muted); font-weight: 600; }
.summary-table td.n { text-align: center; font-variant-numeric: tabular-nums; }

/* ----- Filters bar ---------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters .form-group { margin-bottom: 0; min-width: 160px; }

/* ----- Modal ---------------------------------------------------------- */
.modal-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; align-items: center; justify-content: center; }
.modal-backdrop.active { display: flex; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop); width: 460px; max-width: calc(100vw - 32px); padding: 22px; }
.modal h3 { margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 16px; }

/* ----- Toast ---------------------------------------------------------- */
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 0.85rem; max-width: 360px; }
.toast.success { background: #14794a; }
.toast.error { background: var(--danger); }

/* ----- Tabs ----------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 14px; border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 0.875rem; cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* =====================================================================
   Login
   ===================================================================== */
.login-page { min-height: 100vh; background: var(--bg-subtle); }
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-shell { display: grid; grid-template-columns: 1fr 1fr; width: 880px; max-width: 100%; min-height: 520px; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.12); }
.login-brand { background: var(--sidebar-bg); color: #fff; display: flex; align-items: center; padding: 40px; }
.login-brand-kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; color: var(--primary); font-weight: 700; margin-bottom: 14px; }
.login-brand-title { font-size: 2rem; font-weight: 700; margin-bottom: 12px; }
.login-brand-lede { color: var(--sidebar-muted); font-size: 0.95rem; line-height: 1.6; max-width: 280px; }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 320px; }
.login-logo { display: block; height: 44px; width: auto; margin-bottom: 18px; }
.login-box h1 { font-size: 1.2rem; margin-bottom: 2px; }
.login-box h2 { font-size: 0.9rem; font-weight: 500; color: var(--muted); margin-bottom: 22px; }
.login-form .form-group, .forgot-password-form .form-group { margin-bottom: 14px; }
.login-btn { width: 100%; padding: 0.6rem; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.login-btn:hover { background: var(--primary-hover); }
.forgot-password-link { text-align: center; margin-top: 12px; font-size: 0.85rem; }
.forgot-password-form { display: none; }
.forgot-password-form.show { display: block; }
.cancel-link { text-align: center; margin-top: 10px; font-size: 0.85rem; }
.divider { display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 0.75rem; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--border); }
.divider::before { margin-right: 12px; } .divider::after { margin-left: 12px; }
.microsoft-login-btn { width: 100%; padding: 0.6rem; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; color: var(--text); font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.microsoft-login-btn:hover { background: var(--bg-subtle); }
.error-message, .success-message { display: none; margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 0.85rem; }
.error-message.show { display: block; background: #fde8eb; color: #b3293b; }
.success-message.show { display: block; background: #e6f4ea; color: #197b46; }
@media (max-width: 760px) { .login-shell { grid-template-columns: 1fr; } .login-brand { display: none; } }

/* =====================================================================
   Dashboard (index.html) — restyle of existing class names
   ===================================================================== */
.sidebar-divider { border-top: 1px solid rgba(255,255,255,0.08); margin: 8px 6px; }
.nav-item--primary { background: var(--primary); color: #fff; font-weight: 600; margin-top: 6px; }
.nav-item--primary:hover { background: var(--primary-hover); }
.nav-item--primary.active::before { display: none; }

#login-section { padding: 40px; }
.view { width: 100%; }
.view > h2 { margin: 2px 0 18px; font-size: 1.4rem; }

/* secondary button alias (legacy markup) */
.btn-secondary { background: #fff; border: 1px solid var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--bg-subtle); }

/* Dashboard two-panel cards */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .dashboard-grid { grid-template-columns: 1fr; } }
.dashboard-panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.dashboard-panel__head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 12px; }
.dashboard-panel__title { font-size: 1.05rem; margin: 0; }
.dashboard-panel__summary { margin-bottom: 12px; }
.dashboard-panel__hint { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.dashboard-panel__cta { }

/* Badges → pills */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; line-height: 1.6; text-transform: capitalize; white-space: nowrap; background: #eef2f6; color: #475569; }
.badge-primary { background: color-mix(in srgb, var(--primary) 18%, #fff); color: #b3522f; }
.badge-success { background: #e6f4ea; color: #197b46; }
/* status */
.badge-open { background: #e7f0ff; color: #2c5fb3; }
.badge-in_progress { background: #fdf2d6; color: #946b00; }
.badge-waiting_customer, .badge-waiting_amberley { background: #fde4ee; color: #b13a72; }
.badge-resolved { background: #e6f4ea; color: #197b46; }
.badge-closed { background: #ececf0; color: #5b5b66; }
/* priority */
.badge-low { background: color-mix(in srgb, var(--low) 16%, #fff); color: #555b63; }
.badge-medium { background: color-mix(in srgb, var(--medium) 16%, #fff); color: #285fa6; }
.badge-high { background: color-mix(in srgb, var(--high) 18%, #fff); color: #9a6200; }
.badge-urgent { background: color-mix(in srgb, var(--urgent) 16%, #fff); color: #b3293b; }

/* Filters */
.queue-filters-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.queue-filter-select, .queue-page-size-select { width: auto; min-width: 150px; }
.queue-filter-checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.queue-filter-checkbox input { width: auto; }
.queue-page-size-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 14px; font-size: 0.85rem; color: var(--muted); }
.queue-page-size-row label { font-weight: 600; }
.ticket-list-container { margin-top: 4px; }

/* Asana-style ticket table */
.ticket-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.ticket-table { width: 100%; border-collapse: collapse; }
.ticket-table__th { text-align: left; background: var(--bg-subtle); border-bottom: 1px solid var(--border); padding: 0; }
.ticket-table__th--actions { padding: 10px 14px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.ticket-table__sort { width: 100%; text-align: left; background: transparent; border: none; padding: 10px 14px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; cursor: pointer; }
.ticket-table__sort:hover { color: var(--text); }
.ticket-table__row { border-bottom: 1px solid var(--border); cursor: pointer; }
.ticket-table__row:last-child { border-bottom: none; }
.ticket-table__row:hover { background: var(--bg-subtle); }
.ticket-table__td { padding: 11px 14px; font-size: 0.875rem; vertical-align: middle; }
.ticket-table__td--mono { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.ticket-table__td--subject { font-weight: 600; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-table__td--clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.ticket-table__td--nowrap { white-space: nowrap; color: var(--muted); font-size: 0.82rem; }
.ticket-table__td--actions { text-align: right; }
.ticket-table__muted { color: var(--muted); }

/* Pagination */
.queue-pagination { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-top: 12px; font-size: 0.85rem; color: var(--muted); }
.queue-pagination--note { justify-content: flex-end; }
.queue-pagination__buttons { display: flex; gap: 6px; align-items: center; }
.queue-pagination__page { font-weight: 600; color: var(--text); }

/* States */
.loading { padding: 28px; text-align: center; color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* Summary mini-table (buildTable output uses inline styles; give cells breathing room) */
.dashboard-panel__summary table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.dashboard-panel__summary th, .dashboard-panel__summary td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dashboard-panel__summary th { color: var(--muted); font-weight: 600; }

/* Content padding for the dashboard pages (main holds the views) */
.content > main { padding: 26px 30px 80px; }
@media (max-width: 860px) { .content > main { padding: 18px 16px 60px; } }
.nav-item .nav-ico { margin-right: 2px; }

/* =====================================================================
   Standalone staff pages (All Tickets, Companies, Users, Config, ...)
   ===================================================================== */
.page-main { padding: 24px 30px 80px; max-width: 1600px; width: 100%; }
@media (max-width: 860px) { .page-main { padding: 16px; } }
.view-header h1 { font-size: 1.4rem; }

.container { width: 100%; }   /* legacy wrapper — now full width inside .page-main */
.error, .error-banner { background: #fde8eb; color: #b3293b; border: 1px solid #f6c9d1; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.875rem; }
.success-banner { background: #e6f4ea; color: #197b46; border: 1px solid #bfe3cc; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.875rem; }

/* Filters card */
.filters-section { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px; }
.filters-section h3 { margin-bottom: 12px; font-size: 0.95rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.filter-actions { display: flex; gap: 10px; margin-top: 14px; }

/* Section card wrapping a table */
.tickets-section, .table-section { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0; overflow: hidden; }
.tickets-header { display: flex; align-items: center; gap: 0.6rem; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.tickets-header h2 { font-size: 1rem; margin: 0; }

/* Generic data tables (All Tickets / Users / Companies / Config) */
.tickets-table, .data-table, .users-table, .companies-table { width: 100%; border-collapse: collapse; }
.tickets-table th, .data-table th, .users-table th, .companies-table th {
  text-align: left; background: var(--bg-subtle); border-bottom: 1px solid var(--border);
  padding: 11px 16px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.tickets-table td, .data-table td, .users-table td, .companies-table td { padding: 12px 16px; font-size: 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tickets-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.tickets-table tbody tr, .data-table tbody tr { cursor: pointer; }
.tickets-table tbody tr:hover, .data-table tbody tr:hover, .users-table tbody tr:hover, .companies-table tbody tr:hover { background: var(--bg-subtle); }
.tickets-table th.sort-asc::after { content: ' ▲'; color: var(--muted); }
.tickets-table th.sort-desc::after { content: ' ▼'; color: var(--muted); }

/* Pagination */
.pagination-controls { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; }
.pagination, .pagination-info { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 16px; color: var(--muted); font-size: 0.85rem; flex-wrap: wrap; }

/* Modals (legacy .modal overlay + .modal-content pattern) */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; align-items: center; justify-content: center; padding: 16px; }
.modal.active { display: flex; }
.modal-content { background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop); width: 500px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.modal-content > form, .modal-body { padding: 18px 20px; }
.close-btn { background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.close-btn:hover { color: var(--text); }
.badge-active, .badge-inactive { display: inline-flex; padding: 2px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-active { background: #e6f4ea; color: #197b46; }
.badge-inactive { background: #ececf0; color: #5b5b66; }
.action-buttons { display: flex; gap: 6px; }

/* Section cards on Companies / Users / Config pages */
.companies-section, .users-section, .config-section, .section-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px; }
.companies-section h2, .users-section h2, .config-section h2 { font-size: 1rem; margin-bottom: 12px; }
.add-company-form, .add-user-form, .inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-company-form .form-group, .add-user-form .form-group, .inline-form .form-group { margin-bottom: 0; min-width: 200px; flex: 1; }

/* Tab panels (company-config) */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Multi-select dropdown (Users → companies picker). These styles used to live
   in styles.css; they must be in app.css now, otherwise the generic
   `input { width:100% }` / `.form-group label { display:block }` rules break the
   checkbox rows. */
.multiselect-dropdown { position: relative; width: 100%; }
.multiselect-trigger {
  width: 100%; padding: 0.55rem 0.65rem; border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 0.875rem; text-align: left; background: #fff; color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
}
.multiselect-trigger:hover { border-color: var(--accent); }
.multiselect-trigger::after { content: '\25BC'; font-size: 0.65rem; color: var(--muted); flex-shrink: 0; }
.multiselect-trigger[aria-expanded="true"]::after { transform: rotate(180deg); }
.multiselect-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.multiselect-label.has-selection { color: var(--text); }
.multiselect-panel {
  display: none; position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px; max-height: 240px;
  overflow-y: auto; background: #fff; border: 1px solid var(--border-strong); border-radius: 8px;
  box-shadow: var(--shadow-pop); z-index: 100;
}
.multiselect-panel.show { display: block; }
.multiselect-panel label {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.5rem 0.75rem; margin: 0; cursor: pointer;
  font-weight: 500; font-size: 0.875rem; color: var(--text); border-bottom: 1px solid var(--border);
  min-height: 2.25rem; width: 100%; box-sizing: border-box;
}
.multiselect-panel label:last-child { border-bottom: none; }
.multiselect-panel label:hover { background: var(--bg-subtle); }
.multiselect-panel input[type="checkbox"] { flex-shrink: 0; width: 1rem; height: 1rem; margin: 0; padding: 0; }
.multiselect-option-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Configuration tables (priorities / statuses / products / ticket types) —
   the page's inline styles were commented out in the app.css migration, so the
   table look + reorder affordances live here. Rows are draggable and also have
   explicit ↑/↓ buttons; a three-line grip signals draggability. */
.config-table { width: 100%; border-collapse: collapse; }
.config-table th { text-align: left; background: var(--bg-subtle); border-bottom: 1px solid var(--border); padding: 11px 16px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; white-space: nowrap; }
.config-table td { padding: 11px 16px; font-size: 0.875rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.config-table tr:last-child td { border-bottom: none; }
.config-table tbody tr { cursor: grab; }
.config-table tbody tr:hover { background: var(--bg-subtle); }
.config-table tbody tr:active { cursor: grabbing; }
.config-table tbody tr.dragging { opacity: .5; background: var(--bg-subtle); }
.config-table tbody tr.drag-over { box-shadow: inset 0 2px 0 var(--primary); }
.config-move { padding: 0.3rem 0.55rem; min-width: 30px; font-weight: 700; line-height: 1; }
.config-move:disabled { opacity: .35; cursor: not-allowed; }
caption.reorder-hint { caption-side: top; text-align: left; color: var(--muted); font-size: 0.8rem; font-weight: 500; padding: 2px 0 10px; }
/* Drag handle: three short horizontal lines */
.config-table .drag-col, .config-table .drag-cell { width: 30px; }
.config-table .drag-cell { text-align: center; padding-left: 10px; padding-right: 0; }
.drag-handle { display: inline-flex; flex-direction: column; justify-content: center; gap: 3px; cursor: grab; padding: 5px 3px; vertical-align: middle; }
.drag-handle span { display: block; width: 15px; height: 2px; border-radius: 2px; background: var(--border-strong); }
.config-table tbody tr:hover .drag-handle span { background: var(--muted); }
.drag-handle:active { cursor: grabbing; }

/* =====================================================================
   Ticket detail page
   ===================================================================== */
.ticket-header, .comment-form, .comments-section, .attachments-section, .update-section, .detail-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.ticket-header { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.ticket-header h1, .ticket-header h2 { font-size: 1.3rem; }
.ticket-meta { font-size: 0.875rem; color: var(--muted); min-width: 240px; }
.ticket-meta-row { margin-bottom: 6px; }
.comment-form h3, .comments-section h3, .attachments-section h3, .update-section h3 { margin-bottom: 12px; font-size: 1rem; }
.comment, .comment-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.comment-internal, .comment.internal { background: #fff8e6; border-color: #f0e0b0; }
.attachment-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 0.875rem; }
.form-group.checkbox { display: flex; align-items: center; gap: 8px; }
.form-group.checkbox input { width: auto; }
.form-group.checkbox label { margin: 0; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 18px; }

/* =====================================================================
   Right-side slide-out drawer (taskdeck-style) + embed mode
   ===================================================================== */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 60; opacity: 0; transition: opacity .18s; pointer-events: none; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 760px; max-width: 96vw; background: #fff; z-index: 61; box-shadow: -10px 0 40px rgba(0,0,0,.16); transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; gap: .6rem; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fff; }
.drawer-header h2 { font-size: 1rem; margin: 0; flex: 1; }
.drawer-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* Embed mode: a page rendered inside the drawer hides the app chrome */
html.embed, html.embed body { background: #fff; height: auto; }
.embed .sidebar, .embed .sidebar-backdrop, .embed .mobile-topbar, .embed .view-header, .embed .footer { display: none !important; }
.embed .app { display: block; min-height: 0; }
.embed .content { display: block; }
.embed .page-main, .embed .content > main { padding: 18px 20px 60px; max-width: none; }
.embed .container, .embed .container-wide { max-width: none; }

/* Existing centered modals now render as right-side drawer panels */
.modal { align-items: stretch; justify-content: flex-end; padding: 0; }
.modal.active { animation: drawer-fade .18s ease; }
.modal-content { width: 480px; max-width: 96vw; height: 100vh; max-height: 100vh; border-radius: 0; overflow: auto; animation: drawer-slide .22s ease; }
@keyframes drawer-slide { from { transform: translateX(60px); } to { transform: translateX(0); } }
@keyframes drawer-fade { from { opacity: 0; } to { opacity: 1; } }

/* Ensure modal-as-drawer panels sit on the right (robust against flex quirks) */
.modal-content { margin-left: auto; margin-right: 0; }

/* Overlay must span the full viewport so flex-end right-aligns the panel
   (overrides the leftover width:460px from the original centered-modal token). */
.modal { width: 100vw; max-width: none; left: 0; right: 0; padding: 0; }

/* =====================================================================
   Customer-facing pages (portal, submit ticket, ticket detail, CSAT
   survey, reset password). Everything is scoped under .customer-page so
   nothing collides with the staff shell (.sidebar / .header / .container
   mean different things there). Same Asana design language, but a simple
   top-bar layout that suits external users with few nav items.
   ===================================================================== */
:root { --spacing-xl: 2rem; }

.customer-page { background: var(--bg-subtle); min-height: 100vh; }

/* Top header bar */
.customer-page .header,
.customer-page .app-header {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid var(--border); padding: 14px 28px;
}
.customer-page .header-logo img,
.customer-page .app-header img { height: 34px; width: auto; display: block; }
.customer-page .header h1 { font-size: 1.15rem; }
.customer-page .header-actions,
.customer-page .user-info { display: flex; align-items: center; gap: 0.9rem; margin-left: auto; }
.customer-page .header-actions__user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.customer-page .header-user-email { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.customer-page .header-user-company { font-size: 0.75rem; color: var(--muted); }

/* Centered content container */
.customer-page main,
.customer-page .container { max-width: 1080px; margin: 0 auto; padding: 24px 28px 64px; width: 100%; }
.customer-page .container-wide { max-width: 1080px; }
@media (max-width: 720px) { .customer-page main, .customer-page .container { padding: 16px; } }

/* Portal nav (horizontal tabs) */
.customer-page .main-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.customer-page .nav-btn {
  padding: 10px 16px; border: none; background: transparent; color: var(--muted); width: auto;
  font-weight: 600; font-size: 0.9rem; cursor: pointer; border-bottom: 2px solid transparent;
  text-decoration: none; border-radius: 0;
}
.customer-page .nav-btn:hover { color: var(--text); text-decoration: none; }
.customer-page .nav-btn.active { color: var(--text); border-bottom-color: var(--primary); }

/* Stat tiles */
.customer-page .portal-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.customer-page .portal-stat { background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.customer-page .portal-stat__value { font-size: 1.7rem; font-weight: 700; color: var(--text); }
.customer-page .portal-stat__label { font-size: 0.76rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; margin-top: 2px; }
.customer-page .customer-portal-section--loading { color: var(--muted); padding: 16px 0; }
.customer-page .loading { padding: 28px; text-align: center; color: var(--muted); }

/* Submit-ticket wizard */
.customer-page .form-container { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.customer-page .step-indicator { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 8px; }
.customer-page .step { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; text-align: center; }
.customer-page .step-circle { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; background: var(--bg-subtle); color: var(--muted); border: 1px solid var(--border-strong); }
.customer-page .step.active .step-circle { background: var(--primary); color: #fff; border-color: var(--primary); }
.customer-page .step-label { font-size: 0.78rem; color: var(--muted); }
.customer-page .step.active .step-label { color: var(--text); font-weight: 600; }
.customer-page .form-step { display: none; }
.customer-page .form-step.active { display: block; }
.customer-page .form-step h2 { margin-bottom: 6px; }

/* KB suggestions */
.customer-page .kb-suggestions { display: none; margin-top: 12px; background: color-mix(in srgb, var(--primary) 8%, #fff); border: 1px solid color-mix(in srgb, var(--primary) 26%, #fff); border-radius: var(--radius); padding: 12px 14px; }
.customer-page .kb-suggestions.show { display: block; }
.customer-page .kb-suggestion-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.customer-page .kb-suggestion-item:last-child { border-bottom: none; }

/* File upload */
.customer-page .file-upload { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.customer-page .file-upload:hover { border-color: var(--accent); color: var(--text); }
.customer-page .file-list { margin-top: 10px; }
.customer-page .file-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 0.85rem; }

/* Button groups (wizard nav) */
.customer-page .button-group { display: flex; align-items: center; gap: 10px; margin-top: 22px; }
.customer-page .button-group-left { display: flex; gap: 10px; }
.customer-page .button-group-right { display: flex; gap: 10px; margin-left: auto; }
.customer-page .hint, .customer-page .subtitle { color: var(--muted); font-size: 0.85rem; }

/* Ticket detail meta */
.customer-page .ticket-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 12px; }
.customer-page .meta-item { margin-bottom: 6px; font-size: 0.875rem; }

/* CSAT survey */
.customer-page .survey-container { max-width: 520px; margin: 44px auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; }
.customer-page .survey-container h1 { font-size: 1.3rem; margin-bottom: 4px; }
.customer-page .rating-section { text-align: center; margin: 20px 0; }
.customer-page .rating-label { font-weight: 600; margin-bottom: 12px; }
.customer-page .rating-buttons { display: flex; gap: 8px; justify-content: center; }
.customer-page .rating-btn { width: 48px; height: 48px; border-radius: 10px; border: 1px solid var(--border-strong); background: #fff; font-size: 1.05rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.customer-page .rating-btn:hover { border-color: var(--accent); color: var(--text); }
.customer-page .rating-btn.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.customer-page .rating-labels { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.75rem; color: var(--muted); }
.customer-page .thank-you { display: none; text-align: center; padding: 20px; }

/* Reset password */
.customer-page .reset-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.customer-page .reset-box { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.customer-page .reset-box h1 { font-size: 1.3rem; margin-bottom: 4px; }
.customer-page .reset-box h2 { font-size: 0.9rem; font-weight: 500; color: var(--muted); margin-bottom: 20px; }
.customer-page .reset-form { text-align: left; }
.customer-page .reset-btn { width: 100%; padding: 0.6rem; border: none; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 600; cursor: pointer; margin-top: 4px; }
.customer-page .reset-btn:hover { background: var(--primary-hover); }
.customer-page .back-to-login { margin-top: 16px; font-size: 0.85rem; }

/* Ticket body & comments: preserve the line breaks the user typed.
   (The per-page embedded styles were migrated out during the reskin, so these
   live here in the shared stylesheet that every ticket view loads.) */
.ticket-description p,
.comment-content { white-space: pre-wrap; overflow-wrap: break-word; }
