/* =====================================================================
   Entitlements register — per-product board of each customer's contracted
   entitlement limits and current usage (manual; not sourced from CRM/CPQ/NS).
   EVERY selector is scoped under #entitlementsView, classes are ent-*, and
   vars are --ent-* declared on the view root (never :root) so nothing leaks
   into the shared dashboard. Blended onto the warm light theme tokens in
   styles.css. No shadows, no dark mode (matches the design system).
   ===================================================================== */

#entitlementsView {
    --ent-ground: var(--bg-base);
    --ent-panel: var(--bg-surface);
    --ent-panel-2: var(--bg-hover);
    --ent-ink: var(--text-primary);
    --ent-ink-2: var(--text-secondary);
    --ent-ink-3: var(--text-muted);
    --ent-rule: var(--border);
    --ent-rule-2: var(--border-strong);
    --ent-accent: #1D4E5F;      --ent-accent-bg: #E6EFF1;   /* Legal Desk dark-teal (was #0d9488) */
    --ent-over: #A62A20;        --ent-over-bg: #FAEBE9;
    color: var(--ent-ink);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.45;
}

#entitlementsView * { box-sizing: border-box; }

/* ---------- layout ---------- */
/* Full-bleed: the register is a dense data board, so use the whole viewport width
   (notes were clipping inside a 1340px centred column). */
#entitlementsView .ent-wrap { max-width: none; width: 100%; margin: 0; padding: 8px 24px 40px; }

/* ---------- controls ---------- */
#entitlementsView .ent-controls {
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
    padding: 12px 14px; margin: 16px 0 14px;
    background: var(--ent-panel); border: 1px solid var(--ent-rule); border-radius: 10px;
}
#entitlementsView .ent-prod {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; color: var(--ent-ink-3); text-transform: uppercase; letter-spacing: .06em;
}
#entitlementsView .ent-prod select {
    font-family: var(--font); font-size: 14px; color: var(--ent-ink);
    background: var(--ent-ground); border: 1px solid var(--ent-rule); border-radius: 7px;
    padding: 7px 10px; text-transform: none; letter-spacing: 0; min-width: 200px;
}
#entitlementsView .ent-add-type { margin-left: auto; }
#entitlementsView .ent-archived-toggle {
    display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ent-ink-3);
}

/* ---------- table ---------- */
#entitlementsView .ent-table-wrap { overflow-x: auto; border: 1px solid var(--ent-rule); border-radius: 10px; background: var(--ent-panel); }
#entitlementsView .ent-table { width: 100%; border-collapse: collapse; }
#entitlementsView .ent-table th, #entitlementsView .ent-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--ent-rule); vertical-align: top; text-align: left;
}
#entitlementsView .ent-table thead th {
    font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ent-ink-3);
    border-bottom: 2px solid var(--ent-ink); background: var(--ent-ground);
    position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
#entitlementsView .ent-cust-col { min-width: 240px; }
/* Notes moved out of the value cells into an expandable row, so columns can be
   tight and numeric again (used / limit + a thin usage bar only). */
#entitlementsView .ent-type-col { min-width: 132px; }
#entitlementsView .ent-actions-col { width: 150px; }
#entitlementsView .ent-table td { vertical-align: middle; }
#entitlementsView .ent-table thead th { vertical-align: bottom; }
/* Zebra striping, applied by JS per-customer index so the interleaved notes row
   keeps its parent's shade instead of flipping. */
#entitlementsView .ent-row.ent-z1 > td,
#entitlementsView .ent-notes-row.ent-z1 > td { background: color-mix(in srgb, var(--ent-panel-2) 45%, transparent); }
#entitlementsView .ent-row:hover > td { background: var(--ent-panel-2); }
#entitlementsView .ent-row.editing > td { background: var(--ent-accent-bg); }

/* ---------- type header ---------- */
#entitlementsView .ent-type-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#entitlementsView .ent-type-label { font-weight: 600; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--ent-ink); }
#entitlementsView .ent-type-unit { font-size: 10px; color: var(--ent-ink-3); margin-top: 2px; text-transform: none; letter-spacing: 0; }
#entitlementsView .ent-type-menu { display: flex; gap: 2px; opacity: .55; }
#entitlementsView .ent-type-col:hover .ent-type-menu { opacity: 1; }
#entitlementsView .ent-ic {
    font-size: 12px; line-height: 1; color: var(--ent-ink-2); background: none;
    border: 1px solid var(--ent-rule); border-radius: 6px; padding: 3px 5px; cursor: pointer;
}
#entitlementsView .ent-ic:hover { background: var(--ent-panel-2); color: var(--ent-ink); }
#entitlementsView .ent-arch-tag {
    font-size: 9px; text-transform: uppercase; letter-spacing: .05em; color: var(--ent-ink-3);
    background: var(--ent-panel-2); border: 1px solid var(--ent-rule); border-radius: 5px; padding: 1px 5px; margin-left: 4px;
}
#entitlementsView .ent-type-archived { opacity: .6; }

