:root {
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e0d5;
  --accent: #0f4c3a;
  --accent-soft: #d8ebe3;
  --danger: #9f1239;
  --warn: #b45309;
  --ok: #047857;
  --radius: 10px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #dceee6 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #efe6d6 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: rgba(255,253,248,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}
.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
}
.topbar nav a {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}
.topbar nav a.active,
.topbar nav a:hover { color: var(--accent); }

.wrap {
  width: min(980px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 1.5rem;
}

h1 { font-size: 1.55rem; margin: 0 0 1rem; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: end;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 0 rgba(28,25,23,0.03);
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.field { margin-bottom: 0.9rem; }
input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
@media (max-width: 640px) {
  .row-2 { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; color: #fff; }
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 0.3rem 0.55rem; font-size: 0.85rem; font-weight: 500; }

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:hover td { background: rgba(15,76,58,0.03); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-new { background: #e0e7ff; color: #3730a3; }
.badge-sent { background: #fef3c7; color: #92400e; }
.badge-accepted { background: #d1fae5; color: #065f46; }
.badge-contract_sent { background: #e0f2fe; color: #075985; }
.badge-contract_signed { background: #0f4c3a; color: #fff; }
.badge-rejected { background: #ffe4e6; color: #9f1239; }

.row-featured td {
  background: #ecfdf5;
}
.row-featured:hover td {
  background: #d1fae5;
}
.row-featured td:first-child {
  box-shadow: inset 3px 0 0 #0f4c3a;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}
.flash-ok { background: #d1fae5; color: #065f46; }
.flash-error { background: #ffe4e6; color: #9f1239; }

.login-wrap {
  width: min(400px, calc(100% - 2rem));
  margin: 4rem auto;
}
.login-wrap h1 { text-align: center; }
.muted { color: var(--muted); font-size: 0.9rem; }
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 0.25rem 0 1rem;
}
.check-row .check { margin: 0; }
.check input { width: auto; }
.check label { margin: 0; color: var(--ink); font-size: 0.92rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.inline-form { display: inline; }

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.cal-legend {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}
.cal-legend-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}
.cal-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.82rem;
  text-decoration: none;
}
.cal-legend-item:hover { text-decoration: none; border-color: var(--accent); }
.cal-legend-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.cal-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.cal-dot-new { background: #4f46e5; }
.cal-dot-sent { background: #d97706; }
.cal-dot-accepted { background: #059669; }
.cal-dot-contract_sent { background: #0284c7; }
.cal-dot-contract_signed { background: #0f4c3a; }
.cal-dot-rejected { background: #e11d48; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}
.cal-head {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.35rem;
  text-transform: uppercase;
}
.cal-day {
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
}
.cal-day.empty { background: transparent; border-color: transparent; min-height: 0; }
.cal-day .num { font-weight: 700; color: var(--muted); margin-bottom: 0.25rem; }
.cal-day.today {
  box-shadow: inset 0 0 0 2px var(--accent);
}
.cal-day.has-events { background: #fff; }
.cal-events {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-height: 0;
}
.cal-event {
  display: block;
  border-radius: 5px;
  padding: 0.2rem 0.35rem;
  text-decoration: none !important;
  line-height: 1.2;
  border-left: 3px solid transparent;
}
.cal-event-name {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
}
.cal-event-status {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-new {
  background: #eef2ff;
  border-left-color: #4f46e5;
}
.cal-event-sent {
  background: #fffbeb;
  border-left-color: #d97706;
}
.cal-event-accepted {
  background: #ecfdf5;
  border-left-color: #059669;
}
.cal-event-contract_sent {
  background: #e0f2fe;
  border-left-color: #0284c7;
}
.cal-event-contract_signed {
  background: #0f4c3a;
  border-left-color: #083528;
}
.cal-event-contract_signed .cal-event-name,
.cal-event-contract_signed .cal-event-status {
  color: #f0fdf4;
}
.cal-event-featured {
  box-shadow: 0 0 0 2px rgba(15, 76, 58, 0.35);
  font-weight: 600;
}
.cal-event-rejected {
  background: #fff1f2;
  border-left-color: #e11d48;
  opacity: 0.85;
}
.cal-mobile-dots {
  display: none;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: auto;
  padding-top: 0.2rem;
}
.qr {
  display: block;
  margin: 0.75rem 0;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.secret-box {
  font-family: ui-monospace, monospace;
  background: #f5f5f4;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  word-break: break-all;
}
.status-select {
  min-width: 10rem;
  padding: 0.3rem 0.4rem;
  font-size: 0.85rem;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}
@media (max-width: 800px) {
  .cal-day { min-height: 64px; }
  .cal-events { display: none; }
  .cal-mobile-dots { display: flex; }
  .cal-legend-item { font-size: 0.75rem; }
}

