/* TrubeTech operational portal — minimal professional layout */
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: #f4f6f8; color: #1a1a1a; }
.portal-emulation-bar {
  background: #b91c1c;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  font-size: 0.95rem;
  font-weight: 600;
}
.portal-emulation-bar-text {
  color: #fff;
  flex: 0 1 auto;
  min-width: 0;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.portal-emulation-bar-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.portal-emulation-bar-stop {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  padding: 6px 14px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.portal-emulation-bar-stop:hover {
  background: rgba(255, 255, 255, 0.15);
}

.layout { display: flex; min-height: 100vh; flex-direction: column; }
.nav { background: #0f172a; color: #e2e8f0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 20px; }
.nav-brand { font-weight: 600; letter-spacing: 0.02em; display: flex; align-items: center; min-height: 44px; }
.nav-brand-link { display: inline-flex; align-items: center; text-decoration: none; color: inherit; }
.nav-brand-link:hover { opacity: 0.92; }
.nav-brand-text { font-weight: 600; letter-spacing: 0.02em; }
.nav-brand-logo { display: block; width: auto; max-width: min(280px, 50vw); max-height: 75px; height: auto; object-fit: contain; object-position: left center; }
.nav-links { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.nav a { color: #cbd5f5; text-decoration: none; font-size: 0.95rem; }
.nav a:hover { color: #fff; text-decoration: underline; }
.nav-business-form { display: inline-flex; align-items: flex-end; margin: 0; gap: 4px; }
.nav-business-label { color: #cbd5f5; font-size: 0.75rem; display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.nav-business-select { max-width: 11rem; font-size: 0.85rem; padding: 4px 6px; border-radius: 4px; border: 1px solid #334155; background: #1e293b; color: #e2e8f0; }
.main { flex: 1; padding: 24px 20px 40px; max-width: 1100px; width: 100%; margin: 0 auto; }
h1 { font-size: 1.5rem; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 24px 0 12px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15,23,42,0.04); }
.portal-admin-modules summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; margin: 0 0 4px; list-style: none; display: flex; align-items: center; gap: 0.4em; }
.portal-admin-modules summary::-webkit-details-marker { display: none; }
/* Client hub: Submit a ticket, Contact Support, Email signature — matching collapsible cards */
.portal-hub-details {
    margin: 12px 0;
    max-width: 52rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.65rem 1rem 0.85rem;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.portal-hub-details-summary {
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4em;
    user-select: none;
}
.portal-hub-details-summary::-webkit-details-marker { display: none; }
.portal-hub-details-summary::before {
    content: '▸';
    font-size: 0.85rem;
    line-height: 1;
    color: #334155;
    transition: transform 0.15s ease;
}
.portal-hub-details[open] > .portal-hub-details-summary::before {
    transform: rotate(90deg);
}
.portal-hub-details-body {
    margin-top: 0.65rem;
    padding-top: 0.15rem;
    border-top: 1px solid #f1f5f9;
}
.portal-hub-details-body > .w3-border:first-child,
.portal-hub-details-body > div:first-child {
    margin-top: 0.35rem;
}
.portal-hub-accordion {
    max-width: 52rem;
}
.portal-client-retainer-status {
    margin: 0 0 0.75rem;
    padding: 0.75rem 1rem;
    background: #f0f7ff;
    border: 1px solid #cce5ff;
    border-radius: 4px;
    font-size: 0.95rem;
    line-height: 1.45;
}
.portal-client-retainer-status--warn {
    background: #fff8e6;
    border-color: #e6d088;
}
.portal-client-billing-body .portal-client-retainer-status:last-child,
.portal-client-billing-body .portal-client-invoice-statement:last-child {
    margin-bottom: 0;
}
.portal-client-invoice-statement {
    margin: 0;
}
.portal-admin-modules .portal-admin-modules-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
    margin-top: 12px;
    align-items: center;
    line-height: 1.35;
}
.portal-admin-modules .portal-admin-modules-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    padding: 0.55rem 0.95rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    text-decoration: none !important;
    color: #0f172a !important;
    white-space: nowrap;
    font-size: 0.9rem;
    box-shadow: 0 1px 1px rgba(15, 23, 42, 0.04);
}
.portal-admin-modules .portal-admin-modules-links a:hover {
    border-color: #cbd5e1;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    text-decoration: none !important;
    color: #0f172a !important;
}
.portal-admin-modules .portal-admin-modules-links a:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
.portal-admin-modules .portal-admin-modules-links a:visited {
    color: #0f172a !important;
    text-decoration: none !important;
}
.portal-admin-modules .portal-mod-emoji { flex-shrink: 0; line-height: 1; }
/* Client Hub (ticket_guest): same module chips as Dashboard; icon + label in each pill */
.ticket-guest-hub-links-strip.portal-admin-modules {
    max-width: 52rem;
}
.ticket-guest-hub-links-strip-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0 0 4px 0 !important;
    line-height: 1.3;
}
.ticket-guest-hub-links-strip .portal-admin-modules-links a img {
    display: block;
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    object-fit: contain;
}
.business-notes-form label { display: block; margin-bottom: 0.35rem; }
.business-notes-form .business-notes-body {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: calc(100vh - 16rem);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.45;
    padding: 12px 14px;
    resize: vertical;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.stat { font-size: 1.4rem; font-weight: 600; color: #0f172a; }
.stat-label { font-size: 0.85rem; color: #64748b; }
a.card.dash-stat { text-decoration: none; color: inherit; display: block; }
a.card.dash-stat:hover { border-color: #cbd5e1; box-shadow: 0 2px 6px rgba(15,23,42,0.08); }

/* Admin clients: non-active (e.g. archived) listed last */
tr.client-row-inactive td { color: #b91c1c; }
.client-status-pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.client-status-pill-active { background: #dcfce7; color: #166534; }
.client-status-pill-inactive { background: #fee2e2; color: #991b1b; }

/* Admin domains: inactive status rows (sorted last in query) */
tr.domain-row-inactive td,
tr.domain-row-inactive td a {
  color: #b91c1c;
}

/* Admin work entries: invoiced (locked) */
tr.work-entry-invoiced td {
  background: #ecfdf5;
  color: #047857;
}
tr.work-entry-invoiced td .btn {
  border-color: #6ee7b7;
  background: #f0fdf4;
  color: #047857;
}

/* Admin work entries: in progress */
tr.work-entry-in-progress td {
  background: #fef9c3;
}

/* Admin work entries: new (unreviewed) */
tr.work-entry-new td {
  background: #adff2f;
  color: #0f172a;
  font-weight: 600;
}
tr.work-entry-new td .btn {
  border-color: #84cc16;
  background: #ecfccb;
}

table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; }
table.data th { background: #f8fafc; font-weight: 600; color: #334155; }
table.data tr:last-child td { border-bottom: none; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid #cbd5e1; background: #fff; color: #0f172a; text-decoration: none; font-size: 0.9rem; cursor: pointer; }
.btn-primary { background: #2563eb; border-color: #1d4ed8; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #b91c1c; border-color: #991b1b; color: #fff; }
label { display: block; font-weight: 500; margin: 10px 0 4px; font-size: 0.9rem; color: #334155; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; max-width: 520px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 0.95rem;
}
textarea { min-height: 90px; resize: vertical; }
.form-row { margin-bottom: 10px; }
.form-inline-delete { display: inline; margin-left: 6px; vertical-align: middle; }
.flash { padding: 10px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 0.95rem; }
.flash-ok { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.flash-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.small { font-size: 0.85rem; color: #64748b; }
.stack { display: flex; flex-direction: column; gap: 8px; }
