:root {
  --primary: #004ac6;
  --primary-bright: #2563eb;
  --secondary: #006591;
  --tertiary: #006242;
  --error: #ba1a1a;
  --warning: #a16207;
  --surface: #f7f9fd;
  --text: #181c1f;
  --muted: #434655;
  --line: rgba(24, 28, 31, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.06), transparent 34%),
    radial-gradient(at 100% 0%, rgba(0, 101, 145, 0.05), transparent 36%),
    var(--surface);
  color: var(--text);
  letter-spacing: 0;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.material-symbols-outlined {
  font-variation-settings: "FILL" 0, "wght" 430, "GRAD" 0, "opsz" 24;
  font-size: 22px;
}

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

.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-copy,
.nav-label {
  opacity: 1;
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(0);
  transition: opacity .18s ease, max-width .22s ease, transform .22s ease;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: var(--primary-bright);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.2);
}

.brand h1, .page-title h2 { margin: 0; }
.brand p, .page-title p { margin: 4px 0 0; color: var(--muted); }

.glass {
  background: rgba(255, 255, 255, 0.56);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  transition: grid-template-columns .22s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 88px 1fr;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  z-index: 10;
  transition: width .22s ease, transform .22s ease;
}

.sidebar-collapsed .sidebar {
  width: 88px;
  align-items: center;
}

.sidebar-collapsed .brand {
  justify-content: center;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-label {
  opacity: 0;
  max-width: 0;
  transform: translateX(-8px);
}

.nav {
  display: grid;
  gap: 4px;
  margin-top: 24px;
  overflow: auto;
}

.sidebar-collapsed .nav,
.sidebar-collapsed .side-action {
  width: 56px;
}

.nav button, .side-action {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: transform .2s ease, background .2s ease, color .2s ease;
}

.sidebar-collapsed .nav button,
.sidebar-collapsed .side-action {
  justify-content: center;
  padding: 0;
}

.nav button:hover, .nav button.active {
  background: white;
  color: var(--primary);
  transform: scale(1.01);
}

.main {
  grid-column: 2;
  min-width: 0;
  padding: 88px 40px 40px;
  transition: padding .22s ease;
}

.sidebar-collapsed .main {
  padding-left: 32px;
}

.topbar {
  position: fixed;
  top: 0;
  left: 280px;
  right: 0;
  height: 64px;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 40px;
  transition: left .22s ease;
}

.sidebar-collapsed .topbar {
  left: 88px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--primary);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -18px;
  transform: translateY(-50%);
  z-index: 12;
  border: 1px solid rgba(0, 74, 198, 0.12);
}

.mobile-menu-btn,
.drawer-backdrop {
  display: none;
}

.search {
  width: min(520px, 48vw);
  position: relative;
}

.search span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 44px; }

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

.grid {
  display: grid;
  gap: 16px;
}

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

.two-col {
  grid-template-columns: 1.25fr .75fr;
  align-items: start;
}

.card {
  border-radius: 24px;
  padding: 20px;
  overflow-x: auto;
  animation: fadeUp .24s ease both;
}

