*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --green-900: #1f4e19;
  --green-800: #2e6425;
  --green-700: #3d7731;
  --green-100: #eaf3e7;
  --green-050: #f4f8f2;
  --orange: #e97808;
  --orange-soft: #fff5e8;
  --ink: #161c1a;
  --text: #323b38;
  --muted: #6c7773;
  --line: #dfe5e1;
  --line-dark: #cfd7d2;
  --surface: #ffffff;
  --canvas: #f6f7f5;
  --purple: #6f37dc;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(31, 53, 39, .12);
}

html { min-width: 320px; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.eyebrow { color: var(--green-700); font-size: 11px; font-weight: 800; letter-spacing: .11em; }

.works-topbar {
  height: 92px;
  display: grid;
  grid-template-columns: minmax(440px, 1fr) auto minmax(360px, 1fr);
  align-items: center;
  gap: 28px;
  padding: 0 66px 0 44px;
  background:
    radial-gradient(circle at 18% 50%, rgba(159, 195, 132, .22), transparent 28%),
    linear-gradient(100deg, #174d15 0%, #2a5d23 48%, #204c1e 100%);
  color: #fff;
  box-shadow: 0 7px 24px rgba(25, 69, 23, .18);
}
.works-brand { min-width: 0; display: flex; align-items: center; gap: 24px; color: #fff; text-decoration: none; }
.works-brand img { width: 198px; height: 69px; object-fit: contain; mix-blend-mode: multiply; }
.works-brand-divider { width: 1px; height: 44px; flex: 0 0 1px; background: rgba(255,255,255,.42); }
.works-brand strong { overflow: hidden; font-size: 20px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.works-home { display: inline-flex; align-items: center; gap: 9px; padding: 10px 13px; border-radius: 8px; color: #fff; font-size: 14px; text-decoration: none; }
.works-home:hover, .works-home:focus-visible { background: rgba(255,255,255,.1); }
.works-search { height: 46px; display: flex; align-items: center; gap: 12px; padding: 0 17px; border: 1px solid rgba(255,255,255,.06); border-radius: 8px; background: rgba(255,255,255,.13); }
.works-search i { color: rgba(255,255,255,.9); }
.works-search input { width: 100%; border: 0; outline: 0; background: transparent; color: #fff; }
.works-search input::placeholder { color: rgba(255,255,255,.77); }

.works-main { width: 100%; min-height: calc(100vh - 92px); }
.works-toolbar {
  min-height: 85px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 32px 14px 42px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.86);
}
.toolbar-back { display: inline-flex; align-items: center; gap: 12px; border: 0; background: transparent; font-weight: 650; cursor: pointer; }
.toolbar-back i { font-size: 19px; }
.toolbar-separator { width: 1px; height: 34px; background: var(--line); }
.toolbar-heading { min-width: 0; display: flex; align-items: center; gap: 17px; }
.toolbar-heading h1 { margin: 0; overflow: hidden; font-size: clamp(22px, 2.1vw, 30px); font-weight: 760; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-actions { display: flex; gap: 10px; margin-left: auto; }
.status-chip, .request-status { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 13px; border-radius: 8px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.status-chip::before { width: 8px; height: 8px; border-radius: 50%; background: currentColor; content: ""; }
.status-running { background: var(--green-100); color: var(--green-800); }
.status-paused { background: var(--orange-soft); color: #b35700; }
.status-done { background: #e7f5ee; color: #087a4c; }
.status-muted { background: #eef1ef; color: #64716c; }
.status-cancelled { background: #fff0f0; color: var(--danger); }

.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; border: 1px solid transparent; border-radius: 7px; background: #fff; font-size: 14px; font-weight: 700; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:focus-visible, .icon-button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(78, 125, 62, .22); outline-offset: 2px; }
.btn:disabled { opacity: .48; cursor: not-allowed; }
.btn-primary { border-color: var(--green-800); background: var(--green-800); color: #fff; box-shadow: 0 7px 18px rgba(46, 100, 37, .2); }
.btn-primary:hover:not(:disabled) { background: var(--green-900); }
.btn-secondary { border-color: var(--line-dark); background: #fff; color: #27312e; }
.btn-quiet { min-height: 36px; border-color: #ded7ef; color: var(--purple); }
.count-badge { min-width: 21px; height: 21px; display: inline-grid; place-items: center; padding: 0 5px; border-radius: 999px; background: var(--orange-soft); color: #ae5700; font-size: 11px; }
.owner-only[hidden] { display: none !important; }

#workContent { padding: 0 22px 0; }
.timeline-card { position: relative; min-height: 328px; padding: 69px 65px 26px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fafbf9 0%, #f8f9f7 100%); }
.timeline { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
.timeline-step { position: relative; min-width: 0; text-align: center; }
.timeline-step:not(:last-child)::after { position: absolute; z-index: 0; top: 52px; left: calc(50% + 24px); width: calc(100% - 48px); height: 2px; background: var(--green-700); content: ""; }
.timeline-step.pending:not(:last-child)::after, .timeline-step.overdue:not(:last-child)::after { background: repeating-linear-gradient(90deg, var(--orange) 0 7px, transparent 7px 12px); }
.timeline-step h3 { margin: 0 0 15px; font-size: 16px; font-weight: 600; }
.timeline-marker { position: relative; z-index: 1; width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 12px; border: 3px solid var(--green-700); border-radius: 50%; background: #fff; color: var(--green-700); font-size: 18px; }
.timeline-step.done .timeline-marker { border-color: var(--green-700); background: var(--green-700); color: #fff; }
.timeline-step.overdue .timeline-marker { border-color: var(--orange); background: var(--orange); color: #fff; }
.timeline-step.pending .timeline-marker { box-shadow: inset 0 0 0 7px var(--green-100); }
.timeline-date { display: block; min-height: 22px; font-size: 15px; }
.timeline-step.overdue .timeline-date, .timeline-step.overdue .timeline-caption { color: var(--orange); }
.timeline-caption { min-height: 20px; display: block; margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 650; }
.timeline-proposal { width: max-content; max-width: 92%; display: inline-block; margin-top: 8px; padding: 4px 9px; border: 1px dashed var(--orange); border-radius: 5px; color: var(--orange); font-size: 12px; }
.today-indicator { position: absolute; z-index: 2; top: -47px; left: 71%; display: flex; flex-direction: column; align-items: center; color: var(--green-800); font-size: 12px; transform: translateX(-50%); }
.today-indicator strong { margin-top: 2px; font-size: 13px; font-weight: 600; }
.today-indicator::after { width: 1px; height: 61px; margin-top: 8px; background: repeating-linear-gradient(180deg, var(--green-700) 0 6px, transparent 6px 10px); content: ""; }
.pending-date-notice { width: max-content; max-width: calc(100% - 40px); display: flex; align-items: center; gap: 14px; margin: 64px auto 0; padding: 12px 18px; border: 1px solid #f0b36f; border-radius: 7px; background: var(--orange-soft); color: #b85c00; font-size: 14px; }
.pending-date-notice i { font-size: 20px; }

.finance-card { margin: 20px 22px 16px; padding: 22px 26px 19px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.finance-metrics { display: grid; grid-template-columns: repeat(4, 1fr); }
.finance-metrics article { min-width: 0; padding: 0 26px; border-right: 1px solid var(--line); text-align: center; }
.finance-metrics article:last-child { border-right: 0; }
.finance-metrics span { display: block; color: var(--text); font-size: 13px; }
.finance-metrics strong { display: block; margin-top: 8px; color: var(--green-800); font-size: clamp(18px, 1.7vw, 24px); font-weight: 720; white-space: nowrap; }
.progress-track { height: 9px; overflow: hidden; margin-top: 22px; border-radius: 999px; background: #d8ddda; }
.progress-track span { width: 0; height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--green-700), var(--green-900)); transition: width .45s ease; }
.progress-label { margin: 9px 0 0; text-align: center; font-size: 13px; }

.works-data-grid { display: grid; grid-template-columns: 1.22fr .88fr; gap: 16px; margin: 0 22px; }
.data-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.data-card > header { min-height: 69px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.data-card h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.02em; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 13px 15px; color: #42504a; font-size: 11px; font-weight: 750; text-align: left; white-space: nowrap; }
td { padding: 14px 15px; border-top: 1px solid #edf0ee; vertical-align: middle; }
td strong { font-weight: 760; }
.table-empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.table-status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.table-status::before { width: 7px; height: 7px; border-radius: 50%; background: currentColor; content: ""; }
.table-status.ok { color: #2f7a31; }
.table-status.warn { color: var(--orange); }
.table-status.muted { color: #71807a; }
.work-facts { min-height: 66px; display: grid; grid-template-columns: .7fr 1fr 1.75fr .55fr .55fr; align-items: stretch; margin: 16px 0 0; border-top: 1px solid var(--line); background: #fff; }
.work-facts article { min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 10px 25px; border-right: 1px solid var(--line); }
.work-facts article:last-child { border-right: 0; }
.work-facts span { color: var(--muted); font-size: 11px; }
.work-facts strong { margin-top: 3px; overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.work-facts article:nth-last-child(-n+2) { align-items: center; text-align: center; }
.work-facts article:nth-last-child(-n+2) strong { font-size: 20px; }
.fact-iban { position: relative; padding-right: 50px !important; }
.fact-iban button { position: absolute; right: 15px; bottom: 18px; border: 0; background: transparent; cursor: pointer; }

.state-panel { min-height: calc(100vh - 177px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); text-align: center; }
.state-panel i { color: var(--green-700); font-size: 36px; }
.state-panel h2 { margin: 10px 0 0; color: var(--ink); }
.state-panel p { max-width: 620px; margin: 0; line-height: 1.5; }
.state-warning i { color: var(--orange); }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 2147483635; }
.drawer-backdrop { background: rgba(25, 34, 29, .10); }
.modal-backdrop { background: rgba(25, 34, 29, .28); backdrop-filter: blur(2px); }
.side-drawer { position: fixed; z-index: 2147483636; top: 0; bottom: 0; right: 0; width: min(404px, 100vw); display: flex; flex-direction: column; background: #fff; box-shadow: -20px 0 55px rgba(21, 42, 27, .17); transform: translateX(105%); transition: transform .26s cubic-bezier(.2,.8,.2,1); }
.side-drawer.open { transform: translateX(0); }
.side-drawer > header, .side-drawer form > header { min-height: 106px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 23px 24px 18px; border-bottom: 1px solid var(--line); }
.side-drawer header h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.side-drawer header p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.icon-button { width: 38px; height: 38px; display: grid; flex: 0 0 38px; place-items: center; border: 0; border-radius: 50%; background: transparent; font-size: 20px; cursor: pointer; }
.icon-button:hover { background: #f0f3f1; }
.works-list { left: 0; right: auto; box-shadow: 20px 0 55px rgba(21, 42, 27, .17); transform: translateX(-105%); }
.drawer-search { height: 48px; display: flex; align-items: center; gap: 10px; margin: 18px 20px 10px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; }
.drawer-search input { width: 100%; border: 0; outline: 0; }
.drawer-primary { margin: 0 20px 10px; }
.works-list-items { overflow-y: auto; padding: 6px 12px 24px; }
.work-list-item { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 15px 13px; border: 1px solid transparent; border-bottom-color: var(--line); background: #fff; text-align: left; cursor: pointer; }
.work-list-item:hover, .work-list-item.selected { border-color: #cbdac6; border-radius: 8px; background: var(--green-050); }
.work-list-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-list-item small { color: var(--muted); }
.work-list-item .status-chip { grid-row: 1 / span 2; grid-column: 2; min-height: 27px; padding: 0 9px; font-size: 10px; }

.date-drawer form { height: 100%; display: flex; flex-direction: column; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 24px 25px; }
.request-status { min-height: 31px; border: 1px solid #f2a34d; background: var(--orange-soft); color: #bf5e00; }
.drawer-intro { margin: 12px 0 25px; color: #4c5551; font-size: 13px; line-height: 1.45; }
.date-grid-head { display: grid; grid-template-columns: 1.08fr .8fr 1.18fr; align-items: center; gap: 12px; padding: 0 0 9px; font-size: 11px; }
.date-grid-head strong { text-align: center; }
.date-row { display: grid; grid-template-columns: 1.08fr .8fr 1.18fr; align-items: center; gap: 12px; min-height: 60px; border-top: 1px solid var(--line); }
.date-row label { font-size: 12px; font-weight: 700; }
.current-date { color: #343d39; font-size: 13px; text-align: center; }
.date-input-wrap { position: relative; }
.date-input-wrap input { width: 100%; height: 39px; padding: 0 35px 0 10px; border: 1px solid var(--line-dark); border-radius: 6px; background: #fff; color: var(--ink); font-size: 13px; }
.date-input-wrap i { position: absolute; right: 11px; top: 50%; color: #36423d; pointer-events: none; transform: translateY(-50%); }
.date-row.changed { margin: 0 -10px; padding: 0 10px; border: 1px solid #f1c28b; border-radius: 6px; background: var(--orange-soft); }
.date-row.changed + .date-row { border-top-color: transparent; }
.field-block { display: block; margin-top: 20px; }
.field-block > span { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 750; }
.field-block em { color: #d4281f; font-style: normal; }
.field-block textarea { width: 100%; resize: vertical; padding: 11px 12px; border: 1px solid var(--line-dark); border-radius: 6px; color: var(--ink); font-size: 13px; line-height: 1.45; }
.file-field { display: flex; align-items: center; gap: 12px; margin-top: 17px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.file-field > i { font-size: 20px; }
.file-field span { min-width: 0; display: flex; flex: 1; flex-direction: column; }
.file-field strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.file-field small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.file-field b { color: var(--green-800); font-size: 12px; }
.file-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.approval-note { display: flex; gap: 10px; margin: 21px 0 0; color: #59645f; font-size: 11px; line-height: 1.45; }
.date-drawer footer { display: grid; grid-template-columns: 1fr 1.35fr; gap: 12px; padding: 18px 24px 22px; border-top: 1px solid var(--line); }
.date-drawer footer .btn { min-height: 49px; }

.modal-backdrop { display: grid; place-items: center; padding: 24px; }
.requests-modal { width: min(880px, 100%); max-height: min(780px, calc(100vh - 48px)); overflow: hidden; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.requests-modal > header { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.requests-modal h2 { margin: 4px 0 0; font-size: 23px; }
.requests-modal header p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.requests-list { max-height: 640px; overflow-y: auto; padding: 18px; }
.request-card { padding: 17px; border: 1px solid var(--line); border-radius: 10px; }
.request-card + .request-card { margin-top: 12px; }
.request-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.request-card h3 { margin: 0; font-size: 17px; }
.request-card small { color: var(--muted); }
.request-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0; color: #515d58; font-size: 12px; }
.request-changes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.request-change { padding: 9px 10px; border-radius: 7px; background: var(--orange-soft); font-size: 12px; }
.request-change strong { display: block; margin-bottom: 3px; color: #a85000; }
.request-reason { margin: 13px 0; padding: 10px 12px; border-left: 3px solid #d8dedb; background: #f7f8f7; color: #46514c; font-size: 13px; line-height: 1.45; }
.request-actions { display: flex; justify-content: flex-end; gap: 9px; }
.request-actions .reject { border-color: #efc3bf; color: var(--danger); }

.entity-modal { width: min(660px, 100%); max-height: min(820px, calc(100vh - 48px)); overflow: hidden; border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.entity-modal > header { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.entity-modal h2 { margin: 4px 0 0; font-size: 23px; }
.entity-fields { max-height: 610px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; overflow-y: auto; padding: 22px 24px; }
.entity-field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.entity-field.full { grid-column: 1 / -1; }
.entity-field > span { color: #3e4944; font-size: 12px; font-weight: 750; }
.entity-field em { color: #d4281f; font-style: normal; }
.entity-field input, .entity-field select, .entity-field textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-dark); border-radius: 7px; background: #fff; color: var(--ink); }
.entity-field textarea { min-height: 82px; resize: vertical; }
.entity-field small { color: var(--muted); font-size: 10px; }
.entity-checkbox { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 9px 11px; border: 1px solid var(--line-dark); border-radius: 7px; }
.entity-checkbox input { width: 17px; height: 17px; min-height: 0; }
.entity-modal > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 17px 24px 21px; border-top: 1px solid var(--line); }

.toast { position: fixed; z-index: 2147483647; left: 50%; bottom: 28px; max-width: min(560px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 8px; background: #233128; color: #fff; box-shadow: 0 14px 38px rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #9f2018; }

@media (max-width: 1120px) {
  .works-topbar { grid-template-columns: minmax(360px, 1fr) minmax(300px, .8fr); padding-left: 26px; }
  .works-home { display: none; }
  .works-data-grid { grid-template-columns: 1fr; }
  .work-facts { grid-template-columns: repeat(3, 1fr); }
  .work-facts article:nth-last-child(-n+2) { border-top: 1px solid var(--line); }
  .finance-metrics article { padding: 0 14px; }
}

@media (max-width: 780px) {
  .works-topbar { height: auto; min-height: 76px; grid-template-columns: 1fr; gap: 10px; padding: 10px 66px 10px 15px; }
  .works-brand { gap: 11px; }
  .works-brand img { width: 126px; height: 47px; }
  .works-brand-divider { height: 31px; }
  .works-brand strong { font-size: 15px; }
  .works-search { height: 39px; }
  .works-toolbar { align-items: flex-start; flex-wrap: wrap; gap: 10px 15px; padding: 15px; }
  .toolbar-separator { display: none; }
  .toolbar-heading { order: 2; width: 100%; }
  .toolbar-actions { order: 3; width: 100%; }
  .toolbar-actions .btn { min-width: 0; flex: 1 1 0; padding: 0 7px; font-size: 12px; line-height: 1.05; white-space: normal; }
  #workContent { padding: 0; }
  .timeline-card { min-height: 0; padding: 30px 18px; }
  .timeline { grid-template-columns: 1fr; }
  .timeline-step { min-height: 92px; display: grid; grid-template-columns: 104px 44px 1fr; align-items: center; text-align: left; }
  .timeline-step h3 { margin: 0; }
  .timeline-marker { margin: 0; }
  .timeline-step:not(:last-child)::after { top: 67px; left: 124px; width: 2px; height: 45px; }
  .today-indicator { display: none; }
  .pending-date-notice { width: 100%; max-width: 100%; margin: 22px 0 0; }
  .finance-card, .works-data-grid { margin-left: 12px; margin-right: 12px; }
  .finance-metrics { grid-template-columns: repeat(2, 1fr); row-gap: 22px; }
  .finance-metrics article:nth-child(2) { border-right: 0; }
  .finance-metrics article:nth-child(n+3) { padding-top: 18px; border-top: 1px solid var(--line); }
  .work-facts { grid-template-columns: repeat(2, 1fr); }
  .fact-iban { grid-column: 1 / -1; }
  .request-changes { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