/* ---------- customer cell ---------- */
#entitlementsView .ent-cust-line { display: flex; align-items: center; gap: 7px; }
#entitlementsView .ent-cust-name { font-weight: 600; }
#entitlementsView .ent-cust-meta { font-size: 11px; color: var(--ent-ink-3); margin-top: 3px; padding-left: 25px; }
/* chevron toggle for the notes panel (only rendered when the customer has notes) */
#entitlementsView .ent-chev {
    flex: none; width: 18px; height: 18px; line-height: 1; padding: 0; cursor: pointer;
    background: none; border: 1px solid var(--ent-rule); border-radius: 5px;
    color: var(--ent-ink-2); font-size: 12px; transition: transform .12s ease;
}
#entitlementsView .ent-chev:hover { background: var(--ent-panel-2); color: var(--ent-ink); }
#entitlementsView .ent-chev.open { transform: rotate(180deg); color: var(--ent-accent); border-color: var(--ent-accent); }
#entitlementsView .ent-chev-spacer { flex: none; width: 18px; }

/* ---------- value cell: read-first display ---------- */
#entitlementsView .ent-val { font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#entitlementsView .ent-val-used { font-weight: 600; color: var(--ent-ink); }
#entitlementsView .ent-val-sep { color: var(--ent-ink-3); margin: 0 3px; }
#entitlementsView .ent-val-lim { color: var(--ent-ink-2); }
#entitlementsView .ent-val-dash { color: var(--ent-ink-3); }
#entitlementsView .ent-val-see { font-size: 11px; color: var(--ent-ink-3); font-style: italic; }
#entitlementsView .ent-over { color: var(--ent-over); }
#entitlementsView .ent-pct { font-size: 10px; color: var(--ent-ink-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
#entitlementsView .ent-pill-unl {
    display: inline-block; font-size: 11px; font-weight: 600; color: var(--ent-accent);
    background: var(--ent-accent-bg); border-radius: 20px; padding: 2px 10px;
}

/* ---------- usage bar ---------- */
#entitlementsView .ent-bar {
    height: 4px; margin-top: 5px; max-width: 110px; border-radius: 3px; background: var(--ent-panel-2); overflow: hidden;
}
#entitlementsView .ent-bar span { display: block; height: 100%; background: var(--ent-accent); border-radius: 3px; }
#entitlementsView .ent-bar-over span { background: var(--ent-over); }

/* ---------- value cell: edit mode ---------- */
#entitlementsView .ent-edit-inputs { display: flex; align-items: center; gap: 4px; }
#entitlementsView .ent-in {
    font-family: var(--font-mono); font-size: 12px; color: var(--ent-ink);
    background: var(--ent-ground); border: 1px solid var(--ent-rule); border-radius: 6px; padding: 5px 7px;
}
#entitlementsView .ent-used, #entitlementsView .ent-limit { width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
/* Show the full value — native number-spinner arrows otherwise clip 6+ digit limits (e.g. 100000 showed as "10000"). */
#entitlementsView .ent-in[type="number"] { -moz-appearance: textfield; appearance: textfield; }
#entitlementsView .ent-in[type="number"]::-webkit-outer-spin-button,
#entitlementsView .ent-in[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#entitlementsView .ent-sep { color: var(--ent-ink-3); }
#entitlementsView .ent-in:focus { outline: none; border-color: var(--ent-accent); box-shadow: 0 0 0 2px var(--ent-accent-bg); }

/* ---------- row actions ---------- */
#entitlementsView .ent-actions { white-space: nowrap; text-align: right; }
#entitlementsView .ent-edit-btn { font-size: 12px; padding: 5px 10px; }
#entitlementsView .ent-actions .btn { padding: 5px 12px; font-size: 12px; margin-left: 6px; }
#entitlementsView .ent-actions .btn:first-child { margin-left: 0; }

/* ---------- expandable notes row ---------- */
#entitlementsView .ent-notes-cell { padding: 0 !important; border-bottom: 1px solid var(--ent-rule); }
#entitlementsView .ent-notes-panel {
    padding: 4px 16px 14px 41px;
    display: grid; grid-template-columns: 1fr; gap: 8px;
}
#entitlementsView .ent-note-read {
    display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: baseline;
    padding: 7px 0; border-top: 1px dashed var(--ent-rule);
}
#entitlementsView .ent-notes-panel .ent-note-read:first-child { border-top: none; }
#entitlementsView .ent-note-label { font-weight: 600; font-size: 12px; color: var(--ent-ink-2); }
#entitlementsView .ent-note-text { font-size: 12.5px; color: var(--ent-ink); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
#entitlementsView .ent-note-empty { font-size: 12px; color: var(--ent-ink-3); font-style: italic; }
/* edit-mode note fields inside the panel */
#entitlementsView .ent-note-edit { display: grid; grid-template-columns: 180px 1fr; gap: 14px; align-items: start; padding: 5px 0; }
#entitlementsView .ent-note-edit label { font-weight: 600; font-size: 12px; color: var(--ent-ink-2); padding-top: 7px; }
#entitlementsView .ent-note {
    width: 100%; font-family: var(--font); font-size: 12px;
    min-height: 60px; max-height: 320px; resize: vertical; line-height: 1.5;
    white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--ent-ground); border: 1px solid var(--ent-rule); border-radius: 6px; padding: 7px 9px;
    /* Auto-grow to fit the note where the browser supports it (falls back to min-height + scroll). */
    field-sizing: content;
}

/* ---------- empty / error / hint ---------- */
#entitlementsView .ent-empty {
    padding: 48px 20px; text-align: center; color: var(--ent-ink-3); line-height: 1.6;
    background: var(--ent-panel); border: 1px solid var(--ent-rule); border-radius: 10px;
}
#entitlementsView .ent-error { color: var(--ent-over); }
#entitlementsView .ent-hint { font-size: 11px; color: var(--ent-ink-3); margin: 12px 2px 0; line-height: 1.5; }
