:root {
  --blue: #0f4c81;
  --turquoise: #1dcad3;
  --dark: #1b2430;
  --sidebar: #102033;
  --light: #f5f7fa;
  --success: #2eaf62;
  --warning: #ffb703;
  --line: #e2e8f0;
  --text: #1b2430;
  --muted: #5c6b7a;
  --font: Inter, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--light);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 8px;
  background: var(--turquoise);
  color: #08343a;
  font: 600 0.95rem/1 var(--font);
  padding: 0.65rem 1rem;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { filter: brightness(0.96); text-decoration: none; }
.button-quiet { background: #fff; color: var(--blue); border: 1px solid var(--line); }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-button { display: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.8rem 1rem;
  z-index: 20;
}
.brand { display: block; padding: 0.35rem 0.75rem 1.1rem; text-decoration: none; }
.wordmark {
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.wordmark span { color: var(--turquoise); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #d5deea;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
}
.sidebar nav a img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}
.sidebar nav a.is-active,
.sidebar nav a:hover {
  background: #1d6fa8;
  color: #fff;
  text-decoration: none;
}
.sidebar-user {
  margin-top: auto;
  padding: 0.9rem 0.7rem 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: #b7c3d1;
  font-size: 0.82rem;
}
.sidebar-user strong { display: block; color: #fff; font-size: 0.92rem; }
.sidebar-account { min-width: 0; }
.sidebar-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.35rem; }
.sidebar-actions form { margin: 0; }
.sidebar-actions a,
.sidebar-actions button {
  background: none;
  border: 0;
  padding: 0;
  width: auto;
  color: #d5e4f2;
  font: 600 0.78rem/1.2 var(--font);
  cursor: pointer;
}
.sidebar-actions a:hover,
.sidebar-actions button:hover { color: #fff; text-decoration: underline; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #3d5f86;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
  object-fit: cover;
}
img.avatar { display: inline-block; }
.avatar-sm { width: 22px; height: 22px; font-size: 0.62rem; }
.person-cell { display: inline-flex; align-items: center; gap: 0.45rem; }
.person-stack { display: flex; flex-wrap: wrap; gap: 0.45rem 0.8rem; }
#id_assigned_employees { list-style: none; margin: 0; padding: 0; }
#id_assigned_employees li { margin: 0.3rem 0; }
#id_assigned_employees input { width: auto; max-width: none; margin-right: 0.45rem; }
.photo-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.photo-preview img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
}

.shell { margin-left: 240px; min-height: 100vh; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.4rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 1.35rem; flex: 1; }
.topbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
main { padding: 1.2rem 1.4rem 2rem; }

