/* Shared login, pagination, account menu, and help dialog components. */

/* Unadorned search fields share the same treatment; composite inputs reset it below. */
input[type="search"]:not(.sr-only) { border-radius:var(--radius-lg); }
input[type="search"]:focus { outline:0; box-shadow:none; border-color:var(--accent); }

/* Search appearance has one owner. Module rules only place/show the control. */
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form) {
  height:var(--search-height); min-height:var(--search-height);
  align-items:center; grid-template-columns:20px minmax(0,1fr); gap:8px;
  padding:0 12px; border:1px solid var(--border); border-radius:var(--radius-lg);
  background:var(--search-background); color:var(--icon-muted); box-shadow:none;
}
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form):focus-within { border-color:var(--accent); outline:0; box-shadow:none; }
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form) input:not([type="hidden"]),
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form) input:not([type="hidden"]):focus {
  min-width:0; width:100%; height:100%; min-height:0!important; margin:0;
  padding:0!important; border:0!important; border-radius:0; outline:none!important;
  box-shadow:none!important; background:transparent!important; color:var(--text);
  font-size:var(--text-sm);
}
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form) input::placeholder { color:var(--faint); }
:is(.workspace-list-search,.compact-search,.files-search,.files-mobile-search,.files-share-search,.files-google-drive-search,.gw-chat-list-search,.gw-chat-message-search,.library-picker > header form) :is(svg,.app-icon) { width:16px; height:16px; flex:0 0 16px; color:var(--icon-muted); }


