:root {
  --paper: #f8f6f0;
  --white: #fffefb;
  --ink: #20332c;
  --muted: #53655d;
  --forest: #213f35;
  --forest-hover: #31584a;
  --line: #dcded4;
  --overdue: #8e3c32;
  --soon: #75520e;
  --serif: Georgia, "PT Serif", serif;
  --sans: "PT Sans", "Trebuchet MS", sans-serif;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
}

button, input { font: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid #477b67;
  outline-offset: 3px;
}

h1, h2, h3, p { margin: 0; }
h1, h2 { font: 400 1.78rem/1.13 var(--serif); }

.container {
  width: min(calc(100% - 64px), 1080px);
  margin-inline: auto;
}

.topbar {
  background: var(--forest);
  color: #f9edda;
  border-bottom: 3px solid #c8a46e;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 58px;
  padding-block: 10px;
}

.project-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: .94rem;
  font-weight: 700;
}
.project-mark svg { flex: none; }

.today {
  color: #e4e7d6;
  text-align: end;
  font-size: .94rem;
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 33px 0 27px;
}

.intro h1 { font-size: clamp(2.2rem, 5vw, 3.55rem); }
.intro p {
  margin-top: .55rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 700;
  transition: background-color .15s ease;
}

.button-primary { background: var(--forest); color: white; }
.button-primary:hover { background: var(--forest-hover); }
.button-secondary { border-color: var(--line); color: var(--ink); background: var(--white); }
.button-secondary:hover, .button-icon:hover { background: #e9ece4; }
.button-danger { background: var(--overdue); color: white; }
.button-danger:hover { background: #753026; }
.button-icon { padding: 0; width: 44px; flex: none; color: var(--ink); background: transparent; font-size: 1.5rem; line-height: 1; }
.plus { font-size: 1.5rem; line-height: 1; font-weight: 400; }

.schedule {
  padding: 21px 24px 23px;
  background: #eef0e7;
  border: 1px solid #d8ddce;
  border-radius: 9px;
}

.schedule-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.17fr);
  gap: 23px;
  margin-top: 16px;
}

.schedule-group {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}

.schedule-group h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 1rem;
}

.schedule-overdue h3 { color: var(--overdue); }
.schedule-soon h3 { color: var(--soon); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.event-list { padding: 0; margin: 0; list-style: none; }
.event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(72px, auto);
  gap: 12px;
  padding: 7px 0;
}

.event + .event { border-top: 1px solid var(--line); }
.event-name, .contract-name, .counterparty { overflow-wrap: anywhere; }
.event-type, .event-offset, .counterparty { display: block; color: var(--muted); font-size: .88rem; }
.event-deadline { text-align: right; }
.event-deadline time { font-weight: 700; white-space: nowrap; }
.schedule-overdue .event-offset { color: var(--overdue); }
.schedule-soon .event-offset { color: var(--soon); }
.schedule-empty { padding: 7px 0; color: var(--muted); }

.registry { margin-top: 28px; }
.registry-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 13px; margin-bottom: 11px; }
.count { color: var(--muted); font-size: .94rem; }
.registry-card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; }

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th, td { padding: 9px 15px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .93rem; font-weight: 700; }
th:first-child { width: 38%; }
th:nth-child(2), th:nth-child(3) { width: 21%; }
td { border-top: 1px solid var(--line); }
.counterparty { margin-top: 1px; }
.row-actions { text-align: right; }

.text-button {
  display: inline-block;
  padding: 5px 6px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--forest);
  font-weight: 700;
  font-size: .88rem;
}

.text-button:hover { text-decoration: underline; }
.text-button-delete { color: var(--overdue); }
.mobile-label { display: none; }
.registry-empty { padding: 23px; color: var(--muted); }
.status-note { display: block; font-size: .84rem; }
.status-note.overdue { color: var(--overdue); }
.status-note.soon { color: var(--soon); }
.no-date { color: var(--muted); }

main.container { padding-bottom: 22px; }

.notice {
  margin: 0 0 18px;
  padding: 9px 12px;
  border: 1px solid #d9c8a7;
  border-radius: 5px;
  color: #704c0c;
  background: #fcf4e3;
}

dialog {
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 23px;
  border: 1px solid var(--line);
  border-top: 4px solid #c8a46e;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
}

dialog::backdrop { background: rgb(18 32 25 / 58%); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
#delete-description { overflow-wrap: anywhere; }
label { display: block; margin-bottom: 4px; font-weight: 700; }
input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 43px;
  margin-bottom: 13px;
  padding: 8px 10px;
  border: 1px solid #a7b1a5;
  border-radius: 5px;
  background: white;
  color: var(--ink);
}
fieldset { min-inline-size: 0; margin: 0; padding: 0; border: none; }
.date-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.date-fields input { margin-bottom: 4px; }
.form-hint, .form-error { font-size: .91rem; }
.form-hint { color: var(--muted); }
.form-error { color: var(--overdue); }
.form-actions { display: flex; justify-content: end; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 940px) {
  th:first-child { width: 33%; }
  th:nth-child(2), th:nth-child(3) { width: 20%; }
}

@media (max-width: 710px) {
  .container { width: calc(100% - 36px); }
  .schedule-grid { grid-template-columns: 1fr; gap: 10px; }
  .schedule { padding: 16px; }
  table, tbody { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 12px 14px;
  }
  tbody tr + tr { border-top: 1px solid var(--line); }
  td { display: block; padding: 0; border: 0; }
  td:first-child, .row-actions { grid-column: 1 / -1; }
  .row-actions { text-align: left; }
  .text-button { min-height: 44px; padding-inline: 10px; }
  .mobile-label { display: block; color: var(--muted); font-size: .87rem; }
}

@media (max-width: 525px) {
  .intro { align-items: flex-start; flex-direction: column; gap: 15px; padding-block: 23px 20px; }
  .intro p { font-size: 1rem; }
  .project-mark, .today { font-size: .82rem; }
}

@media (max-width: 385px) {
  .event { gap: 7px; }
  .date-fields { grid-template-columns: 1fr; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