.stat h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.stat strong {
  display: block;
  margin-top: 12px;
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.table-search {
  max-width: 320px;
}

.table-filter {
  max-width: 220px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination div {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.pagination .icon-btn {
  width: 34px;
  height: 34px;
  box-shadow: none;
}

.pagination .icon-btn:disabled {
  cursor: default;
  opacity: .42;
}

.calendar-controls {
  display: grid;
  grid-template-columns: 44px minmax(180px, 260px) 44px 110px;
  justify-content: start;
  margin-top: -12px;
  margin-bottom: 16px;
}

.calendar-controls .calendar-arrow {
  min-width: 0;
  padding: 0;
}

.calendar-year-input {
  width: 110px;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

label.btn {
  display: inline-flex;
  color: white;
}

label.btn.secondary {
  color: var(--primary);
}

.btn.secondary {
  background: white;
  color: var(--primary);
  border: 1px solid rgba(0, 74, 198, 0.12);
}

.btn.danger { background: var(--error); }

.table-action {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  box-shadow: none;
}

.danger-action {
  color: var(--error);
  background: #fee2e2;
}

.danger-action:hover {
  background: var(--error);
  color: white;
  transform: scale(1.04);
}

.input, select, textarea {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(115, 118, 134, 0.24);
  background: rgba(255, 255, 255, 0.55);
  padding: 10px 12px;
  outline: none;
}

.input:focus, select:focus, textarea:focus {
  border-color: var(--primary-bright);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

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

.form-grid .full { grid-column: 1 / -1; }

label:not(.btn):not(.check-item) {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(115, 118, 134, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.36);
}

.check-list legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.check-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

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

tbody tr {
  transition: background .18s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.38);
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.PENDING, .status.ACTIVE { background: #dbeafe; color: #1d4ed8; }
.status.COMPLETED { background: #dcfce7; color: #166534; }
.status.OVERDUE, .status.SUSPENDED, .status.EXPIRED { background: #fee2e2; color: #991b1b; }
.status.today { background: #fef3c7; color: #92400e; }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--line);
}

.day-name, .day {
  min-height: 42px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-name {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.5);
}

.day {
  min-height: 120px;
  background: rgba(255, 255, 255, 0.34);
}

.event {
  margin-top: 6px;
  padding: 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
}

.event.OVERDUE { background: #fee2e2; color: #991b1b; }
.event.COMPLETED { background: #dcfce7; color: #166534; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #111827;
  color: white;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .18);
  animation: toastIn .2s ease both;
}

.loading-card {
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

.loader {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid rgba(0, 74, 198, .15);
  border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .46);
  backdrop-filter: blur(8px);
  animation: fadeUp .18s ease both;
}

.modal-overlay.closing {
  opacity: 0;
  transition: opacity .16s ease;
}

.modal-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 24px;
  animation: zoomIn .2s ease both;
}

.modal-form {
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.9);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.modal-head h3 {
  margin: 0 0 6px;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
}

.modal-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fee2e2;
  color: var(--error);
}

.modal-card h3 {
  margin: 16px 0 8px;
}

.modal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.hidden { display: none !important; }

@media (max-width: 1180px) {
  .main {
    padding: 84px 24px 32px;
  }

  .topbar {
    padding: 0 24px;
  }

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

  .two-col {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar,
  .sidebar-collapsed .sidebar {
    position: fixed;
    width: min(82vw, 300px);
    align-items: stretch;
    transform: translateX(calc(-100% - 24px));
    border-radius: 0 24px 24px 0;
    z-index: 30;
  }

  .menu-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-collapsed .brand-copy,
  .sidebar-collapsed .nav-label {
    display: block;
    opacity: 1;
    max-width: 180px;
    transform: translateX(0);
  }

  .sidebar-collapsed .brand {
    justify-content: flex-start;
  }

  .sidebar-collapsed .nav,
  .sidebar-collapsed .side-action {
    width: 100%;
  }

  .sidebar-collapsed .nav button,
  .sidebar-collapsed .side-action {
    justify-content: flex-start;
    padding: 0 14px;
  }

  .sidebar-toggle {
    display: none;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(17, 24, 39, 0.28);
    backdrop-filter: blur(3px);
  }

  .menu-open .drawer-backdrop {
    display: block;
  }

  .topbar,
  .sidebar-collapsed .topbar {
    left: 0;
    height: 64px;
    padding: 0 16px;
    gap: 12px;
    justify-content: flex-start;
  }

  .mobile-menu-btn {
    display: inline-grid;
    flex: 0 0 auto;
  }

  .search {
    width: auto;
    flex: 1;
  }

  .topbar > div:last-child {
    display: none;
  }

  .main,
  .sidebar-collapsed .main {
    grid-column: 1;
    padding: 84px 14px 24px;
  }

  .stats,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .btn,
  .toolbar label.btn,
  .toolbar select,
  .toolbar .input,
  .table-search,
  .table-filter {
    flex: 1 1 auto;
    max-width: none;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-controls {
    grid-template-columns: 44px 1fr 44px;
  }

  .calendar-year-input {
    grid-column: 1 / -1;
    width: 100%;
  }

  .day-name {
    padding: 8px 4px;
    text-align: center;
  }

  .day {
    min-height: 86px;
    padding: 6px;
  }

  .event {
    font-size: 10px;
    padding: 5px;
  }

  .login-card {
    padding: 22px;
  }

  .modal-form {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .check-list {
    grid-template-columns: 1fr;
  }
}