/* Shared paged list controls */
.pagination { display:flex; align-items:center; justify-content:center; gap:6px; min-height:52px; padding:10px 16px; border-top:1px solid var(--border); background:var(--surface); }
.pagination a { display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:34px; padding:0 10px; border:1px solid var(--border); border-radius:6px; color:var(--text); text-decoration:none; font-size:var(--text-sm); font-weight:650; }
.pagination a:hover { border-color:var(--accent); color:var(--accent); }
.pagination a.active { border-color:var(--primary); background:var(--primary); color:#fff; }
.pagination .disabled { display:inline-flex; align-items:center; justify-content:center; min-width:34px; height:34px; padding:0 10px; border:1px solid var(--border); border-radius:6px; color:var(--faint); font-size:var(--text-sm); font-weight:650; opacity:.65; }
.pagination-summary { margin-left:8px; color:var(--muted); font-size:var(--text-xs); }

.login-page { min-height: 100vh; display: grid; place-items: center; overflow: auto; background: var(--bg); }
.login { width:min(420px,calc(100vw - var(--modal-viewport-inset))); background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:24px; box-shadow:0 18px 50px rgba(15,23,42,.08); }
.login h1 { font-size: var(--text-xl); margin: 0 0 6px; }
.login-brand { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.login-brand img { width:44px; height:44px; border-radius:11px; }
.login-brand h1 { margin:0; }
.login .muted { margin-bottom: 18px; }
.login .err { background: #fff0ef; color: var(--danger); border-radius: 7px; padding: 10px 12px; margin-bottom: 12px; }
.login .msg { margin-bottom:12px; }
.login-note { margin-top: 16px; margin-bottom: 0; }
.login-remember { display:flex; align-items:center; gap:8px; margin:2px 0 14px; color:var(--text); font-size:var(--text-sm); cursor:pointer; }
.login-remember input { width:18px; height:18px; margin:0; accent-color:var(--primary); }
.login-reset { margin-top:16px; padding-top:14px; border-top:1px solid var(--border); }
.login-reset summary { color:var(--muted); font-size:var(--text-sm); font-weight:650; cursor:pointer; }
.login-reset form { display:grid; gap:10px; margin-top:12px; }
.login-reset form label { display:grid; gap:6px; color:var(--muted); font-size:var(--text-xs); font-weight:650; }
.login-reset form input { width:100%; }
.login-reset form button { width:100%; }
.login-reset p { margin:9px 0 0; color:var(--muted); font-size:var(--text-xs); line-height:1.5; }

.icon-btn, .global-actions button, .global-actions a {
  display: inline-grid;
  place-items: center;
  width: var(--icon-button-size);
  height: var(--icon-button-size);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  padding: 0;
}
.icon-btn svg, .global-actions svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.global-actions button.active, .global-actions a.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 38%, var(--border)); }
.notification-menu { position:relative; }
.notification-menu > summary { list-style:none; }
.notification-menu > summary::-webkit-details-marker { display:none; }
.global-actions .notification-menu > summary { display:inline-grid; place-items:center; width:var(--icon-button-size); height:var(--icon-button-size); border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text); cursor:pointer; }
.notification-menu[open] > summary { border-color:color-mix(in srgb,var(--accent) 38%,var(--border)); background:var(--accent-soft); color:var(--accent); }
.notification-link { position: relative; }
.notification-link > .notification-count { position:absolute; top:-6px; right:-6px; width:20px; min-width:20px; height:20px; padding:0; display:inline-flex; align-items:center; justify-content:center; border:2px solid var(--surface); border-radius:50%; background:var(--danger); color:#fff; font-size:var(--text-2xs); line-height:1; font-weight:750; font-variant-numeric:tabular-nums; }
.notification-link > .notification-count.wide { width:auto; padding:0 5px; border-radius:999px; }
.notification-popover { position:absolute; z-index:var(--z-popover); top:calc(100% + 8px); right:0; width:min(380px,calc(100vw - 24px)); overflow:hidden; border:1px solid var(--border); border-radius:8px; background:var(--surface); box-shadow:var(--shadow-popover); }
.notification-popover[popover] { position:fixed; inset:auto; margin:0; }
.notification-popover[popover]:popover-open { display:block; }
.notification-popover > header { min-height:48px; display:flex; align-items:center; justify-content:space-between; padding:0 15px; border-bottom:1px solid var(--border); }
.notification-popover > header strong { font-size:var(--text-control); }
.notification-popover > header span { color:var(--muted); font-size:var(--text-xs); }
.notification-head-actions { display:flex; align-items:center; gap:9px; }
.global-actions .notification-head-actions > button { width:auto; height:28px; min-height:28px; padding:0 9px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--muted); font-size:var(--text-2xs); font-weight:700; }
.global-actions .notification-head-actions > button:hover { border-color:var(--border-strong); background:var(--surface-hover); color:var(--text); }
.notification-list { max-height:min(480px,calc(100vh - 168px)); overflow:auto; overscroll-behavior:contain; }
.global-actions .notification-item { width:100%; height:auto; min-height:70px; display:grid; grid-template-columns:38px minmax(0,1fr) 16px; align-items:center; gap:11px; padding:11px 14px; border:0; border-bottom:1px solid var(--border); border-radius:0; color:var(--text); text-align:left; }
.global-actions .notification-item { justify-items:stretch; }
.global-actions .notification-item:last-child { border-bottom:0; }
.global-actions .notification-item:hover { background:var(--surface-hover); }
.notification-icon { width:36px; height:36px; display:grid; place-items:center; justify-self:start; border-radius:7px; background:var(--icon-muted-bg); color:var(--icon-muted); }
.notification-icon svg { width:17px; height:17px; }
.notification-content { width:100%; min-width:0; display:grid; gap:5px; }
.notification-title-line { width:100%; min-width:0; display:grid; grid-template-columns:42px minmax(0,1fr); align-items:center; gap:7px; }
.notification-title-line strong { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:var(--text-sm); }
.notification-kind { flex:0 0 auto; min-width:42px; padding:2px 5px; border-radius:4px; background:var(--surface-subtle); color:var(--muted); font-size:var(--text-3xs); font-weight:750; text-align:center; }
.notification-content small { min-width:0; display:flex; align-items:center; justify-content:space-between; gap:8px; overflow:hidden; color:var(--muted); font-size:var(--text-2xs); white-space:nowrap; }
.notification-content small time { flex:0 0 auto; color:var(--faint); font-variant-numeric:tabular-nums; }
.notification-item > svg { justify-self:end; color:var(--faint); }
.notification-empty { padding:30px 16px; color:var(--muted); text-align:center; font-size:var(--text-sm); }
.notification-loading { padding:30px 16px; color:var(--muted); text-align:center; font-size:var(--text-sm); }
.notification-footer { min-height:var(--list-head-height); display:flex; align-items:center; padding:7px 10px; border-top:1px solid var(--border); background:var(--surface-subtle); }
.notification-footer[hidden] { display:none; }
.global-actions .notification-footer button { width:100%; height:var(--control-height-sm); display:flex; align-items:center; justify-content:center; gap:7px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text); font-size:var(--text-xs); font-weight:700; }
.notification-footer button:hover { border-color:var(--border-strong); background:var(--surface-hover); }
.notification-footer button:disabled { opacity:.55; cursor:wait; }
.notification-footer small { color:var(--muted); font-size:var(--text-3xs); font-weight:500; }
.user-menu { position: relative; margin-left: 2px; }
.user-menu summary { list-style: none; min-height: var(--control-height); display: flex; align-items: center; gap: 7px; padding: 2px 7px 2px 3px; border-radius: var(--radius); cursor: pointer; }
.user-menu summary:hover, .user-menu[open] summary { background: var(--surface-hover); }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary svg { width: 14px; height: 14px; color: var(--muted); }
.user-avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.user-avatar.has-image { overflow:hidden; background:var(--surface-subtle); }
.user-avatar.has-image img { width:100%; height:100%; display:block; object-fit:cover; }
.user-popover { position: absolute; z-index: var(--z-popover); top: calc(100% + 8px); right: 0; width: 210px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-popover); }
.user-popover-head { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; padding:8px 9px 11px; margin-bottom:5px; border-bottom:1px solid var(--border); }
.user-popover-identity { min-width:0; display:grid; gap:2px; }
.user-popover-identity :is(strong,span) { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.user-popover-head span { color: var(--muted); font-size: var(--text-xs); }
.global-actions .user-popover-head .user-theme-toggle { width:var(--icon-button-size-sm); height:var(--icon-button-size-sm); border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text); }
.global-actions .user-popover-head .user-theme-toggle:hover { border-color:var(--border-strong); background:var(--surface-hover); }
.global-actions .user-popover-head .user-theme-toggle.active { border-color:color-mix(in srgb,var(--accent) 38%,var(--border)); background:var(--accent-soft); color:var(--accent); }
.user-font-scale { display:grid; gap:7px; padding:8px 9px 10px; margin-bottom:5px; border-bottom:1px solid var(--border); }
.user-font-scale > span { color:var(--muted); font-size:var(--text-xs); font-weight:700; }
.user-font-scale > div { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; }
.user-font-scale small { color:var(--faint); font-size:var(--text-3xs); line-height:1.35; }
.global-actions .user-popover > a,
.global-actions .user-popover > button { width:100%; height:var(--control-height); display:flex; align-items:center; justify-content:flex-start; gap:9px; padding:0 9px; border:0; background:transparent; color:var(--text); font-size:var(--text-control); font-weight:600; line-height:1.4; }
.global-actions .user-popover a:hover, .global-actions .user-popover button:hover { background:var(--surface-hover); }
.global-actions .user-popover a svg, .global-actions .user-popover button svg { width: 16px; height: 16px; }
.global-actions .user-popover .user-font-scale button {
  width:auto;
  min-width:0;
  height:var(--control-height-sm);
  min-height:var(--control-height-sm);
  display:inline-flex;
  justify-content:center;
  gap:0;
  padding:0 4px;
  border:1px solid var(--border);
  border-radius:5px;
  background:var(--surface);
  color:var(--muted);
  font-size:var(--text-2xs);
  font-weight:750;
}
.global-actions .user-popover .user-font-scale button:hover { border-color:var(--border-strong); background:var(--surface-hover); color:var(--text); }
.global-actions .user-popover .user-font-scale button.active { border-color:color-mix(in srgb,var(--accent) 38%,var(--border)); background:var(--accent-soft); color:var(--accent); }
.workspace-modal.gw-help-dialog { width:min(920px,calc(100vw - var(--modal-viewport-inset))); height:min(760px,calc(100vh - var(--modal-viewport-block-inset))); }
.gw-help-content { display:grid; gap:22px; }
.gw-help-content h3 { margin:0; font-size:var(--text-lg); }
.gw-help-content p { margin:0; color:var(--muted); line-height:1.7; }
.gw-help-intro { display:grid; gap:8px; }
.gw-help-progress { display:grid; gap:12px; }
.gw-help-progress-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.gw-help-progress-grid article { min-width:0; display:grid; align-content:start; gap:7px; padding:14px 15px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface-subtle); }
.gw-help-progress-grid .status-chip { width:max-content; }
.gw-help-progress-grid h4 { margin:0; font-size:var(--text-sm); }
.gw-help-progress-grid p { font-size:var(--text-xs); line-height:1.6; }
.gw-help-menu-map, .gw-help-accordions { display:grid; gap:12px; }
.gw-help-table-wrap { max-width:100%; overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius); }
.gw-help-table-wrap table { width:100%; min-width:680px; border-collapse:collapse; background:var(--surface); }
.gw-help-table-wrap th, .gw-help-table-wrap td { padding:11px 13px; border-bottom:1px solid var(--border); color:var(--muted); font-size:var(--text-xs); line-height:1.55; text-align:left; vertical-align:top; }
.gw-help-table-wrap thead th { background:var(--surface-subtle); color:var(--text); font-weight:750; }
.gw-help-table-wrap tbody th { width:100px; color:var(--text); white-space:nowrap; }
.gw-help-table-wrap tr:last-child > * { border-bottom:0; }
.gw-help-accordions details { border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); overflow:hidden; }
.gw-help-accordions summary { min-height:52px; display:flex; align-items:center; justify-content:space-between; gap:14px; padding:11px 14px; color:var(--text); cursor:pointer; list-style:none; }
.gw-help-accordions summary::-webkit-details-marker { display:none; }
.gw-help-accordions summary::after { content:"+"; flex:0 0 auto; color:var(--muted); font-size:18px; font-weight:500; }
.gw-help-accordions details[open] summary { border-bottom:1px solid var(--border); background:var(--surface-subtle); }
.gw-help-accordions details[open] summary::after { content:"−"; }
.gw-help-accordions summary > span { min-width:0; display:flex; align-items:center; gap:9px; }
.gw-help-accordions summary svg { width:17px; height:17px; color:var(--accent); }
.gw-help-accordions summary small { margin-left:auto; color:var(--muted); font-size:var(--text-2xs); }
.gw-help-accordions details > div { display:grid; gap:11px; padding:14px 16px 16px; }
.gw-help-accordions ol { display:grid; gap:7px; margin:0; padding-left:20px; color:var(--muted); font-size:var(--text-xs); line-height:1.6; }
.gw-help-accordions details > div p { font-size:var(--text-xs); }
.gw-help-tip { padding:10px 12px; border-radius:var(--radius); background:var(--accent-soft); }
.gw-help-tip strong { margin-right:7px; color:var(--accent); }
.gw-help-faq summary { min-height:48px; }
.gw-help-expense-guide { display:grid; gap:14px; }
.gw-help-section-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.gw-help-section-head > div { min-width:0; display:grid; gap:7px; }
.gw-help-section-head p { font-size:var(--text-xs); }
.gw-help-section-head > .status-chip { flex:0 0 auto; }
.gw-help-expense-rules { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.gw-help-expense-rules span { min-width:0; display:flex; align-items:flex-start; gap:8px; padding:10px 11px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface-subtle); color:var(--muted); font-size:var(--text-2xs); line-height:1.55; }
.gw-help-expense-rules b { flex:0 0 20px; width:20px; height:20px; display:grid; place-items:center; border-radius:50%; background:var(--accent); color:#fff; font-size:10px; }
.gw-help-expense-table table { min-width:820px; }
.gw-help-expense-table td:first-child { width:150px; }
.gw-help-expense-table td:first-child strong, .gw-help-expense-table td:first-child small { display:block; }
.gw-help-expense-table td:first-child small { margin-top:2px; color:var(--faint); font-size:var(--text-3xs); }
.gw-help-cost-chip { min-height:24px; display:inline-flex; align-items:center; padding:3px 9px; border:1px solid transparent; border-radius:999px; font-size:var(--text-2xs); font-weight:750; white-space:nowrap; }
.gw-help-cost-chip.is-sga { border-color:color-mix(in srgb,var(--success) 22%,var(--border)); background:color-mix(in srgb,var(--success) 10%,var(--surface)); color:var(--success-text,#087443); }
.gw-help-cost-chip.is-cogs { border-color:color-mix(in srgb,var(--information,#3478f6) 22%,var(--border)); background:color-mix(in srgb,var(--information,#3478f6) 10%,var(--surface)); color:var(--information-text,#2456a6); }
.gw-help-cost-chip.is-mixed { border-color:color-mix(in srgb,var(--accent) 22%,var(--border)); background:var(--accent-soft); color:var(--accent); }
.gw-help-expense-note { padding:11px 13px; border-left:3px solid var(--warning); border-radius:var(--radius); background:var(--warning-soft); font-size:var(--text-xs); }
.gw-help-expense-note strong { margin-right:7px; color:var(--warning-text); }
.gw-help-cost-chip.is-inventory { border-color:color-mix(in srgb,var(--information,#3478f6) 22%,var(--border)); background:color-mix(in srgb,var(--information,#3478f6) 10%,var(--surface)); color:var(--information-text,#2456a6); }
.gw-help-cost-override { display:block; margin-top:4px; color:var(--faint); font-size:var(--text-3xs); }
.gw-help-notice { display:grid; gap:8px; padding:15px 16px; border-left:3px solid var(--accent); border-radius:var(--radius); background:var(--accent-soft); }
.gw-help-notice h3 { font-size:var(--text-sm); }
.gw-help-notice p { font-size:var(--text-xs); }
.gw-help-meta { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:auto; padding-top:12px; border-top:1px solid var(--border); color:var(--muted); font-size:var(--text-xs); }
.gw-help-meta strong { color:var(--text); font-variant-numeric:tabular-nums; }

.icon-btn { border-color:var(--border-strong); background:var(--surface); box-shadow:none; }

/* Legacy base components */
.panel {
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.panel h2 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-md);
}

.body { padding: 16px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.card:hover { background: var(--surface-hover); }
.card strong { display: block; margin-bottom: 6px; }
.muted, .meta { color: var(--muted); font-size: var(--text-xs); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
label { color: var(--muted); font-size: var(--text-sm); }

input,
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-control);
  line-height: 1.35;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--control-height);
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

button:hover, .btn:hover { background: var(--surface-hover); }

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table-fixed { table-layout: fixed; }
.table-content-aware { table-layout:auto; }
.table-content-aware th,
.table-content-aware td { min-width:0; }

.table th,
.table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.table td {
  font-size: var(--text-sm);
  vertical-align: top;
}

.subsection-title {
  margin: 18px 0 10px;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 700;
}

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  margin: 2px 4px 2px 0;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb,var(--muted) 10%,var(--surface-subtle));
  border-radius: 5px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.msg {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--success-bg);
  color: var(--success-text);
}

.err {
  background: #fff0ef;
  color: var(--danger);
}

:root.dark .err { background: #321b1a; }

/* Stable aliases used by the server-rendered component layer. */
.app-toolbar,
.actions,
.toolbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

.app-sidebar,
.side,
.sidebar { box-shadow: 1px 0 0 rgba(16, 24, 40, .015); }

.app-sidebar-link,
.side-nav-link { min-height: var(--sidebar-row-height); }

.app-panel,
.panel,
.workspace-panel,
.module-disclosure,
.status-strip {
  border-color: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

/* Shared four-up summary used by company, HR, operations, and dashboard pages. */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.status-item {
  position: relative;
  min-width: 0;
  padding: 18px 20px;
}

.status-item + .status-item::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 1px;
  background: var(--border);
  content: "";
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.status-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 9px;
  font-size: var(--text-xl);
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.status-value small {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.status-strip .status-item:nth-child(1) .status-value { color: var(--brand); }
.status-strip .status-item:nth-child(2) .status-value { color: var(--brand-blue); }
.status-strip .status-item:nth-child(3) .status-value { color: var(--warning); }
.status-strip .status-item:nth-child(4) .status-value { color: var(--text); }

.status-note {
  display: block;
  overflow: hidden;
  margin-top: 8px;
  color: var(--faint);
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-card,
.card { border-color: var(--border); border-radius: var(--radius-lg); }

.app-table,
.table { width: 100%; border-collapse: collapse; }

.app-modal-read,
.workspace-modal,
.app-modal-form,
.app-form-dialog { color: var(--text); }

.side-heading {
  padding-top: 2px;
  letter-spacing: 0;
  text-transform: none;
}

.side-nav-link.active { box-shadow: inset 3px 0 0 var(--accent); }

/* Shared controls */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]),
select,
textarea {
  min-height: var(--control-height);
  border-color: var(--border-strong);
  line-height: 1.4;
}

/* Keep native selects visually consistent across modules and browsers. */
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 1px),
    calc(100% - 11px) calc(50% - 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea { min-height: 92px; resize: vertical; }

input::placeholder,
textarea::placeholder { color: var(--faint); opacity: 1; }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]):hover,
select:hover,
textarea:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--border)); }

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="hidden"]):not([type="search"]):focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

button,
.btn {
  min-height: var(--control-height);
  border-color: var(--border-strong);
  font-size: var(--text-sm);
  font-weight: 650;
}

button:disabled,
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: .48; }

