:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-alt: #eef2f5;
  --text: #1f2a37;
  --muted: #637083;
  --border: #d5dde5;
  --primary: #0f5d73;
  --primary-dark: #0a4353;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 8px 24px rgba(31, 42, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8fafb 0%, var(--bg) 100%);
}

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

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #12222d;
  color: #fff;
  padding: 1.5rem 1rem;
}

.sidebar h1 {
  font-size: 1.15rem;
  line-height: 1.4;
  margin: 0 0 1.5rem;
}

.sidebar nav a,
.sidebar nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dce7ed;
  border: 0;
  padding: 0.85rem 0.9rem;
  border-radius: 0.6rem;
  margin-bottom: 0.35rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.sidebar nav a:hover,
.sidebar nav button:hover,
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.main {
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.content {
  padding: 1.5rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.stat-card h2 {
  margin: 0;
  font-size: 2rem;
}

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-alt);
  font-size: 0.92rem;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: #d9edf4;
  color: var(--primary-dark);
  font-size: 0.8rem;
}

.flash {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.75rem;
}

.flash.success {
  background: #e9f8ef;
  color: var(--success);
}

.flash.error {
  background: #fdecec;
  color: var(--danger);
}

form {
  display: grid;
  gap: 1rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

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

input,
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fff;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button,
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--primary);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
}

.button.secondary {
  background: #dce7ed;
  color: var(--text);
}

.inline-form {
  display: inline;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(100%, 420px);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 1rem;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

.detail-list div {
  padding: 0.75rem;
  background: var(--surface-alt);
  border-radius: 0.75rem;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(180px, 1fr));
  gap: 0.75rem;
  overflow-x: auto;
}

.calendar-controls {
  align-items: center;
}

.calendar-period {
  padding: 0.75rem 0.25rem;
  font-weight: 700;
  color: var(--text);
}

.day-column {
  min-height: 240px;
}

.job-pill {
  display: block;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: #edf7fa;
  margin-bottom: 0.75rem;
}

.calendar-month {
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-month-header,
.calendar-month-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-month-header div {
  padding: 0.85rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  text-align: center;
}

.calendar-month-cell {
  min-height: 160px;
  padding: 0.75rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: #fff;
}

.calendar-month-row .calendar-month-cell:last-child,
.calendar-month-header div:last-child {
  border-right: 0;
}

.calendar-month-date {
  font-weight: 700;
}

.calendar-month-cell.is-muted {
  background: #f8fafb;
  color: var(--muted);
}

.calendar-month-items {
  display: grid;
  gap: 0.45rem;
}

.calendar-month-pill {
  display: grid;
  gap: 0.1rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.65rem;
  background: #edf7fa;
  color: var(--text);
  font-size: 0.84rem;
}

.calendar-month-pill span {
  color: var(--muted);
}

.calendar-month-more {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.2rem 0.1rem;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 0.5rem;
  }

  .grid-4,
  .grid-2,
  .detail-grid,
  .form-grid,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .calendar-month-header,
  .calendar-month-row {
    min-width: 760px;
  }

  .topbar,
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