.messages { list-style: none; margin: 0; padding: 0.8rem 1.4rem 0; }
.messages li {
  background: #e7f8f4;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.4rem;
}
.messages .error { background: #fde8e8; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.card, .panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.card { padding: 1rem 1.1rem; }
.card h2, .panel h2 { margin: 0; font-size: 0.92rem; color: var(--muted); font-weight: 600; }
.metric { margin: 0.35rem 0 0; font-size: 2rem; font-weight: 700; color: var(--text); }
.hint, .empty, .week-label { color: var(--muted); }
.hint { margin: 0.2rem 0 0; }
.panel { overflow: auto; }
.panel-head, .detail { padding: 1rem 1.1rem 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem 1rem; border-top: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.empty { padding: 1rem 1.1rem; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  background: #e8eef5;
  color: var(--blue);
}
.badge-planned { background: #e7f1fb; color: var(--blue); }
.badge-progress { background: #e5f8fa; color: #0c7c86; }
.badge-done { background: #e5f6ec; color: #1d7a43; }
.badge-open { background: #fff4d6; color: #8a6200; }
.badge-critical { background: #fde8e8; color: #9b2331; }
.badge-muted { background: #eef1f4; color: var(--muted); }

.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.filters a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--text);
  text-decoration: none;
}
.filters a.is-active { background: var(--blue); color: #fff; border-color: var(--blue); }

.section-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.4rem 0;
}
.section-nav a {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.86rem;
}
.section-nav a.is-active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.placeholder-panel { padding: 1.2rem 1.1rem; margin-bottom: 0.8rem; }
.panel-inline-title {
  margin: 0;
  padding: 0.9rem 1.1rem 0;
  font-size: 0.95rem;
  color: var(--muted);
}
.analytics-cards { margin-bottom: 1rem; }
.more-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.more-list li {
  border-top: 1px solid var(--line);
  padding: 0.9rem 1.1rem;
}
.more-list li:first-child { border-top: 0; }
.more-list a, .more-list span { display: block; color: var(--text); font-weight: 600; }
.more-list small { display: block; color: var(--muted); margin-top: 0.25rem; font-weight: 400; }
.mobile-nav { display: none; }
.mobile-only { display: none; }
.desktop-only { display: flex; }
.sidebar.desktop-only { display: flex; }

.week {
  display: grid;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  gap: 0.6rem;
  overflow-x: auto;
  --hour-count: 11;
}
.day {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.day h2 { margin: 0 0 0.45rem; font-size: 0.85rem; }
.day-body {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  flex: 1;
  min-height: calc(var(--hour-count) * 2.35rem);
}
.day-hours {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin: 0;
  padding-right: 0.3rem;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1;
  text-align: right;
  user-select: none;
}
.day-hours span { transform: translateY(-50%); }
.day-hours span:first-child { transform: none; }
.day-hours span:last-child { transform: translateY(-100%); }
.day-track {
  position: relative;
  min-height: calc(var(--hour-count) * 2.35rem);
  border-radius: 8px;
  background: #fafcfd;
  overflow: hidden;
}
.day-hour-lines {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  z-index: 0;
}
.day-hour-line {
  border-top: 1px solid #e8eef5;
  height: 0;
}
.day-hour-line:first-child { border-top-color: #d7e0ea; }
.plan-card {
  position: absolute;
  left: var(--lane-left, 0.25rem);
  right: var(--lane-right, 0.25rem);
  width: var(--lane-width, auto);
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.35rem;
  background: #f3fbfc;
  border-left: 3px solid var(--turquoise);
  border-radius: 8px;
  padding: 0.15rem 0.35rem;
  margin: 0;
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(15, 76, 129, 0.04);
}
.plan-card span { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.plan-card:hover { text-decoration: none; background: #e7f7f8; }

.form-panel, .detail { padding: 1.1rem; }
form p { margin: 0 0 0.8rem; }
.address-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 5.5rem 6rem minmax(0, 1.4fr);
  gap: 0.6rem;
  max-width: 40rem;
  margin-bottom: 0.8rem;
}
.address-grid p { margin: 0; }
.address-grid input { max-width: none; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  max-width: 32rem;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: 1rem/1.4 var(--font);
  background: #fff;
}
textarea { min-height: 7rem; }
.errorlist { color: #9b2331; padding-left: 1.1rem; }
.status-form, .logout-form, .form-actions { display: flex; gap: 0.6rem; align-items: end; flex-wrap: wrap; margin-top: 1rem; }
.status-form select, .role-form select { width: auto; }
.role-form { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin: 0; }
.role-checks { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; border: 0; margin: 0; padding: 0; }
.role-checks legend { font-weight: 600; width: 100%; margin-bottom: 0.25rem; }
.role-checks label { display: flex; align-items: center; gap: 0.35rem; font-weight: 500; margin: 0; }
.role-checks input { width: auto; max-width: none; }
#id_roles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
#id_roles li { margin: 0; }
#id_roles label { display: flex; align-items: center; gap: 0.35rem; font-weight: 500; margin: 0; }
#id_roles input { width: auto; max-width: none; }
dl { display: grid; gap: 0.55rem; }
dt { font-size: 0.8rem; color: var(--muted); }
dd { margin: 0; }

.auth-layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at top right, rgba(29, 202, 211, 0.18), transparent 28rem),
    var(--light);
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 1.6rem;
  border: 1px solid var(--line);
}
.auth-mark { border-radius: 16px; }
.auth-logo { display: block; width: 200px; height: auto; margin: 0.8rem 0; }
.lede { color: var(--muted); margin-top: 0; }
.auth-foot { margin-bottom: 0; }
.auth-card button { margin-top: 0.4rem; }

.dash-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.4rem 0.2rem;
}
.dash-head h1 { margin: 0; font-size: 1.7rem; flex: 1; }
.dash-head-actions { display: flex; align-items: center; gap: 0.8rem; }
.bell { color: var(--muted); display: inline-flex; }
.hint-critical { color: #d64545; font-weight: 700; }
.card-spark { position: relative; }
.spark { position: absolute; right: 0.8rem; bottom: 0.7rem; width: 7.5rem; height: 2.2rem; }
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 0.9rem;
}
.dash-panel { display: flex; flex-direction: column; min-height: 320px; }
.panel-head h2 { color: var(--text); font-size: 1rem; }
.week-nav { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.week-nav a { margin: 0 0.45rem; }
.absence-board { margin-bottom: 0.9rem; padding-bottom: 0.9rem; }
.absence-cal {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0 1rem 0.2rem;
}
.absence-head { font-size: 0.75rem; color: var(--muted); font-weight: 700; padding: 0 0.2rem; }
.absence-day {
  min-height: 4.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem 0.35rem;
  background: #fff;
  font-size: 0.72rem;
}
.absence-day strong { display: block; margin-bottom: 0.15rem; }
.absence-day span, .absence-day a { display: block; line-height: 1.25; text-decoration: none; }
.absence-day a { color: var(--blue); }
.absence-day a.is-sick { color: #9b2331; }
.absence-day.is-muted { background: #f7f9fb; color: #9aa6b2; }
.absence-day.is-busy { background: #fff4d6; border-color: #e0a000; }
.order-list { list-style: none; margin: 0; padding: 0.2rem 0 0; }
.order-list a,
.order-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.order-list a:hover { background: #f8fbfd; text-decoration: none; }
.order-copy { flex: 1; min-width: 0; }
.order-list strong, .chip strong, .order-copy strong, .plan-card strong { display: block; }
.order-list small, .chip small, .order-copy small { display: block; color: var(--muted); font-size: 0.78rem; }
.panel-foot { margin-top: auto; padding: 0.8rem 1.1rem 1rem; }
.panel-foot a { font-weight: 600; }
.mini-week {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.2rem 0.7rem 0.4rem;
}
.mini-day h3 { margin: 0 0 0.35rem; font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.chip {
  display: flex;
  gap: 0.35rem;
  align-items: flex-start;
  border-radius: 8px;
  padding: 0.35rem;
  margin-bottom: 0.35rem;
  text-decoration: none;
  color: inherit;
  font-size: 0.72rem;
}
.chip:hover { text-decoration: none; filter: brightness(0.97); }
.chip-mint { background: #e5f6ec; }
.chip-sand { background: #fff4d6; }
.chip-lilac { background: #efe7fb; }
.chip-sky { background: #e7f1fb; }

.photo-thumb {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: #e8eef5;
}
.photo-cell { width: 3rem; }

@media (max-width: 1100px) {
  .cards, .dash-grid, .analytics-cards { grid-template-columns: 1fr 1fr; }
  .mini-week { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .desktop-only,
  .sidebar.desktop-only { display: none !important; }
  .mobile-only { display: flex; }
  .shell { margin-left: 0; padding-bottom: 4.5rem; }
  .cards, .dash-grid, .mini-week, .address-grid, .analytics-cards { grid-template-columns: 1fr; }
  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    background: #102033;
    border-top: 1px solid #1d3654;
    padding: 0.35rem 0.2rem calc(0.35rem + env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #b7c3d1;
    text-decoration: none;
    font-size: 0.68rem;
    line-height: 1.15;
    padding: 0.45rem 0.2rem;
    border-radius: 8px;
  }
  .mobile-nav a.is-active {
    color: #fff;
    background: #1d6fa8;
  }
  .section-nav.mobile-only {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }
}