/* Shared content patterns */
.module-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.module-title-row > div { min-width: 0; }

.module-title-icon,
.section-title-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background: var(--icon-muted-bg);
  color: var(--icon-muted);
}

.module-title-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
}

.module-title-icon .app-icon { width: 18px; height: 18px; }

.section-title-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.section-title-icon.small { width: 24px; height: 24px; }
.section-title-icon .app-icon { width: 15px; height: 15px; }

.module-header,
.dashboard-header { margin-bottom: var(--section-gap); }

.module-header h1,
.dashboard-title {
  font-size: var(--text-2xl);
  line-height: var(--line-tight);
  font-weight: 760;
}

.module-header p,
.dashboard-date { color: var(--muted); font-size: var(--text-xs); }

.workspace-panel,
.module-disclosure { margin-bottom: var(--section-gap); }

.workspace-panel {
  min-width:0;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:var(--surface);
  overflow:hidden;
}

/*
 * Shared panel content contract.
 * Keep content spacing on this wrapper instead of adding one-off margins to
 * each child. Prototype fixtures should use the same wrapper so their layout
 * matches server-rendered panels.
 */
.workspace-panel-body {
  min-width:0;
  padding:var(--panel-padding-inline);
}

.workspace-panel-body > :first-child { margin-top:0; }
.workspace-panel-body > :last-child { margin-bottom:0; }

