:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6fa;
  font-synthesis: none;
  --surface: #ffffff;
  --text: #172033;
  --border: #d9deea;
  --muted: #657089;
  --primary: #3558d4;
  --primary-dark: #2746ba;
  --success: #0f8a5f;
  --danger: #c73d4d;
  --warning: #b7791f;
  --shadow: 0 12px 30px rgba(28, 39, 64, 0.09);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1120px; background: var(--background, #f4f6fa); color: var(--text, #172033); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
code { background: #eef1f7; padding: 0.1rem 0.35rem; border-radius: 4px; }

.app-header {
  display: flex; justify-content: space-between; align-items: center; gap: 2rem;
  padding: 1.3rem 2rem; background: #10192d; color: white; position: sticky; top: 0; z-index: 50;
}
.app-header h1 { margin: 0; font-size: 1.65rem; }
.app-title-row { display: flex; align-items: baseline; gap: .55rem; }
.app-version { color: #9eabc4; font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.app-header p { margin: .25rem 0 0; color: #bfc9dd; font-size: .92rem; }
.toolbar, .toolbar-group, .inline-actions, .training-toolbar, .training-toolbar > div { display: flex; align-items: center; gap: .65rem; }


.app-menu { position: relative; flex: 0 0 auto; }
.menu-trigger { background: #1d2a45; color: #fff; border-color: #3a4968; min-width: 98px; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; }
.menu-trigger:hover:not(:disabled), .menu-trigger[aria-expanded="true"] { background: #283957; }
.main-menu { position: absolute; right: 0; top: calc(100% + .55rem); z-index: 300; width: 255px; padding: .42rem; border: 1px solid #34425d; border-radius: 10px; background: #172238; box-shadow: 0 18px 45px rgba(0,0,0,.3); }
.main-menu button { display: block; width: 100%; border: 0; background: transparent; color: #eef3ff; text-align: left; border-radius: 7px; padding: .68rem .72rem; white-space: normal; }
.main-menu button:hover:not(:disabled), .main-menu button:focus-visible { background: #263754; outline: none; }
.main-menu button:disabled { color: #748099; }
.menu-separator { height: 1px; margin: .35rem .3rem; background: #34425d; }

.layout { padding: 1.25rem 1.5rem 2rem; display: grid; gap: 1rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.panel-title-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
h2 { margin: 0; font-size: 1.18rem; }
.panel p, .modal-header p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); margin-top: .7rem; }
.csv-paste { width: 100%; min-height: 145px; margin-top: .85rem; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; line-height: 1.45; }
.inline-hint { margin-top: 0; font-size: .82rem; }

button, .file-button {
  border: 1px solid transparent; border-radius: 8px; padding: .58rem .85rem; font-weight: 600; line-height: 1.1;
  transition: .15s ease; white-space: nowrap;
}
button:disabled { opacity: .48; cursor: not-allowed; }
.primary { background: var(--primary); color: white; }
.primary:hover:not(:disabled) { background: var(--primary-dark); }
.secondary, .file-button { background: white; color: #23304c; border-color: #cbd2df; }
.secondary:hover, .file-button:hover { background: #f6f8fc; }
.ghost { background: transparent; color: #4f5a71; border-color: #d8deea; }
.success { background: var(--success); color: white; }
.danger { background: var(--danger); color: white; }
.danger-ghost { background: transparent; color: var(--danger); border-color: #e8b8bf; }
.file-button { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.file-button input { display: none; }
.file-button.compact { padding: .48rem .65rem; font-size: .9rem; }

.toolbar-panel { padding: .75rem 1rem; }
.toolbar { justify-content: space-between; }
.toolbar-group.right { margin-left: auto; }
.summary { color: #47536c; font-weight: 600; margin-right: .5rem; }
.progress-wrap { display: flex; align-items: center; gap: .7rem; margin-top: .7rem; }
.progress-track { height: 8px; flex: 1; background: #e9edf5; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--primary); transition: width .2s; }
.hidden { display: none !important; }

.table-panel { overflow: visible; min-height: 360px; }
.table-wrap { overflow: visible; min-height: 360px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: .88rem; }
th { position: sticky; top: 0; z-index: 2; background: #f7f9fc; text-align: left; color: #526078; font-size: .79rem; text-transform: uppercase; letter-spacing: .035em; padding: .7rem .65rem; border-bottom: 1px solid var(--border); }
td { padding: .55rem .65rem; border-bottom: 1px solid #edf0f5; vertical-align: top; background: white; }
tr:last-child td { border-bottom: none; }
tr.row-error td { background: #fff7f7; }
tr.row-sent td { background: #f3fbf7; }
.empty-state { text-align: center; padding: 3rem; color: var(--muted); }

.table-input, .table-textarea {
  width: 100%; border: 1px solid #ccd3df; border-radius: 6px; background: #fff; color: #182239; padding: .42rem .5rem;
}
.table-textarea { min-width: 0; min-height: 88px; resize: vertical; }
.datetime-cell { width: 138px; white-space: nowrap; }
.datetime-select-row { display: flex; align-items: flex-start; gap: .5rem; min-width: 0; }
.datetime-content { min-width: 0; }
.report-select-checkbox, .select-all-reports input { width: auto; accent-color: var(--primary); }
.report-select-checkbox { margin: .18rem 0 0; flex: 0 0 auto; }
.select-all-reports { display: flex; align-items: center; gap: .42rem; color: inherit; font: inherit; cursor: pointer; }
.select-all-reports input { margin: 0; }
.report-date { font-weight: 750; color: var(--text); }
.report-time { display: flex; align-items: baseline; gap: .28rem; margin-top: .2rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.time-separator { color: #8a95a9; }
.hours-cell { width: 62px; }
.hours-input { width: 56px; min-width: 0; padding-left: .38rem; padding-right: .38rem; font-variant-numeric: tabular-nums; }
.hours-input::-webkit-outer-spin-button, .hours-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hours-input[type=number] { appearance: textfield; -moz-appearance: textfield; }
.remarks-cell { width: 24%; }
.autocomplete-cell { position: relative; min-width: 0; }
.order-cell { width: 373px; max-width: 373px; }
.position-cell { width: 255px; max-width: 255px; }
.autocomplete-control { position: relative; }
.autocomplete-display { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.autocomplete-display strong { flex: 0 0 auto; }
.autocomplete-display small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.autocomplete-input { width: 100%; }
.autocomplete-menu {
  position: absolute; left: 0; top: calc(100% + 3px); z-index: 100;
  width: 100%; max-height: 260px; overflow: auto; border: 1px solid #c9d1df; border-radius: 8px; background: white; box-shadow: 0 14px 35px rgba(22, 33, 57, .18);
}
.order-cell .autocomplete-menu { width: min(560px, calc(100vw - 2rem)); }
.position-cell .autocomplete-menu { width: min(440px, calc(100vw - 2rem)); }
.autocomplete-option small { display: block; white-space: normal; overflow-wrap: anywhere; }
.autocomplete-option { padding: .55rem .65rem; cursor: pointer; border-bottom: 1px solid #eef1f5; }
.autocomplete-option:last-child { border-bottom: none; }
.autocomplete-option:hover, .autocomplete-option.active { background: #eef3ff; }
.autocomplete-option strong { display: block; }
.autocomplete-option small { color: var(--muted); }

.ai-alternatives { min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; gap: .2rem .4rem; align-items: baseline; margin-top: .32rem; line-height: 1.2; }
.ai-alternative-link { border: 0; background: transparent; padding: 0; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; word-break: break-word; color: #3558c8; font: inherit; font-size: .72rem; text-decoration: underline; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.ai-alternative-link:hover, .ai-alternative-link:focus { text-decoration-thickness: 2px; outline: none; }

.status-pill { display: inline-flex; align-items: center; gap: .35rem; border-radius: 999px; padding: .32rem .5rem; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.status-open { background: #eef2f8; color: #55627a; }
.status-ready { background: #e9f7ef; color: #14714f; }
.status-error { background: #fdecee; color: #a42e3b; }
.status-ai { background: #eef0ff; color: #4655b9; }
.status-sent { background: #e4f8ee; color: #0d7651; }
.source-label { color: #64718a; font-size: .76rem; max-width: 100%; overflow-wrap: anywhere; line-height: 1.25; }
.status-source-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: .32rem; min-width: 0; }
.icon-button { border: none; background: transparent; font-size: 1.6rem; line-height: 1; color: #69758a; padding: .2rem .45rem; }
.row-delete { border: none; background: transparent; color: #9b4350; padding: .25rem; font-size: 1.1rem; }


.import-modal-body { padding: 1rem 1.2rem; }
.import-modal-body .csv-paste { margin-top: 0; min-height: 260px; }
.import-modal-body #importInfo { margin-top: .7rem; }
.import-modal-footer { justify-content: space-between; align-items: center; }
.modal-footer-actions { display: flex; align-items: center; justify-content: flex-end; gap: .6rem; }

.modal { width: min(1060px, calc(100vw - 3rem)); border: 1px solid var(--border); border-radius: 14px; padding: 0; box-shadow: 0 24px 70px rgba(21, 31, 55, .28); color: #172033; }
.wide-modal { width: min(1380px, calc(100vw - 3rem)); }
.modal::backdrop { background: rgba(10, 17, 32, .55); backdrop-filter: blur(2px); }
.modal-header { padding: 1rem 1.2rem; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-footer { padding: .9rem 1.2rem; display: flex; justify-content: flex-end; gap: .6rem; border-top: 1px solid var(--border); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.1rem 1.2rem; }
fieldset { border: 1px solid #dbe0e9; border-radius: 10px; padding: .9rem; display: grid; gap: .75rem; align-content: start; }
legend { font-weight: 750; color: #2b3853; padding: 0 .35rem; }
label { display: grid; gap: .3rem; font-weight: 600; color: #34415b; font-size: .9rem; }
label small { font-weight: 400; color: var(--muted); line-height: 1.35; }
input, textarea, select { border: 1px solid #cbd3e0; border-radius: 7px; padding: .55rem .6rem; background: white; color: #182239; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(53, 88, 212, .2); border-color: #6d85dc; }
.advanced-settings { margin: 0 1.2rem 1rem; border: 1px solid #dde2ec; border-radius: 9px; padding: .7rem .85rem; }
.advanced-settings summary { cursor: pointer; font-weight: 700; }
.details-grid { margin-top: .8rem; }

.training-form { padding: 1rem 1.2rem; display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: .75rem; align-items: end; }
.training-form label { position: relative; }
.training-form textarea { resize: vertical; }
.training-toolbar { justify-content: space-between; padding: .75rem 1.2rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.training-list-wrap { max-height: 430px; overflow: auto; }
.training-table td:first-child { min-width: 320px; }

.confirm-modal { width: min(770px, calc(100vw - 3rem)); }
.confirm-modal > p { padding: 1rem 1.2rem; margin: 0; color: #45516a; line-height: 1.5; }

.toast-container { position: fixed; right: 1rem; bottom: 1rem; z-index: 500; display: grid; gap: .6rem; width: 390px; }
.toast { background: #172033; color: white; border-radius: 9px; padding: .75rem .9rem; box-shadow: 0 14px 30px rgba(0,0,0,.22); display: flex; gap: .65rem; align-items: flex-start; }
.toast.error { background: #8e2936; }
.toast.success { background: #0d6f4e; }
.toast .message { flex: 1; line-height: 1.4; }
.toast button { border: 0; background: transparent; color: white; padding: 0; font-size: 1.1rem; }

@media (prefers-color-scheme: dark) {
  :root { color: #e6e9f0; background: #101521; --surface: #171e2c; --border: #30394b; --muted: #a8b2c7; --text: #eef2f8; --shadow: none; }
  body { background: #101521; color: #e6e9f0; }
  .panel, td { background: #171e2c; }
  th { background: #1d2535; color: #b5bfd1; }
  td { border-bottom-color: #283143; }
  input, textarea, select, .table-input, .table-textarea, .secondary, .file-button, .autocomplete-menu { background: #111827; color: #e7ebf3; border-color: #3b465b; }
  code { background: #252e40; }
  tr.row-error td { background: #2a1c22; }
  tr.row-sent td { background: #172820; }
  .modal { background: #171e2c; color: #e6e9f0; }
  label, legend { color: #d9deea; }
  .autocomplete-option { border-bottom-color: #2d3749; }
  .autocomplete-option:hover, .autocomplete-option.active { background: #26334d; }
  .ai-alternative-link { color: #9db0ff; }
  .source-label { color: #a8b2c7; }
}

.compact-action { padding: .34rem .48rem; font-size: .75rem; line-height: 1.15; }

.history-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; padding: 1rem 1.2rem; }
.history-summary > div { border: 1px solid var(--border); border-radius: 10px; padding: .8rem; display: flex; flex-direction: column; gap: .25rem; }
.history-summary span { color: var(--muted); font-size: .78rem; }
.history-summary strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.history-info { padding: 0 1.2rem 1rem; color: var(--muted); line-height: 1.5; }
.history-info p { margin: .4rem 0; }
@media (max-width: 760px) { .history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Compact report-table column geometry (v0.7.10). */
#reportTable th:nth-child(1) { width: 138px; }
#reportTable th:nth-child(2) { width: 62px; }
#reportTable th:nth-child(3) { width: 24%; }
#reportTable th:nth-child(4) { width: 373px; }
#reportTable th:nth-child(5) { width: 255px; }
#reportTable th:nth-child(6) { width: 238px; }
.position-cell .autocomplete-menu { left: auto; right: 0; }

/* Integrated two-line Auftrag field (v0.7.13): description first, customer inside the same field. */
.order-field-shell {
  width: 100%;
  border: 1px solid #ccd3df;
  border-radius: 6px;
  background: #fff;
  padding: .28rem .5rem .34rem;
  min-width: 0;
}
.order-field-shell:focus-within {
  outline: 2px solid rgba(53, 88, 212, .2);
  border-color: #6d85dc;
}
.order-autocomplete-control .autocomplete-input {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: .08rem 0;
  outline: 0;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.autocomplete-selected-customer {
  margin-top: .12rem;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-display strong,
.order-option strong {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.order-display small,
.order-option small {
  margin-top: .18rem;
  font-size: .76rem;
}
.order-option small:empty,
.autocomplete-selected-customer:empty { display: none; }
.order-alternative-link { display: flex; flex-direction: column; align-items: flex-start; gap: .08rem; }
.ai-alt-primary { font-weight: 600; }
.ai-alt-secondary { color: var(--muted); font-size: .68rem; text-decoration: none; }
@media (prefers-color-scheme: dark) {
  .order-field-shell { background: #111827; border-color: #3b465b; }
}

/* Dynamic rule editor (v0.8.0). */
.rules-modal { width: min(1540px, 96vw); max-width: 1540px; }
.system-rule-note { margin: 0 1.2rem 1rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 9px; background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%); font-size: .9rem; }
.rule-toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0 1.2rem 1rem; flex-wrap: wrap; }
.button-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-height: 38px; padding: 0 .85rem; border-radius: 8px; border: 1px solid var(--border); font-weight: 700; }
.rule-layout { display: grid; grid-template-columns: minmax(480px, 1fr) minmax(430px, .9fr); gap: 1rem; padding: 0 1.2rem 1rem; align-items: start; }
.rule-list-panel { border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 62vh; }
.rule-table { table-layout: auto; font-size: .84rem; }
.rule-table th, .rule-table td { padding: .55rem .6rem; vertical-align: top; }
.rule-table th:first-child, .rule-table td:first-child { width: 54px; text-align: right; }
.rule-table th:last-child, .rule-table td:last-child { width: 108px; white-space: nowrap; }
.rule-name { font-weight: 750; }
.rule-condition-summary { color: var(--muted); font-size: .78rem; margin-top: .18rem; max-width: 420px; }
.rule-badge { display: inline-flex; border-radius: 999px; padding: .16rem .45rem; font-size: .72rem; font-weight: 800; background: #e7edf8; color: #36445f; }
.rule-badge.soft { background: #fff3cf; color: #6d5200; }
.rule-badge.off { background: #eceff3; color: #737b88; }
.rule-editor { border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1rem; background: var(--surface); position: sticky; top: .5rem; }
.rule-editor-head, .rule-section-head, .rule-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.rule-editor-head h3, .rule-section-head h4 { margin: 0; }
.rule-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; margin-top: .8rem; }
.rule-form-grid label { margin: 0; }
.checkbox-label { display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem; padding-top: 1.35rem; }
.checkbox-label input { width: auto; }
.rule-section-head { margin-top: 1rem; margin-bottom: .5rem; }
.rule-conditions { display: grid; gap: .5rem; }
.rule-condition-row { display: grid; grid-template-columns: 1.05fr 1.05fr minmax(150px, 1.8fr) auto auto; gap: .45rem; align-items: center; }
.rule-condition-row select, .rule-condition-row input[type="text"] { width: 100%; }
.rule-condition-case { display: flex; align-items: center; gap: .25rem; font-size: .76rem; color: var(--muted); white-space: nowrap; }
.rule-condition-case input { width: auto; }
.rule-test-panel { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .3rem; }
.rule-test-result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .5rem; }
.rule-test-result-grid > div { border: 1px solid var(--border); border-radius: 8px; padding: .55rem; }
.rule-test-result-grid strong { display: block; font-size: 1.05rem; }
.rule-test-pairs { margin-top: .6rem; font-size: .8rem; }
.rule-editor-actions { margin-top: 1rem; justify-content: flex-end; }
@media (max-width: 980px) { .rule-layout { grid-template-columns: 1fr; } .rule-editor { position: static; } }
@media (prefers-color-scheme: dark) {
  .rule-badge { background: #293750; color: #dce7fa; }
  .rule-badge.soft { background: #4a3d17; color: #f6df8e; }
  .rule-badge.off { background: #2b313c; color: #aeb7c7; }
}

/* Customer alias editor (v0.9.0). */
.customer-alias-layout { grid-template-columns: minmax(520px, 1fr) minmax(390px, .75fr); }
.customer-alias-preview { margin-top: 1rem; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); line-height: 1.4; }
.customer-alias-label { color: #4a5b7a; font-size: .72rem; line-height: 1.25; overflow-wrap: anywhere; }
.customer-alias-label.hard { color: #344d86; }
.customer-alias-label.prefer { color: #78611d; }
#customerAliasRows td:nth-child(1) { width: 120px; }
#customerAliasRows td:nth-child(3) { width: 115px; white-space: nowrap; }
#customerAliasRows td:nth-child(4) { width: 108px; white-space: nowrap; }
@media (max-width: 980px) { .customer-alias-layout { grid-template-columns: 1fr; } }
@media (prefers-color-scheme: dark) {
  .customer-alias-label { color: #b6c4df; }
  .customer-alias-label.hard { color: #a9bbff; }
  .customer-alias-label.prefer { color: #e2c96d; }
}

/* Standalone autocomplete fields in rule/customer editors (v0.9.1). */
.editor-autocomplete { position: relative; width: 100%; }
.editor-autocomplete > input { width: 100%; }
.editor-autocomplete-menu { width: min(620px, calc(100vw - 3rem)); text-align: left; }
#rulePositionMenu { width: min(480px, calc(100vw - 3rem)); }
#customerAliasCustomerMenu { width: min(560px, calc(100vw - 3rem)); }

/* Rule/alias editor refinements (v0.9.2). */
.rule-subject-test { margin: 0 1.2rem 1rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.rule-subject-test > label { margin: 0 0 .45rem; font-weight: 750; }
.rule-subject-test-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; align-items: center; }
.rule-subject-test-row input { width: 100%; }
#ruleSubjectTestResult { margin-top: .5rem; line-height: 1.4; }
.rule-test-match-link, .status-editor-link { appearance: none; border: 0; background: none; padding: 0; margin: 0; color: var(--accent); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; white-space: normal; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.rule-test-match-link:hover, .status-editor-link:hover { text-decoration-thickness: 2px; }
.status-rule-links { display: flex; flex-direction: column; gap: .18rem; min-width: 0; }
.status-rule-link { font-size: .72rem; line-height: 1.25; font-weight: 400; overflow-wrap: anywhere; }
.status-alias-link { font-size: .72rem; line-height: 1.25; overflow-wrap: anywhere; }
.rule-form-grid .full-width { grid-column: 1 / -1; }
.customer-alias-form-grid { grid-template-columns: 1fr 1fr; }
@media (max-width: 680px) { .rule-subject-test-row { grid-template-columns: 1fr; } }


/* UI refinements (v0.9.3). */
.rule-table thead .rule-search-row th { top: 35px; padding-top: .35rem; padding-bottom: .45rem; background: #f7f9fc; }
.rule-search-row th:not(:nth-child(2)) { padding-left: 0; padding-right: 0; }
.rule-search-row input { width: 100%; min-width: 180px; padding: .42rem .5rem; font-size: .82rem; font-weight: 500; text-transform: none; letter-spacing: normal; }
.system-rule-note-bottom { margin-top: 0; }
.order-field-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem; align-items: center; }
.order-clear-button { border: 0; background: transparent; color: #7a8497; padding: .1rem .2rem; min-width: 1.35rem; font-size: 1rem; line-height: 1; }
.order-clear-button:hover { color: var(--danger); background: transparent; }
@media (prefers-color-scheme: dark) { .order-clear-button { color: #a8b2c7; } }

/* Selection-based report actions (v0.9.4). */
.status-cell { min-width: 0; overflow-wrap: anywhere; }
@media (prefers-color-scheme: dark) {
  .rule-table thead .rule-search-row th { background: #1d2535; }
}

/* Weekday hours generator (v0.9.7). */
.hours-generator-body { padding: 1rem 1.2rem; }
.hours-generator-grid { margin-top: 0; }
.hours-generator-body .system-rule-note { margin: 1rem 0 0; }

/* Direct performance entry and sticky work toolbar (v1.1.0). */
.toolbar-panel {
  position: sticky;
  top: calc(var(--app-header-height, 82px) + .5rem);
  z-index: 40;
}
#reportTable th {
  top: calc(var(--app-header-height, 82px) + var(--toolbar-panel-height, 58px) + 1rem);
}
.datetime-edit-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  white-space: nowrap;
}
.datetime-edit-button:hover,
.datetime-edit-button:focus-visible {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
}
.datetime-edit-button.report-time {
  display: flex;
  width: max-content;
}
.stop-time-button {
  display: block;
  margin-top: .38rem;
  padding: .18rem .38rem;
  border: 1px solid #cbd2df;
  border-radius: 6px;
  background: #fff;
  color: #34415b;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}
.stop-time-button:hover { background: #f2f5fb; }
.time-editor-modal { width: min(720px, calc(100vw - 3rem)); }
.time-editor-body { padding: 1rem 1.2rem; display: grid; gap: 1rem; }
.time-editor-times { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.time-editor-body #editReportHoursPreview { margin-top: 0; font-weight: 700; }

@media (prefers-color-scheme: dark) {
  .stop-time-button { background: #111827; color: #e7ebf3; border-color: #3b465b; }
  .stop-time-button:hover { background: #1b2536; }
}

/* v1.2.0: toast top-layer, compact delete column and settings options. */
.toast-container[popover] {
  position: fixed;
  inset: auto 1rem 1rem auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  width: min(390px, calc(100vw - 2rem));
}
.toast-container[popover]:popover-open { display: grid; }
.delete-header, .delete-cell { width: 34px; min-width: 34px; max-width: 34px; padding-left: .2rem; padding-right: .2rem; text-align: center; }
.row-delete { cursor: pointer; font-size: 1rem; line-height: 1; padding: .25rem .15rem; }
.row-delete:hover { color: #c6283d; transform: scale(1.08); }
.legend-optional { font-weight: 500; color: var(--muted); font-size: .82rem; }
.fieldset-hint { margin: -.2rem 0 .15rem; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.advanced-options { display: grid; gap: .75rem; }
.checkbox-setting { display: flex; grid-template-columns: none; flex-direction: row; align-items: flex-start; gap: .6rem; font-weight: 500; }
.checkbox-setting input { width: auto; margin-top: .15rem; flex: 0 0 auto; }
#reportTable th:nth-child(7) { width: 34px; }
.row-delete:disabled { opacity: .35; cursor: default; transform: none; }

/* v1.3.0: persistent work list and per-row Magic Wand assignment. */
.remarks-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .3rem;
  align-items: start;
  min-width: 0;
}
.remarks-control .remarks-input { width: 100%; }
.magic-wand-button {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  padding: .28rem .36rem;
  min-width: 2rem;
  font-size: 1rem;
  line-height: 1.15;
  cursor: pointer;
}
.magic-wand-button:hover { background: #f2f5fb; transform: translateY(-1px); }
.magic-wand-button:disabled { opacity: .35; cursor: default; transform: none; }
@media (prefers-color-scheme: dark) {
  .magic-wand-button { background: #111827; border-color: #3b465b; }
  .magic-wand-button:hover { background: #1b2536; }
}


/* v1.4.0: stronger delete action and unified configurable AI assignment. */
.delete-header, .delete-cell { width: 44px; min-width: 44px; max-width: 44px; }
#reportTable th:nth-child(7) { width: 44px; }
.row-delete {
  border: 1px solid #b91c1c;
  border-radius: 7px;
  background: #c62828;
  color: #fff;
  padding: .28rem .36rem;
  min-width: 2rem;
  font-size: 1rem;
  line-height: 1.15;
  cursor: pointer;
}
.row-delete:hover { background: #a91f1f; color: #fff; transform: translateY(-1px); }
.row-delete:disabled { opacity: .35; cursor: default; transform: none; }
@media (prefers-color-scheme: dark) {
  .row-delete { background: #b91c1c; border-color: #ef4444; color: #fff; }
  .row-delete:hover { background: #991b1b; color: #fff; }
}

/* v1.6.0: onboarding, unified backup/restore and developer mode. */
.onboarding-modal { width: min(980px, calc(100vw - 3rem)); }
.onboarding-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 1.2rem; }
.onboarding-option { border: 1px solid var(--border); border-radius: 10px; padding: 1rem; background: var(--surface); }
.onboarding-option h3 { margin: 0 0 .45rem; }
.onboarding-option p { margin: 0 0 1rem; color: var(--muted); }
.backup-info { padding: 1rem 1.2rem; display: grid; gap: .7rem; }
.backup-info p { margin: 0; }
@media (max-width: 720px) {
  .onboarding-options { grid-template-columns: 1fr; }
}

/* v1.7.0: rule suggestions derived from local rapport history. */
.rule-suggestions-modal { width: min(1760px, 98vw); max-width: 1760px; }
.rule-suggestion-table-wrap { margin: 0 1.2rem 1rem; border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 66vh; }
.rule-suggestion-table { min-width: 1380px; }
.rule-suggestion-table th:first-child,
.rule-suggestion-table td:first-child { width: 38px; min-width: 38px; text-align: center; }
.rule-suggestion-table th:nth-child(2) { min-width: 260px; }
.rule-suggestion-table th:nth-child(4) { min-width: 170px; }
.rule-suggestion-table th:nth-child(5) { min-width: 300px; }
.rule-suggestion-table th:nth-child(6) { min-width: 330px; }
.rule-suggestion-table th:last-child,
.rule-suggestion-table td:last-child { width: 104px; }
.rule-suggestion-example { color: var(--muted); font-size: .76rem; line-height: 1.35; margin-bottom: .22rem; overflow-wrap: anywhere; }
.rule-suggestion-kind { margin-top: .25rem; color: var(--muted); font-size: .72rem; }
.rule-suggestion-summary { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.rule-suggestion-check input { width: auto; }


/* v1.8.0: multiple work-time blocks per performance. */
.report-time-blocks { display: grid; gap: .1rem; width: max-content; max-width: 100%; }
.datetime-edit-button.report-time-blocks { display: grid; gap: .1rem; width: max-content; max-width: 100%; }
.datetime-edit-button.report-time-blocks .report-time { display: flex; }
.time-block-editor-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.time-block-list { display: grid; gap: .55rem; }
.time-block-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: .6rem; align-items: end; padding: .65rem; border: 1px solid var(--border); border-radius: 8px; }
.time-block-row label { margin: 0; }
.time-block-remove { min-width: 2.2rem; height: 2.2rem; padding: .2rem .55rem; font-size: 1.1rem; }
.time-block-error { color: var(--danger); font-weight: 700; font-size: .82rem; }
.compact-button { padding: .35rem .6rem; }
@media (max-width: 620px) {
  .time-block-row { grid-template-columns: 1fr 1fr; }
  .time-block-remove { grid-column: 2; justify-self: end; }
}

/* Timer control */
.timer-panel { display: flex; gap: 1rem; align-items: center; padding: .7rem 1rem; position: sticky; top: var(--app-header-height, 90px); z-index: 5; }
.timer-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
#activeTimerLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#activeTimerAssignment { font-size: .8rem; color: var(--text-muted, #64748b); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#activeTimerAssignment[hidden] { display: none; }
#activeTimerCounter { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 5.7rem; }
.timer-toggle { padding: .32rem .5rem; font-size: .78rem; margin-top: .3rem; }

/* Keep destructive bulk actions clearly enabled and readable in both themes. */
#btnClear:not(:disabled), #btnDeleteSelected:not(:disabled) { background: #f4f6fb; color: #172238; border-color: #aeb9cb; }
#btnClear:hover:not(:disabled), #btnDeleteSelected:hover:not(:disabled) { background: #e5ebf5; }

/* AI-assigned values remain marked until a manual or rule-based change. */
.autocomplete-input.ai-filled-field { border: 2px solid #e09a19 !important; box-shadow: 0 0 0 2px rgba(224,154,25,.22); }
.autocomplete-input.ai-filled-field:focus { outline: 2px solid #e09a19; outline-offset: 1px; }

/* Flexible single-screen CSV import */
.import-file-line { margin: .6rem 0; }
.import-config { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin: .75rem 0; }
.import-config summary { cursor: pointer; font-weight: 600; }
.import-config-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: .7rem; margin: .8rem 0; }
.import-config-grid label { display: grid; gap: .35rem; }
.import-config select { width: 100%; }
.import-header-option { display: flex; gap: .45rem; align-items: center; margin-bottom: .7rem; }
.import-mapping-heading { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.import-column-mapping { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: .4rem .8rem; }
.import-column-row { display: flex; gap: .6rem; align-items: center; justify-content: space-between; }
.import-column-row select { max-width: 190px; }

.import-prefix-option { display: grid; gap: .35rem; margin: .7rem 0; max-width: 420px; }

/* In status rule and customer links, emphasize only the type label. */
.status-source-wrap .status-editor-link { font-weight: 400; }
.status-source-wrap .status-editor-link strong { font-weight: 700; }

/* A running timer has no Bis-Zeit until it is stopped. */
.running-time-spinner {
  display: inline-block;
  width: .78rem;
  height: .78rem;
  flex: 0 0 .78rem;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: running-time-spin .75s linear infinite;
  vertical-align: middle;
}
@keyframes running-time-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .running-time-spinner { animation: none; border-style: dotted; }
}

/* Quick report templates (v1.10.5) */
.template-toolbar-controls { display: inline-flex; align-items: stretch; gap: .25rem; }
.template-menu-wrap { position: relative; }
.template-menu-trigger { min-width: 2.4rem; height: 100%; padding: .5rem; }
.template-menu { position: absolute; top: calc(100% + .35rem); left: 0; z-index: 100; width: min(340px, calc(100vw - 2rem)); max-height: min(420px, 70vh); overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: 0 14px 35px rgba(0,0,0,.22); padding: .3rem; }
.template-menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; color: var(--text); white-space: normal; overflow-wrap: anywhere; line-height: 1.4; padding: .6rem .7rem; }
.template-menu button:hover, .template-menu button:focus-visible { background: var(--hover, rgba(80,110,170,.14)); }
.template-menu-divider { height: 1px; background: var(--border); margin: .3rem 0; }
.template-menu-empty { font-size: .85rem; padding: .6rem .7rem; color: var(--muted); }
.template-manager-body { display: grid; grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.2fr); gap: 1.2rem; padding: 1.2rem; max-height: 72vh; overflow: auto; }
.template-manager-list { min-width: 0; }
.template-list-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.template-list-header button { font-size: .8rem; }
.template-list-row { width: 100%; text-align: left; white-space: normal; padding: .65rem; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: inherit; margin-bottom: .4rem; overflow-wrap: anywhere; }
.template-list-row.active { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.template-list-row small { display: block; color: var(--muted); margin-top: .2rem; }
.template-editor { display: grid; gap: .75rem; min-width: 0; }
.template-editor h3 { margin: 0; }
.template-editor label { display: grid; gap: .3rem; min-width: 0; font-size: .87rem; font-weight: 600; }
.template-editor input, .template-editor textarea { width: 100%; }
.template-editor-note { font-size: .8rem; color: var(--muted); margin: 0; }
.template-editor-actions { display: flex; gap: .7rem; justify-content: flex-end; }
@media (max-width: 760px) { .template-manager-body { grid-template-columns: 1fr; max-height: 75vh; } }

/* v1.10.6: duplicate alongside per-row deletion */
.delete-header, .delete-cell { width: 88px; min-width: 88px; max-width: 88px; }
#reportTable th:nth-child(7) { width: 88px; }
.row-actions { display: flex; gap: .3rem; align-items: center; justify-content: center; }
.row-duplicate {
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
  color: var(--text); padding: .28rem .36rem; min-width: 2rem;
  font-size: 1rem; line-height: 1.15; cursor: pointer;
}
.row-duplicate:hover:not(:disabled) { background: var(--hover, #e5ebf5); }
.row-duplicate:disabled { opacity: .35; cursor: default; }

/* Selectable Infomaniak AI models (1.10.8) */
.ai-model-picker { display: flex; gap: .5rem; min-width: 0; }
.ai-model-picker select { flex: 1 1 auto; min-width: 0; width: 100%; }
.ai-model-picker button { flex: 0 0 auto; min-width: 2.75rem; }
