:root {
  --bg: #d1d5db;
  --card: #f8fafc;
  --ink: #111827;
  --muted: #6b7280;
  --accent: #111827;
  --accent-2: #e5e7eb;
  --border: #d1d5db;
  --danger: #c8553d;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  --chip: #e5e7eb;
  --primary: #16a34a;
}

body.dark {
  --bg: #0f172a;
  --card: #111827;
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --accent: #e5e7eb;
  --accent-2: #1f2937;
  --border: #1f2937;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --chip: #1f2937;
  --primary: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(circle at bottom right, rgba(17, 24, 39, 0.15), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

body.dark {
  background: radial-gradient(circle at top left, rgba(148, 163, 184, 0.12), transparent 55%),
    radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.7), transparent 60%),
    var(--bg);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.header h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 3vw, 40px);
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 12px;
}

button {
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

body.dark .primary {
  color: #fff;
}

.ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--border);
}

.select {
  appearance: none;
  padding: 10px 40px 10px 16px;
  min-height: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 1px), calc(100% - 12px) calc(50% - 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.control {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.control label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.control input,
.control select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
}

.hint {
  color: var(--muted);
  display: block;
  margin-top: 6px;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
}

.dates {
  background: var(--card);
  padding: 16px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  height: fit-content;
}

.dates-header h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.dates-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.small {
  padding: 6px 12px;
  font-size: 12px;
}

.dates-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.date-btn {
  text-align: left;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--chip);
  border: 1px solid var(--border);
  color: var(--ink);
}

.date-btn.active {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.table-wrap {
  background: var(--card);
  padding: 16px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  text-align: left;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status {
  margin-bottom: 12px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #fce8e2;
  color: var(--danger);
}

.mobile-row {
  display: none;
}

.mobile-cell {
  display: grid;
  grid-template-columns: minmax(110px, 140px) 1fr;
  gap: 12px;
  align-items: start;
}

.mobile-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 20px;
}

.mobile-line .label {
  color: var(--muted);
  font-weight: 600;
}

.mobile-line .sep {
  color: var(--muted);
}

.mobile-left,
.mobile-right {
  display: grid;
  gap: 6px;
}

.mobile-right {
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.mobile-item {
  font-weight: 700;
  font-size: 15px;
}

.mobile-reason {
  font-size: 15px;
  line-height: 1.4;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.hidden {
  display: none;
}

.modal-card {
  background: var(--card);
  padding: 24px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  max-width: 360px;
  width: 100%;
}

.modal-card input {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.muted {
  color: var(--muted);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 10;
}

#datesToggleBtn {
  display: none;
}

#datesCloseBtn {
  display: none;
}

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

  .dates {
    order: 0;
  }
}

@media (max-width: 640px) {
  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .dates-list {
    flex-direction: row;
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }

  .date-btn {
    white-space: nowrap;
    min-width: max-content;
  }

  .dates {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 320px);
    transform: translateX(110%);
    transition: transform 0.2s ease;
    z-index: 11;
    border-radius: 16px 0 0 16px;
    height: auto;
  }

  .dates.open {
    transform: translateX(0);
  }

  .dates-list {
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 0;
  }

  .date-btn {
    min-width: auto;
  }

  .dates-header h2 {
    margin-bottom: 0;
  }

  #datesToggleBtn {
    display: inline-flex;
  }

  #datesCloseBtn {
    display: inline-flex;
  }

  .table thead {
    display: none;
  }

  .desktop-row {
    display: none;
  }

  .mobile-row {
    display: table-row;
  }

  .table td {
    padding: 8px 10px;
  }
}