.module-grid > .workspace-panel { margin-bottom:0; }

.workspace-head {
  min-height: var(--panel-head-height);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding: 11px var(--panel-padding-inline);
  border-bottom:1px solid var(--border);
}

.workspace-head > div { min-width:0; display:flex; align-items:center; gap:9px; }
.workspace-head h2 { margin:0; font-size:var(--text-lg); line-height:1.35; }
.workspace-head span { color:var(--muted); font-size:var(--text-xs); white-space:nowrap; }
.workspace-head > .workspace-title { align-items: center; gap: 9px; }
.workspace-head .section-title-icon {
  color: var(--icon-muted);
  font-size: 0;
}
.workspace-head .workspace-title > h2 { flex: 0 1 auto; }
.workspace-head .workspace-title > h2 + span { overflow: hidden; text-overflow: ellipsis; }
.panel-header .panel-title {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.panel-header .panel-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.status-chip {
  gap: 4px;
  min-height:24px;
  padding:3px 8px;
  border-radius:5px;
  font-size:var(--text-xs);
  line-height:1.2;
}

.app-table th,
.table th {
  color: var(--muted);
  font-size:var(--text-sm);
  font-weight: 700;
}

.app-panel .app-table th,
.workspace-panel .table th { height: var(--list-head-height); }
.app-panel .app-table td,
.workspace-panel .table td {
  padding-block: var(--table-cell-padding-block);
  padding-inline: var(--table-cell-padding-inline);
}
.app-table tbody tr:hover,
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-hover) 72%, transparent); }

