:root {
  --rw-bg: #f4f6f8;
  --rw-surface: #ffffff;
  --rw-border: #d8dee6;
  --rw-text: #1f2a37;
  --rw-muted: #5d6b7a;
  --rw-primary: #0f4c81;
  --rw-primary-2: #0b3559;
  --rw-accent: #b28704;
  --rw-danger: #b42318;
  --rw-ok: #067647;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--rw-text);
  background: radial-gradient(circle at top right, #fdfefe, var(--rw-bg) 55%);
}

a { color: var(--rw-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: linear-gradient(100deg, var(--rw-primary-2), var(--rw-primary));
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.5px; }
.topbar form { margin: 0; }

.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px 24px;
}

.card {
  background: var(--rw-surface);
  border: 1px solid var(--rw-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px rgba(12, 18, 28, 0.04);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 4px; }
input, select, textarea, button {
  font: inherit;
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  background: #fff;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
  background: var(--rw-primary);
  color: white;
}
button.secondary, .btn.secondary {
  background: #eef3f8;
  color: var(--rw-primary-2);
  border: 1px solid #d1d9e2;
}
button.small, .btn.small {
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.2;
}
button.warn, .btn.warn {
  background: var(--rw-accent);
  color: #1d1600;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.notice { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice.error { background: #fee4e2; color: var(--rw-danger); border: 1px solid #fecdca; }
.notice.ok { background: #dcfae6; color: var(--rw-ok); border: 1px solid #abefc6; }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid var(--rw-border);
  padding: 8px;
  text-align: left;
}
.status-pill {
  display: inline-block;
  border-radius: 99px;
  font-size: 12px;
  padding: 3px 10px;
  font-weight: 700;
}
.status-pill.pending { background: #fef0c7; color: #92400e; }
.status-pill.completed { background: #dcfae6; color: #067647; }
.status-pill.prepared { background: #dbeafe; color: #1d4ed8; }

.pdf-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pdf-page {
  position: relative;
  border: 1px solid var(--rw-border);
  background: #fff;
}
.pdf-overlay {
  position: absolute;
  inset: 0;
}
.field-box {
  position: absolute;
  border: 2px solid var(--rw-primary);
  background: rgba(15, 76, 129, 0.12);
  border-radius: 6px;
  color: var(--rw-primary-2);
  padding: 2px 4px;
  font-size: 12px;
  overflow: hidden;
}
.field-box .meta {
  display: block;
  font-size: 10px;
  opacity: 0.8;
}
.field-box input, .field-box select {
  width: 100%;
  margin-top: 2px;
}
.field-inline-actions {
  display: flex;
  gap: 6px;
  margin-top: 3px;
}
.field-value-status {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: #0c365b;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 36, 0.62);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(860px, 95vw);
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--rw-border);
  box-shadow: 0 12px 30px rgba(7, 14, 23, 0.25);
  padding: 14px;
}
.modal-subtitle {
  margin: 0 0 10px;
  color: var(--rw-muted);
}
.draw-canvas {
  width: 100%;
  height: 220px;
  border: 1px solid var(--rw-border);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}
.modal-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.inline-input-action {
  display: flex;
  gap: 8px;
  align-items: center;
}
.inline-input-action input {
  min-width: 260px;
}

.prepare-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .prepare-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
