:root {
  --red: #9f2d27;
  --red-dark: #7f211d;
  --ink: #1f252b;
  --muted: #667078;
  --line: #d7d9da;
  --paper: #ffffff;
  --canvas: #f3f1ed;
  --success: #18724d;
  --warning: #a56008;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(24, 28, 32, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 16px;
}

.time-layout { display: grid; grid-template-columns: minmax(280px, 0.85fr) minmax(340px, 1.15fr); gap: 1rem; align-items: start; }
.time-cards { display: grid; gap: .75rem; }
.time-card { border: 1px solid var(--line, #ddd); border-radius: 12px; padding: .9rem; display: grid; gap: .45rem; }
.time-card > div:first-child { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.time-card p { margin: 0; }
.calculated-hours { padding: .85rem 1rem; border-radius: 10px; background: #f5eee9; font-weight: 700; color: #79221e; }
.report-filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: .8rem; align-items: end; }
.day-total td { font-weight: 700; background: #f7f4f2; }
.inactive-row { opacity: .62; background: #f4f4f4; }
.narrow-panel { max-width: 620px; }
.delete-user { min-width: 90px; }
.delete-user summary { color: #9f2d27; cursor: pointer; }
.delete-user form { margin-top: .6rem; min-width: 240px; }
@media (max-width: 800px) {
  .time-layout, .report-filters { grid-template-columns: 1fr; }
  .time-card .button-row { align-items: center; }
  .app-header nav { overflow-x: auto; max-width: 100%; }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--red-dark); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-size: clamp(1.75rem, 4vw, 2.55rem); line-height: 1.08; letter-spacing: -.035em; }
h2 { margin-bottom: 1rem; font-size: 1.25rem; }
h3 { font-size: 1rem; }
small { display: block; color: var(--muted); margin-top: .25rem; }

.app-header {
  position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 2rem; min-height: 68px; padding: .75rem clamp(1rem, 4vw, 3rem); color: white; background: #23272b;
  box-shadow: 0 2px 12px rgba(0,0,0,.15);
}
.brand { color: inherit; font-size: 1.35rem; font-weight: 900; font-style: italic; letter-spacing: -.04em; text-decoration: none; white-space: nowrap; }
.brand span { color: #cf4a42; font-size: .7em; }
.brand-image { display: inline-flex; align-items: center; line-height: 0; }
.brand-logo { display: block; width: auto; object-fit: contain; }
.brand-logo-header { height: 50px; }
.brand-logo-login { width: min(290px, 100%); height: auto; margin-bottom: 1.6rem; }
.app-header nav { display: flex; gap: .35rem; }
.app-header nav a { padding: .65rem .8rem; color: #eef0f1; border-radius: 8px; text-decoration: none; font-weight: 650; }
.app-header nav a:hover { background: rgba(255,255,255,.08); }
.logout-form { justify-self: end; }
.app-header .text-button { color: #e8eaeb; }

.app-main { width: min(1480px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.page-heading { margin: .5rem 0 1.5rem; }
.page-heading p { color: var(--muted); }
.page-heading.split { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; }
.eyebrow { margin-bottom: .4rem; color: var(--red) !important; font-size: .76rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.heading-meta { display: flex; align-items: center; gap: .8rem; margin-bottom: .7rem; color: var(--muted); }
.muted, .hint { color: var(--muted); }
.hint { margin: .75rem 0 0; font-size: .9rem; }

.panel { background: var(--paper); border: 1px solid #e1e1de; border-radius: var(--radius); padding: clamp(1rem, 2.2vw, 1.5rem); box-shadow: var(--shadow); }
.panel.compact { margin-bottom: 1.25rem; padding: 1rem 1.25rem; }
.panel summary { cursor: pointer; font-weight: 800; }
.panel summary + * { margin-top: 1.25rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.section-heading > span { min-width: 2rem; padding: .25rem .55rem; border-radius: 99px; color: var(--muted); background: #eeefed; text-align: center; font-size: .85rem; font-weight: 800; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: .45rem; padding: .67rem 1rem; border: 1px solid transparent; border-radius: 9px; background: #eceeed; color: var(--ink); cursor: pointer; font-weight: 780; text-decoration: none; }
.button:hover { filter: brightness(.97); }
.button.primary { background: var(--red); color: #fff; }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { border-color: #bfc4c5; background: white; }
.button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.button.small { min-height: 34px; padding: .35rem .65rem; font-size: .86rem; }
.button.large { min-height: 52px; padding-inline: 1.35rem; }
.button.wide { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-row { display: flex; flex-wrap: wrap; gap: .65rem; }
.text-button { padding: 0; border: 0; background: none; color: var(--red-dark); cursor: pointer; font-weight: 700; }
.text-button.danger, .danger { color: #a82620; }
.icon-button { display: inline-flex; min-height: 34px; align-items: center; padding: .3rem .55rem; border: 1px solid #d7d9da; border-radius: 7px; background: white; color: #3c444a; cursor: pointer; font-size: .8rem; text-decoration: none; }

.notice { margin-bottom: 1rem; padding: .9rem 1rem; border-radius: 9px; border-left: 4px solid #9aa1a5; background: white; box-shadow: var(--shadow); }
.notice.success { border-left-color: var(--success); background: #f2fbf6; }
.notice.error { border-left-color: #bc2d28; background: #fff5f4; }

label { display: grid; gap: .4rem; color: #333a3f; font-size: .9rem; font-weight: 740; }
input, select, textarea { width: 100%; min-height: 46px; padding: .68rem .75rem; border: 1px solid #bfc4c5; border-radius: 8px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--red); outline: 3px solid rgba(159,45,39,.14); }
input[type="checkbox"] { width: 1.2rem; min-height: 1.2rem; accent-color: var(--red); }
.stack { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; max-width: 900px; }
.header-form { max-width: none; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: .6rem; margin-top: .25rem; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.or-field span { color: var(--muted); font-size: .78rem; }
.inline-form { display: flex; align-items: end; gap: .8rem; flex-wrap: wrap; }
.field-label { display: block; margin-bottom: .5rem; color: #333a3f; font-size: .9rem; font-weight: 740; }

.login-page { display: grid; place-items: center; padding: 1.25rem; background: linear-gradient(145deg, #24282c 0 36%, #f3f1ed 36% 100%); }
.login-page .app-main { display: grid; place-items: center; padding: 0; }
.login-card { width: min(440px, 100%); padding: clamp(1.5rem, 5vw, 2.4rem); border-top: 6px solid var(--red); border-radius: 14px; background: white; box-shadow: 0 22px 65px rgba(0,0,0,.22); }
.login-card .brand { color: var(--ink); font-size: 1.7rem; }

.mobile-home { max-width: 860px; margin: 0 auto; }
.primary-action { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; padding: 1.3rem 1.5rem; border-radius: 12px; background: var(--red); color: white; box-shadow: 0 10px 24px rgba(127,33,29,.2); font-size: 1.15rem; font-weight: 850; text-decoration: none; }
.primary-action span { display: grid; width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 50%; background: rgba(255,255,255,.15); font-size: 1.5rem; }
.card-list { display: grid; gap: .7rem; }
.note-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .45rem 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.note-card > span:first-child { grid-row: 1 / 3; }
.note-card > span:not(:first-child) { color: var(--muted); }
.note-card small { grid-column: 3; grid-row: 1 / 3; }

.status-tabs { display: flex; gap: .65rem; margin: 0 0 1.25rem; overflow-x: auto; padding-bottom: .15rem; }
.tab { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; padding: .6rem .85rem; border: 1px solid #d0d3d3; border-radius: 9px; background: white; color: #4b545a; text-decoration: none; white-space: nowrap; }
.tab.active { border-color: var(--ink); background: var(--ink); color: white; }
.status { display: inline-flex; padding: .28rem .55rem; border-radius: 99px; font-size: .7rem; font-weight: 900; letter-spacing: .055em; white-space: nowrap; }
.status-draft { background: #e7eaeb; color: #465057; }
.status-office { background: #fff0d9; color: #8b4f00; }
.status-done { background: #dff4e8; color: #126640; }
.status-cancelled { background: #f7dedd; color: #8e201c; }
.status-archived { background: #e2e7ea; color: #394850; }

.table-actions { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; color: var(--muted); font-size: .87rem; }
.table-wrap { width: 100%; overflow-x: auto; }
.office-mobile-cards { display: none; }
.office-note-card { display: grid; gap: .9rem; padding: 1rem; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: var(--shadow); }
.office-note-card-top { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.office-note-card-top time { color: var(--muted); font-weight: 750; }
.office-note-card > div:nth-child(2) { display: grid; gap: .25rem; }
.office-note-card > div:nth-child(2) strong { font-size: 1.08rem; }
.office-note-card > div:nth-child(2) span { color: var(--muted); }
.office-note-card dl { display: grid; grid-template-columns: auto 1fr; gap: .25rem .7rem; margin: 0; font-size: .86rem; }
.office-note-card dt { color: var(--muted); }
.office-note-card dd { margin: 0; }
.office-card-actions { display: grid; gap: .55rem; }
.office-card-actions form { margin: 0; }
.merge-choice { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .55rem; padding: .65rem .75rem; border-radius: 8px; background: #f3f4f2; }
.merge-choice input { flex: 0 0 auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .8rem .7rem; border-bottom: 1px solid #e1e3e2; vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:hover { background: #fafafa; }
td.actions { text-align: right; }
td.actions form { display: inline-block; margin-left: .35rem; }

.workspace { display: grid; grid-template-columns: minmax(320px, .82fr) minmax(520px, 1.6fr); gap: 1.25rem; align-items: start; }
.position-entry { position: sticky; top: 86px; }
.recent-articles { margin-bottom: 1rem; }
.quick-picks { display: flex; flex-wrap: wrap; gap: .45rem; }
.quick-pick { padding: .55rem .65rem; border: 1px solid #c9cccd; border-radius: 8px; background: #f7f7f5; color: #30373c; cursor: pointer; text-align: left; font-size: .85rem; font-weight: 700; }
.search-block { position: relative; }
.search-results { position: absolute; z-index: 15; top: calc(100% + .3rem); width: 100%; max-height: 310px; overflow: auto; padding: .35rem; border: 1px solid #bbc0c2; border-radius: 9px; background: white; box-shadow: 0 12px 30px rgba(0,0,0,.16); }
.search-result { display: grid; width: 100%; gap: .15rem; padding: .7rem; border: 0; border-bottom: 1px solid #eceeed; background: white; color: var(--ink); cursor: pointer; text-align: left; }
.search-result:hover { background: #f6f3ef; }
.search-result small { margin: 0; }
.selected-article { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem; border-radius: 8px; background: #f0f5f2; color: #2c543f; font-size: .85rem; }
.selected-article button { border: 0; background: none; color: inherit; cursor: pointer; text-decoration: underline; }
.optional-label { display: inline; color: var(--muted); font-size: .76rem; font-weight: 600; }
.manual-line-hint { margin-top: -.45rem; }
.all-articles { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.all-articles h3 { margin: 1rem 0 .35rem; color: var(--muted); }
.article-list-item { display: flex; width: 100%; justify-content: space-between; gap: .75rem; padding: .55rem .2rem; border: 0; border-bottom: 1px solid #eceeed; background: white; cursor: pointer; text-align: left; }
.article-list-item small { white-space: nowrap; }

.day-group { margin-bottom: 1.35rem; }
.day-group > h3 { margin: 0; padding: .55rem .65rem; border-bottom: 2px solid var(--ink); background: #f3f4f2; font-size: .9rem; }
.line-item { display: grid; grid-template-columns: 90px 1fr auto; gap: 1rem; padding: .9rem .65rem; border-bottom: 1px solid #e2e4e3; }
.line-item.text-only { grid-template-columns: 1fr auto; }
.line-quantity { display: flex; align-items: baseline; gap: .35rem; white-space: nowrap; }
.line-quantity strong { font-size: 1.08rem; }
.line-quantity span { color: var(--muted); font-size: .85rem; }
.line-description > strong { display: block; }
.line-actions { display: flex; align-items: flex-start; justify-content: flex-end; gap: .3rem; flex-wrap: wrap; max-width: 245px; }
.line-actions form { display: flex; gap: .2rem; }
.inline-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photo-strip { display: flex; gap: .35rem; margin-top: .6rem; }
.photo-strip img { width: 58px; height: 46px; border-radius: 6px; object-fit: cover; }

.attachments-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-top: 1.25rem; }
.photo-upload-options { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.upload-choice { margin: 0; }
.upload-choice label { cursor: pointer; }
.photo-upload-hint { margin: .55rem 0 1rem; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .8rem; }
.photo-gallery figure { margin: 0; }
.photo-gallery img { width: 100%; aspect-ratio: 4 / 3; border-radius: 8px; object-fit: cover; }
.saved-signature { padding: .8rem; border: 1px solid var(--line); border-radius: 9px; }
.saved-signature + .saved-signature { margin-top: .7rem; }
.saved-signature img { width: 100%; max-height: 150px; object-fit: contain; background: white; }
.signature-form { display: grid; gap: .8rem; margin-top: 1rem; }
.signature-form canvas { width: 100%; height: 180px; border: 2px dashed #9aa0a2; border-radius: 8px; background: white; touch-action: none; }

.completion-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.25rem 0 3rem; padding: 1.1rem 1.25rem; border-radius: 12px; background: #252a2e; color: white; box-shadow: var(--shadow); }
.completion-bar > div { display: grid; gap: .2rem; }
.completion-bar span { color: #cfd4d6; font-size: .9rem; }
.cancelled-notice { display: grid; gap: .25rem; border-left-color: #a82620; background: #fff0ef; }
.cancelled-notice span { color: #6d4542; }
.archived-notice { display: grid; gap: .25rem; border-left-color: #536771; background: #eef2f4; }
.archived-notice span { color: #53616a; }
.danger-zone { margin: -1.5rem 0 3rem; border-color: #e0b4b1; }
.danger-zone summary { color: #8e201c; }
.danger-zone .stack { max-width: 720px; }
.danger-button { border-color: #a82620; background: #a82620; color: white; }
.danger-button:hover { background: #861b17; }
.danger-actions { display: grid; gap: 1.25rem; }
.delete-note-form { padding-top: 1.25rem; border-top: 1px solid #e0b4b1; }
.empty-state { padding: 4rem 1rem; border: 1px dashed #c4c8c8; border-radius: 12px; background: rgba(255,255,255,.55); text-align: center; }
.empty-state.small { padding: 2rem 1rem; }
.management-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.user-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.user-card div { display: grid; gap: .2rem; }
.user-card span { color: var(--muted); font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; }
  .position-entry { position: static; }
  .header-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line-item { grid-template-columns: 82px 1fr; }
  .line-actions { grid-column: 1 / -1; max-width: none; justify-content: flex-start; }
}

@media (max-width: 760px) {
  .app-header { position: static; grid-template-columns: 1fr auto; gap: .6rem; padding: .75rem 1rem; }
  .app-header nav { grid-column: 1 / -1; order: 3; display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .app-header nav a { padding: .55rem .35rem; background: rgba(255,255,255,.06); text-align: center; font-size: .78rem; }
  .brand-logo-header { height: 40px; }
  .logout-form .text-button { font-size: 0; }
  .logout-form .text-button::after { content: "Abmelden"; font-size: .78rem; }
  .app-main { padding: 1rem; }
  .office-mobile-cards { display: grid; gap: .8rem; }
  .office-table-view { display: none; }
  .page-heading.split { align-items: stretch; flex-direction: column; }
  .form-grid, .header-form, .management-grid, .attachments-grid { grid-template-columns: 1fr; }
  .form-actions { justify-content: stretch; }
  .form-actions .button { flex: 1; }
  .note-card { grid-template-columns: auto 1fr; }
  .note-card small { grid-column: 2; grid-row: auto; }
  .line-item { grid-template-columns: 70px 1fr; gap: .7rem; padding-inline: .2rem; }
  .line-actions { gap: .4rem; }
  .line-actions .icon-button { min-height: 42px; }
  .completion-bar { align-items: stretch; flex-direction: column; }
  .completion-bar form, .completion-bar .button { width: 100%; }
  .photo-upload-options { grid-template-columns: 1fr; }
  .table-actions { align-items: stretch; flex-direction: column; }
  .table-actions .button { width: 100%; }
  .login-page { background: #24282c; }
}

@media (max-width: 420px) {
  .two-columns { grid-template-columns: 1fr; }
  .button-row { display: grid; }
  .page-heading .button-row { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