.msg,
.err { border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }

.module-empty,
.table-empty { line-height: var(--line-relaxed); }

.app-search { min-height: var(--control-height); }

.compact-search {
  width:auto;
  min-width:min(220px,100%);
  max-width:100%;
  flex:1 1 240px;
  display:grid;
}
.compact-search svg { width:16px; stroke:currentColor; fill:none; stroke-width:2; }
.compact-search input { width:100%; min-width:0; }

.table-wrap,
.table-scroll { width:100%; min-width:0; max-width:100%; overflow:auto; contain:inline-size; }

.workspace-panel .table { min-width:720px; }
.workspace-panel .table th { padding:8px var(--table-cell-padding-inline); background:var(--surface-subtle); white-space:nowrap; }

.module-filter { display:flex; align-items:center; gap:7px; }
.module-filter input,
.module-filter select { width:auto; min-width:130px; height:38px; padding:7px 9px; }
.module-filter button { height:38px; }
.module-filter svg { width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:2; }

.workspace-filter-bar {
  display:grid;
  grid-template-columns:minmax(180px,1fr) minmax(140px,.42fr) auto;
  align-items:end;
  gap:12px;
  padding:12px var(--panel-padding-inline);
  border-bottom:1px solid var(--border);
  background:var(--surface-subtle);
}

