:root {
  --bg: #f6f8f9;
  --surface: #ffffff;
  --surface-2: #eaf1f4;
  --ink: #162d35;
  --muted: #64747b;
  --line: #d6e0e4;
  --line-strong: #b8c8cf;
  --teal: #1e5360;
  --teal-dark: #173941;
  --green: #247a49;
  --green-bg: #dff2e7;
  --yellow-bg: #fff2c6;
  --red: #a03232;
  --red-bg: #f8dddd;
  --shadow: 0 18px 45px rgba(22, 45, 53, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card p {
  color: var(--muted);
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-card label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card input {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
}

.login-message,
.user-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.register-divider {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

#invoiceMeta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

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

.btn,
.icon-btn {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 6px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.15s ease;
}

.btn {
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.icon-btn {
  width: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: 800;
}

.btn:hover,
.icon-btn:hover {
  border-color: var(--teal);
  background: #f0f6f8;
}

.btn:active,
.icon-btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.btn.danger {
  color: var(--red);
}

.icon {
  width: 18px;
  text-align: center;
  font-weight: 900;
}

.user-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.summary-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.dropzone,
.panel,
.main-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.dropzone {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 18px;
  border-radius: 8px;
  border-style: dashed;
}

.dropzone.is-dragging {
  border-color: var(--teal);
  background: #eef7f9;
}

.drop-icon {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.dropzone span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  border-radius: 8px;
  overflow: hidden;
}

.panel-title {
  min-height: 42px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.panel-title span {
  font-size: 13px;
  font-weight: 800;
  color: var(--teal-dark);
}

.panel-title span.bad {
  color: var(--red);
}

.summary-list {
  display: flex;
  flex-direction: column;
}

.summary-row {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.summary-row:last-child {
  border-bottom: 0;
}

.summary-name {
  font-weight: 800;
}

.summary-metric {
  color: var(--muted);
  font-size: 13px;
}

.summary-hours {
  font-weight: 900;
  color: var(--teal-dark);
}

.bar {
  grid-column: 1 / -1;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6ecef;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--teal);
}

.summary-row.open .bar > span {
  background: #e2b541;
}

.customer-editor {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.customer-chip {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 7px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.customer-chip input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 700;
}

.customer-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.add-customer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 6px;
  padding: 0 8px 8px;
}

.person-editor {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
  align-items: center;
  min-height: 34px;
}

.person-row span {
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-row input {
  width: 78px;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.saved-pdf-list {
  max-height: 220px;
  overflow: auto;
}

.saved-month-filter,
.summary-month-filter {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.saved-month-filter label,
.summary-month-filter label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-month-filter span,
.summary-month-filter span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.saved-month-filter select,
.summary-month-filter select {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  color: var(--ink);
}

.saved-pdf {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  text-align: left;
}

.saved-month-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  border-bottom: 1px solid var(--line);
}

.saved-pdf:hover {
  background: #f4f8fa;
}

.saved-pdf strong,
.saved-pdf span {
  display: block;
}

.saved-pdf strong {
  font-size: 13px;
  line-height: 1.25;
}

.saved-pdf span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.saved-pdf-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.user-list {
  display: flex;
  flex-direction: column;
}

.user-row {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.user-actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.user-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.user-form {
  padding: 8px;
  display: grid;
  gap: 6px;
}

.user-form input {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 9px;
}

.user-message {
  padding: 0 10px 10px;
}

.account-box {
  padding: 10px 8px 4px;
  border-bottom: 1px solid var(--line);
}

.account-box > strong {
  display: block;
  padding: 0 2px 4px;
}

.twofa-box {
  display: grid;
  gap: 7px;
  padding: 8px;
}

.twofa-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.twofa-setup,
.twofa-disable {
  display: grid;
  gap: 6px;
}

.twofa-setup span {
  color: var(--muted);
  font-size: 12px;
}

.twofa-setup code {
  display: block;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7fafb;
  word-break: break-all;
  font-size: 12px;
}

.twofa-setup textarea,
.twofa-setup input,
.twofa-disable input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 8px;
}

.twofa-setup textarea {
  min-height: 72px;
  resize: vertical;
  font-size: 11px;
}

.add-customer input,
.control-strip input,
.control-strip select {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.add-customer input {
  padding: 0 10px;
}

.main-panel {
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.article-block {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.block-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.block-heading.compact {
  margin: 0;
  padding: 12px 14px 0;
  background: var(--surface);
}

.block-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.block-heading > span {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 900;
  color: var(--teal-dark);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}

.article-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 12px;
}

.mini-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mini-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.mini-table th {
  height: 34px;
  padding: 0 8px;
  background: var(--teal-dark);
  color: #fff;
  text-align: left;
  white-space: nowrap;
}

.mini-table td {
  padding: 8px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.mini-table td.num,
.mini-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mode-pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 0 7px;
  background: var(--surface-2);
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 11px;
}

.mini-table .empty-mini {
  height: 72px;
  color: var(--muted);
  text-align: center;
}

.control-strip {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.control-strip label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.control-strip label.search {
  min-width: min(430px, 100%);
  flex: 1;
}

.control-strip span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.control-strip input,
.control-strip select {
  padding: 0 10px;
}

.status-line {
  padding: 8px 12px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  flex: 1;
  overflow: auto;
}

.task-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.task-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 42px;
  padding: 0 9px;
  background: var(--teal);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  text-align: left;
  white-space: nowrap;
}

.task-table th.customer-head {
  text-align: center;
}

.task-table td {
  padding: 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  background: #fff;
}

.task-table tr:hover td {
  background: #f9fcfd;
}

.task-table tr.audit-row:hover td,
.task-table tr.audit-row td {
  background: #f7fafb;
}

.col-nr {
  width: 48px;
  text-align: center;
}

.col-hours {
  width: 80px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-id {
  width: 86px;
}

.col-task {
  min-width: 250px;
  max-width: 330px;
}

.col-suggestion {
  width: 150px;
  color: var(--muted);
}

.customer-cell {
  width: 96px;
  text-align: center;
}

.toggle {
  width: 28px;
  height: 28px;
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 900;
}

.toggle.is-active {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.open {
  color: var(--red);
  background: var(--red-bg);
}

.status.assigned {
  color: var(--green);
  background: var(--green-bg);
}

.audit-toggle {
  display: block;
  min-height: 24px;
  margin-top: 6px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.audit-toggle:hover {
  border-color: var(--teal);
  background: var(--surface-2);
}

.audit-log {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.audit-title {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.audit-empty {
  color: var(--muted);
  font-size: 12px;
}

.audit-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.audit-list li {
  padding-left: 4px;
}

.audit-list span,
.audit-list strong {
  display: block;
}

.audit-meta,
.audit-details {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.audit-list strong {
  margin: 1px 0;
  font-size: 13px;
}

.note-input {
  width: 160px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
}

.details {
  max-width: 360px;
  color: var(--muted);
  line-height: 1.35;
}

.empty-state {
  height: 360px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  margin-top: 120px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
}

@media (max-width: 1000px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    order: 2;
  }

  .main-panel {
    min-height: 560px;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }
}
