/* ------------------------------------------------------------------
   Polish layer — loaded last. Consistent custom form controls, hover and
   focus states, skeleton loading, dialogs and small responsive fixes.
   ------------------------------------------------------------------ */
:root{--control-h:36px;--control-radius:8px;--control-border:var(--border);--control-border-hover:var(--border-strong,#bdc1c6);--shadow-pop:0 12px 32px rgba(24,37,29,.16),0 2px 6px rgba(24,37,29,.08);--skeleton-a:var(--surface-muted,#eef1ef);--skeleton-b:var(--canvas,#f8f9fa);--chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f6368' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")}
:root[data-theme=dark]{--shadow-pop:0 16px 40px rgba(0,0,0,.55),0 2px 8px rgba(0,0,0,.4);--skeleton-a:#2a2d31;--skeleton-b:#202327;--chevron:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")}

/* Pointer + hover affordance on everything clickable */
button,[role=button],[role=tab],[role=checkbox],[role=radio],[role=switch],a[href],summary,label[for],select,input[type=range],input[type=checkbox],input[type=radio],input[type=date]::-webkit-calendar-picker-indicator,.tm-table tbody tr[data-id],.ov-rank-row,.ov-mover-row,.tc-tag,.tn-expand{cursor:pointer}
button:disabled,[aria-disabled=true],input:disabled,select:disabled{cursor:not-allowed}
button:disabled{opacity:.55}
button,input,select,textarea{font-family:inherit}
button{transition:background-color .12s ease,border-color .12s ease,color .12s ease,box-shadow .12s ease}

/* Native-looking controls → one custom look (selects, number, date, text) */
select,.tn-select,.tc-threshold select{appearance:none;-webkit-appearance:none;height:var(--control-h);padding:0 34px 0 12px;border:1px solid var(--control-border);border-radius:var(--control-radius);background:var(--surface) var(--chevron) no-repeat right 10px center/16px;color:var(--text,#202124);font:inherit;font-size:.8125rem;line-height:1}
select:hover,.tn-select:hover{border-color:var(--control-border-hover)}
input[type=text],input[type=search],input[type=email],input[type=password],input[type=number],input[type=date],input[type=url],textarea{accent-color:var(--accent);color-scheme:light}
:root[data-theme=dark] input,:root[data-theme=dark] select,:root[data-theme=dark] textarea{color-scheme:dark}
input[type=number]{appearance:textfield;-moz-appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{appearance:none;margin:0}
input[type=search]::-webkit-search-cancel-button{appearance:none;width:14px;height:14px;cursor:pointer;background:var(--chevron);opacity:0}
input[type=date]::-webkit-calendar-picker-indicator{opacity:.7;border-radius:4px;padding:2px}input[type=date]::-webkit-calendar-picker-indicator:hover{opacity:1;background-color:var(--surface-muted,#eef1ef)}
input[type=checkbox],input[type=radio]{accent-color:var(--accent);width:16px;height:16px}
input:not([type=range]):not([type=checkbox]):not([type=radio]):hover{border-color:var(--control-border-hover)}
input:not([type=range]):not([type=checkbox]):not([type=radio]):focus,select:focus,textarea:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent)}
::placeholder{color:var(--text-muted,#9aa0a6);opacity:1}

/* Range sliders: custom track and thumb in every browser */
input[type=range]{appearance:none;-webkit-appearance:none;width:100%;height:28px;margin:0;background:transparent;accent-color:var(--accent)}
input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:999px;background:linear-gradient(var(--accent),var(--accent)) no-repeat 0/var(--range-fill,0%) 100%,var(--border);background-color:var(--border)}
input[type=range]::-moz-range-track{height:4px;border-radius:999px;background:var(--border)}
input[type=range]::-moz-range-progress{height:4px;border-radius:999px;background:var(--accent)}
input[type=range]::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:18px;height:18px;margin-top:-7px;border-radius:50%;border:2px solid var(--surface);background:var(--accent);box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .12s ease,box-shadow .12s ease}
input[type=range]::-moz-range-thumb{width:14px;height:14px;border-radius:50%;border:2px solid var(--surface);background:var(--accent);box-shadow:0 1px 3px rgba(0,0,0,.3)}
input[type=range]:hover::-webkit-slider-thumb,input[type=range]:focus-visible::-webkit-slider-thumb{transform:scale(1.15);box-shadow:0 0 0 6px color-mix(in srgb,var(--accent) 18%,transparent)}
input[type=range]:focus-visible{outline:none}

/* Unified focus ring */
:where(button,a,[tabindex],select,summary):focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:max(4px,var(--control-radius,6px))}

/* Hover states that were missing */
.tm-button:not(:disabled):hover{filter:brightness(.97)}.tm-button.tm-primary:not(:disabled):hover{filter:brightness(1.07)}
.segmented button:not([aria-pressed=true]):not(:disabled):hover,.tn-display button:not([aria-pressed=true]):hover{background:var(--surface-muted,#eef1ef)}
.tc-chip:not([aria-selected=true]):hover,.entity-hide-empty:hover,.tc-collapse:hover,.tm-scope-toggle:hover,.tc-export:not(:disabled):hover{background:var(--canvas)}
.tm-table tbody tr:hover,.tn-group-head:hover,.tn-member:hover,.ts-steps li:hover,.br-alert:hover,.tc-row:hover{background:var(--canvas)}
.ov-rank-row:hover,.ov-mover-row:hover,.ov-takeaway:hover{background:var(--surface-muted,#f2f4f3)}
.sidebar-links a:hover:not([aria-current=page]){background:var(--surface-muted,#eef1ef)}
.summary-card,.panel.entity-card,.ov-panel,.br-kpi,.br-card{transition:border-color .15s ease,box-shadow .15s ease}
.entity-card:hover,.br-kpi:hover,.summary-card:hover{border-color:var(--control-border-hover)}
.metric-toggle:hover,.filter-trigger:hover,.popover-close:hover,.tm-icon-button:hover,.entity-filter-toggle:hover,.breakdown-button:hover{filter:brightness(.97)}
.tc-tag:hover .tc-tag-name,.tm-name:hover{color:var(--accent)}

/* Skeleton loading */
@keyframes skeleton-shimmer{0%{background-position:-200% 0}100%{background-position:200% 0}}
.skeleton,.chart.chart-pending::before{display:block;border-radius:6px;background:linear-gradient(90deg,var(--skeleton-a) 25%,var(--skeleton-b) 50%,var(--skeleton-a) 75%);background-size:200% 100%;animation:skeleton-shimmer 1.4s ease-in-out infinite}
.skeleton-text{height:12px;margin:6px 0}.skeleton-title{height:18px;width:40%;margin:4px 0 10px}.skeleton-block{height:120px}.skeleton-row{height:44px;margin-bottom:8px}
.skeleton-page{display:flex;flex-direction:column;gap:12px}.skeleton-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.skeleton-kpis .skeleton{height:88px;border-radius:var(--radius)}
.chart.chart-pending{position:relative;min-height:180px}.chart.chart-pending::before{content:'';position:absolute;inset:8px 0;border-radius:8px;opacity:.7}
@media (prefers-reduced-motion:reduce){.skeleton,.chart.chart-pending::before{animation:none}button,.summary-card,.entity-card{transition:none}}

/* Dialogs: consistent size, shadow, close buttons */
#team-dialog,#breakdown-dialog,#entity-dialog,#daily-activity-dialog{box-shadow:var(--shadow-pop);border-radius:14px}
#team-dialog{width:min(560px,calc(100vw - 32px))}#team-dialog.tm-dialog-wide{width:min(720px,calc(100vw - 32px))}#team-dialog.tm-dialog-editor{width:min(1040px,calc(100vw - 32px))}
.tm-dialog-header .tm-icon-button,.popover-close,.breakdown-close,.entity-dialog-close{width:36px;height:36px;border-radius:8px}
.tm-dialog-header .tm-icon-button:hover{background:var(--surface-muted,#eef1ef);color:var(--text,#202124)}
dialog::backdrop{backdrop-filter:blur(2px)}

/* Spacing and overflow guards */
.ops-tabs,.tm-editor-tabs,.tc-chips,.br-chips,.tn-toolbar{scrollbar-width:thin}
.ops-tabs{flex-wrap:nowrap;-webkit-overflow-scrolling:touch}
.tm-table-wrap,.tc-table-wrap,.br-table{max-width:100%}
.panel>:last-child{margin-bottom:0}
code{overflow-wrap:anywhere}
@media(max-width:600px){.tm-page-head{flex-direction:column;align-items:flex-start;gap:10px}.tm-page-head>div+*{align-self:stretch}.br-actions{width:100%}.br-actions .tn-select{flex:1}.tc-actions{width:100%;justify-content:space-between}.drivers{margin-left:-12px;margin-right:-12px;border-radius:0;border-left:0;border-right:0}}

/* Custom date field + calendar */
.ui-date{position:relative}.ui-date-button{display:flex;align-items:center;gap:8px;width:100%;height:var(--control-h);padding:0 10px;border:1px solid var(--control-border);border-radius:var(--control-radius);background:var(--surface);color:var(--text,#202124);font-size:.8125rem;text-align:left}.ui-date-button:hover{border-color:var(--control-border-hover)}.ui-date-button[aria-expanded=true]{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 18%,transparent)}
.ui-date-button .icon{width:16px;height:16px;flex:none;color:var(--muted)}.ui-date-button span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-date-chev{width:14px;height:14px}
.ui-date-pop{position:fixed;z-index:1000;width:296px;padding:10px;border:1px solid var(--border);border-radius:12px;background:var(--surface);box-shadow:var(--shadow-pop)}
.ui-date-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px}.ui-date-head strong{font-size:.875rem;font-weight:500}.ui-date-head button{display:grid;place-items:center;width:32px;height:32px;border:0;border-radius:8px;background:transparent;color:var(--text-secondary,#5f6368)}.ui-date-head button:hover{background:var(--canvas)}.ui-date-head .icon{width:16px;height:16px}
.ui-date-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px}.ui-date-dow{display:grid;place-items:center;height:28px;font-size:.6875rem;font-weight:500;color:var(--muted)}
.ui-date-day{display:grid;place-items:center;height:36px;border:0;border-radius:8px;background:transparent;color:var(--text,#202124);font-size:.8125rem;font-variant-numeric:tabular-nums}.ui-date-day:hover:not(:disabled){background:var(--accent-soft)}.ui-date-day.is-out{color:var(--text-muted,#9aa0a6)}.ui-date-day.is-today{box-shadow:inset 0 0 0 1px var(--accent-border,#aacdb8)}.ui-date-day.is-selected{background:var(--accent);color:var(--on-accent,#fff)}.ui-date-day:disabled{opacity:.35}
.ui-date-foot{display:flex;justify-content:space-between;margin-top:8px;padding-top:8px;border-top:1px solid var(--border-soft,#eef0f2)}.ui-date-foot button{padding:4px 8px;border:0;border-radius:6px;background:transparent;color:var(--accent);font-size:.8125rem;font-weight:500}.ui-date-foot button:hover:not(:disabled){background:var(--accent-soft)}
dialog .ui-date-pop{position:fixed}

/* Chart tooltip: accounts with no rows on the hovered day */
.tooltip-missing{display:flex;flex-direction:column;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--border-soft,#eef0f2);white-space:normal}
.tooltip-missing-label{font-size:.6875rem;font-weight:500;color:var(--tc-drop-fg,#9a4d00)}
.tooltip-accts{display:flex;flex-wrap:wrap;gap:4px}.tooltip-acct{display:inline-flex;align-items:center;gap:5px;padding:2px 7px;border:1px solid var(--border-soft,#e4e7ea);border-radius:999px;background:var(--surface-muted,#f6f7f8);font-size:.6875rem;font-weight:500;color:var(--text-secondary,#5f6368);white-space:nowrap}.tooltip-acct i{width:6px;height:6px;border-radius:50%;background:var(--entity-color)}