.workspace-filter-bar label { min-width:0; display:grid; gap:6px; }
.workspace-filter-bar label > span:first-child { color:var(--muted); font-size:var(--text-xs); font-weight:650; }
.workspace-filter-bar input,
.workspace-filter-bar select { width:100%; min-width:0; max-width:100%; }
.workspace-filter-bar button { min-width:82px; }
.workspace-filter-actions { display:grid; grid-template-columns:repeat(2,minmax(82px,auto)); align-items:end; gap:8px; }
.workspace-filter-actions > * { width:100%; min-width:82px; }
.workspace-filter-bar .compact-search { width:100%; max-width:none; }
.workspace-filter-bar.is-four { grid-template-columns:minmax(220px,1fr) repeat(2,minmax(140px,.42fr)) auto; }
.workspace-filter-bar.is-search-only { grid-template-columns:minmax(220px,1fr) auto; }
.workspace-filter-bar.is-dense { grid-template-columns:minmax(220px,1.5fr) repeat(5,minmax(0,1fr)) auto; }

@media (max-width: 860px) {
  .app-shell > .side,
  .board-shell > .sidebar { width: min(86vw, 288px); }
  .module-header h1,
  .dashboard-title { font-size: var(--text-xl); }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-item + .status-item::before { display: none; }
  .status-item:nth-child(even) { border-left: 1px solid var(--border); }
  .status-item:nth-child(n+3) { border-top: 1px solid var(--border); }
  .mobile-attendance-close.icon-btn { display:grid; width:28px; height:28px; min-height:28px; padding:0; border-color:rgba(255,255,255,.18); background:rgba(255,255,255,.08); color:#fff; }
  .mobile-attendance-close.icon-btn:hover,
  .mobile-attendance-close.icon-btn:focus-visible { border-color:rgba(255,255,255,.28); background:rgba(255,255,255,.14); color:#fff; }
}

@media (max-width: 520px) {
  .workspace-head { padding-inline: 14px; }
  .status-strip { overflow: visible; box-shadow: none; }
  .status-item { min-height: 84px; padding: 12px 14px; }
  .status-label { overflow: hidden; font-size: var(--text-2xs); text-overflow: ellipsis; white-space: nowrap; }
  .status-value { margin-top: 7px; font-size: var(--text-lg); }
  .status-value small { font-size: var(--text-2xs); }
  .status-note { margin-top: 6px; font-size: var(--text-3xs); }
}

/* P6 visual system consolidation */
.primary,
button.primary,
.btn.primary,
a.primary,
.workspace-create-action,
.dashboard-quick .primary {
  border-color: transparent !important;
  background: var(--brand) !important;
  color: #fff !important;
  box-shadow: var(--shadow-panel);
}

.primary:hover,
button.primary:hover,
.btn.primary:hover,
a.primary:hover,
.workspace-create-action:hover {
  border-color: transparent !important;
  background: var(--brand) !important;
  color: #fff !important;
  filter: brightness(.97);
}

.workspace-create-action .app-icon,
.primary .app-icon,
button.primary .app-icon,
a.primary .app-icon {
  border: 0 !important;
  background: transparent !important;
  color: currentColor !important;
  box-shadow: none !important;
}

/* Module wrappers may color nested labels; primary command content stays white. */
.primary > span,
button.primary > span,
.btn.primary > span,
a.primary > span {
  color: #fff !important;
}

.danger,
.danger-btn,
.btn.danger,
button.danger,
a.danger,
.icon-btn.danger {
  color: var(--danger);
}

.danger-btn,
.btn.danger,
button.danger,
a.danger,
.icon-btn.danger {
  border-color: color-mix(in srgb, var(--danger) 22%, var(--border)) !important;
  background: var(--surface);
}

.danger-btn:hover,
.btn.danger:hover,
button.danger:hover,
a.danger:hover,
.icon-btn.danger:hover {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border)) !important;
  background: var(--danger-soft);
  color: var(--danger);
}

