:root {
  --teal: #005870;
  --teal-dark: #003d4d;
  --teal-soft: #e6f3f6;
  --bg: #f3f6f8;
  --card: #ffffff;
  --text: #1a2b32;
  --muted: #5a6d75;
  --danger: #c0392b;
  --ok: #1e7a46;
  --warn: #c47f17;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 55, 70, 0.08);
  --sidebar: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Segoe UI", "Nunito Sans", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--teal); text-decoration: none; }
img { max-width: 100%; }

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(145deg, #e8f4f7 0%, #f7fbfc 45%, #d9eef3 100%);
  padding: 24px;
}
.auth-card {
  width: min(440px, 100%); background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 32px;
}
.auth-card h1 { margin: 0 0 8px; color: var(--teal); font-size: 1.6rem; }
.auth-card p { margin: 0 0 24px; color: var(--muted); }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar .brand { font-weight: 700; font-size: 1.15rem; padding: 10px 12px 22px; }
.sidebar a {
  display: block; color: rgba(255,255,255,.9); padding: 11px 12px; border-radius: 10px; margin-bottom: 4px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-group { margin-bottom: 4px; }
.nav-group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 0; color: rgba(255,255,255,.95); padding: 11px 12px; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.nav-group-toggle:hover,
.nav-group.is-open > .nav-group-toggle { background: rgba(255,255,255,.14); }
.nav-group-toggle .chevron {
  transition: transform .25s ease;
  display: inline-flex;
  line-height: 1;
}
.nav-group.is-open > .nav-group-toggle .chevron { transform: rotate(180deg); }
.nav-group-panel {
  display: none;
  padding: 2px 0 6px 10px;
  border-left: 2px solid rgba(255,255,255,.22);
  margin: 2px 0 6px 12px;
}
.nav-group.is-open > .nav-group-panel {
  display: block !important;
  animation: navSlide .22s ease;
}
.nav-group:not(.is-open) > .nav-group-panel,
.nav-group-panel[hidden] {
  display: none !important;
}
.nav-group-panel a {
  font-size: .93rem !important;
  padding: 9px 12px 9px 12px !important;
  margin-bottom: 2px !important;
  color: rgba(255,255,255,.92) !important;
}
@keyframes navSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: visible; }
.topbar {
  background: var(--card); border-bottom: 1px solid #e5eef1; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 100; overflow: visible;
}
.user-menu { position: relative; z-index: 110; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid #d7e4e8; background: #fff;
  border-radius: 999px; padding: 8px 12px; font: inherit; font-weight: 600; color: var(--teal-dark); cursor: pointer;
}
.user-menu-btn .chevron { transition: transform .2s ease; line-height: 1; }
.user-menu.is-open .user-menu-btn .chevron { transform: rotate(180deg); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(340px, 86vw);
  background: #fff; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid #e5eef1;
  padding: 14px; z-index: 120;
}
.user-menu:not(.is-open) > .user-menu-panel,
.user-menu-panel[hidden] {
  display: none !important;
}
.user-menu.is-open > .user-menu-panel {
  display: block !important;
  animation: dropIn .2s ease;
}
.user-menu-title { font-weight: 800; margin-bottom: 10px; color: var(--teal-dark); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.content { padding: 22px; }
.footer { padding: 16px 22px; color: var(--muted); font-size: .9rem; border-top: 1px solid #e5eef1; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.stat { padding: 18px; border-radius: var(--radius); background: var(--teal-soft); }
.stat strong { display: block; font-size: 1.6rem; color: var(--teal); }

label { display: block; font-weight: 600; margin: 0 0 6px; font-size: .92rem; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfdce1; border-radius: 10px; font: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
.form-row { margin-bottom: 14px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkbox input { width: auto; }

.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--teal); color: #fff; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--teal-dark); }
.btn-secondary { background: #e8eef0; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 7px 11px; font-size: .88rem; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid #e7eef1; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; }
.data-table input[type="text"],
.data-table input[type="number"],
.data-table input:not([type]) {
  width: 100%; min-width: 0; margin: 0;
}
.data-table input[type="checkbox"] { width: auto; }
.data-table td { white-space: nowrap; }
.data-table td:first-child { white-space: normal; min-width: 220px; }
.badge {
  display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700;
}
.badge-dev { background: #ffe8a3; color: #7a5600; }
.badge-ok { background: #d8f5e4; color: var(--ok); }
.badge-warn { background: #fff1d6; color: var(--warn); }
.badge-danger { background: #fde2e0; color: var(--danger); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid #e5eef1; padding-bottom: 10px; }
.tabs a, .tabs button {
  border: 0; background: transparent; padding: 10px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted);
}
.tabs a.active, .tabs button.active { background: var(--teal-soft); color: var(--teal); }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day {
  min-height: 72px; border-radius: 12px; background: #f7fafb; border: 1px solid #e5eef1; padding: 8px; cursor: pointer;
}
.cal-day.filled { background: #e7f8ee; border-color: #b7e4c7; }
.cal-day.missing { background: #fff4e8; border-color: #f0d0a0; }
.cal-day .mark { font-weight: 700; }

.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #12343f; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,30,36,.45); display: none; align-items: center; justify-content: center;
  z-index: 900; padding: 16px;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: min(560px, 100%); background: #fff; border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.menu-toggle { display: none; background: transparent; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--teal); }

@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -280px; z-index: 50; transition: left .25s ease; }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-block; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: repeat(4, 1fr); }
}