.workspace-record-arrow,
.company-document-list-head .icon-btn {
  color: var(--icon-muted) !important;
}

.status-chip,
.notice-mark,
.workspace-record-row .status-chip,
.workspace-record-row .notice-mark {
  min-height: 25px;
  padding: 4px 8px;
  border-width: 1px;
  border-color: color-mix(in srgb, currentColor 13%, var(--surface)) !important;
  border-radius: 5px;
  box-shadow: none !important;
  font-size: var(--text-xs);
  font-weight: 720;
  line-height: 1.2;
}

.status-chip.info { border-color:color-mix(in srgb,var(--info) 12%,var(--info-soft)) !important; background:var(--info-soft); color:var(--info); }
.status-chip.success { border-color:color-mix(in srgb,var(--success) 12%,var(--success-bg)) !important; background:var(--success-bg); color:var(--success-text); }
.status-chip.warning { border-color:color-mix(in srgb,var(--warning) 12%,var(--warning-soft)) !important; background:var(--warning-soft); color:var(--warning); }
.status-chip.danger { border-color:color-mix(in srgb,var(--danger) 12%,var(--danger-soft)) !important; background:var(--danger-soft); color:var(--danger); }
.status-chip.muted { border-color:var(--border) !important; background:var(--surface-muted); color:var(--muted); }
.status-chip :where(.app-icon, svg),
.notice-mark :where(.app-icon, svg) { color:currentColor !important; stroke:currentColor !important; }

dialog[open] { z-index:var(--z-modal); overscroll-behavior:none; }

.board-category-chip {
  border-color: color-mix(in srgb, currentColor 10%, var(--surface)) !important;
}

.table th,
.table td,
.workspace-panel .table th,
.workspace-panel .table td {
  vertical-align: middle;
}

.table th {
  height: 42px;
  padding-block: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.table td {
  color: var(--text);
  line-height: 1.45;
}

.table-empty,
.module-empty,
.list-empty,
.workspace-standard .list > .empty,
.detail-view-panel > .empty,
.company-document-list > .empty,
.collaboration-list > .empty {
  color: var(--muted) !important;
  font-size: var(--text-sm) !important;
  font-weight: 500 !important;
  line-height: 1.55;
}
dialog[open] { position:fixed; inset:0; margin:auto; }
html.app-modal-scroll-locked {
  overflow:hidden !important;
  overscroll-behavior:none;
}
body.app-modal-scroll-locked {
  position:fixed !important;
  top:calc(-1 * var(--app-modal-scroll-y,0px)) !important;
  right:0;
  left:0;
  width:100%;
  overflow:hidden !important;
  overscroll-behavior:none;
  touch-action:none;
  padding-right:var(--app-modal-scrollbar-width,0px);
}
body.app-modal-scroll-locked :is(dialog[open],.detail-workspace.detail-modal-open > .detail-view-panel),
body.app-modal-scroll-locked.global-mobile-open .global-navigation,
body.app-modal-scroll-locked.sidebar-open :is([data-context-sidebar],#appSidebar) {
  touch-action:auto;
}
body.app-dialog-fallback-open::before {
  content:"";
  position:fixed;
  z-index:var(--z-overlay);
  inset:0;
  background:rgba(18,24,33,.48);
  backdrop-filter:blur(2px);
  touch-action:none;
}
html, body { max-width:100%; overflow-x:clip; }
.app-action-toast { position:fixed; z-index:calc(var(--z-modal) + 5); left:50%; bottom:max(24px,calc(env(safe-area-inset-bottom) + 16px)); max-width:min(420px,calc(100vw - 32px)); padding:11px 16px; border-radius:10px; background:var(--text); color:var(--surface); box-shadow:0 12px 30px rgba(16,24,40,.24); transform:translateX(-50%); font-size:var(--text-sm); font-weight:700; text-align:center; }
.app-action-toast.is-error { background:var(--danger); color:#fff; }
/* Profile media must never escape its avatar frame while async detail/edit views hydrate. */
:is(.employee-avatar,.user-avatar).has-image { overflow:hidden; }
:is(.employee-avatar,.user-avatar).has-image > img { display:block!important; width:100%!important; height:100%!important; max-width:100%!important; max-height:100%!important; object-fit:cover; }
