:root {
  --app-bg: #f5f7fb;
  --app-panel: #ffffff;
  --app-text: #111827;
  --app-muted: #64748b;
  --app-line: #e5e7eb;
  --app-blue: #2563eb;
  --app-carvatel: #e11d2e;
  --app-ink: #30343b;
  --app-teal: #0f766e;
  --app-amber: #b45309;
  --app-red: #dc2626;
  --app-green: #16a34a;
  --app-violet: #7c3aed;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 13px;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(140deg, rgba(37, 99, 235, 0.12), transparent 42%),
    linear-gradient(320deg, rgba(15, 118, 110, 0.12), transparent 38%),
    var(--app-bg);
}

.carvatel-login {
  background:
    linear-gradient(135deg, rgba(225, 29, 46, 0.11), transparent 40%),
    linear-gradient(315deg, rgba(48, 52, 59, 0.1), transparent 42%),
    #f8fafc;
}

.login-panel {
  width: min(100%, 500px);
}

.password-success { padding: 12px; border: 1px solid #bbf7d0; background: #f0fdf4; color: #166534; border-radius: 6px; }

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

.login-logo {
  width: 42px;
  height: 42px;
}

.login-logo-wide {
  display: block;
  width: min(100%, 360px);
  height: auto;
  margin: 0 auto 12px;
}

.login-hero {
  text-align: center;
  display: grid;
  gap: 4px;
}

.login-hero h1 {
  margin: 0;
  color: var(--app-ink);
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

.login-copy {
  border-top: 1px solid var(--app-line);
  padding-top: 16px;
}

.login-brand h1,
.topbar h1,
.panel h2,
.login-card h2 {
  margin: 0;
  letter-spacing: 0;
  color: var(--app-text);
}

.login-eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.login-card,
.panel,
.stat-card,
.sidebar {
  border: 1px solid var(--app-line);
  background: var(--app-panel);
  border-radius: var(--radius);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.login-card {
  display: grid;
  gap: 16px;
  padding: 28px;
}

.login-card p {
  margin: 6px 0 0;
  color: var(--app-muted);
}

.alert-error {
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  background: #fef2f2;
  color: #991b1b;
  padding: 10px 12px;
  font-weight: 600;
}

.demo-access {
  display: grid;
  gap: 3px;
  padding-top: 4px;
  color: var(--app-muted);
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width, 220px) minmax(0, 1fr);
}

.app-shell.sidebar-collapsed {
  --sidebar-width: 68px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 16px 12px;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
}

.sidebar-toggle {
  flex: 0 0 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--app-text);
  font-weight: 800;
}

.brand img {
  width: 32px;
  height: 32px;
}

.brand .brand-logo {
  width: 144px;
  height: auto;
  max-height: 48px;
  object-fit: contain;
}

.nav-stack {
  display: grid;
  gap: 6px;
}

.nav-item {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #334155;
  padding: 11px 12px;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  font-size: 13px;
}

.nav-item > i {
  flex: 0 0 18px;
  font-size: 17px;
}

.nav-button {
  appearance: none;
}

.nav-item:hover,
.nav-item.active {
  background: #eef4ff;
  color: var(--app-blue);
}

.main-content {
  min-width: 0;
  padding: 14px 22px 22px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.app-view {
  display: none;
}

.app-view.active {
  display: block;
}

.workspace-grid.app-view.active {
  display: grid;
}

.topbar,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin: 0;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.2;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 10px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: var(--user-color, #475569);
  font-size: 22px;
}

.user-chip div {
  display: grid;
  min-width: 0;
}

.user-chip strong {
  line-height: 1.1;
  font-size: 13px;
}

.kt-btn {
  font-size: 13px;
}

.panel h2,
.modal-card h2,
.login-card h2 {
  font-size: 18px;
}

.user-chip span {
  color: var(--app-muted);
  font-size: 12px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: #fff;
  color: #475569;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--app-blue);
  border-color: #bfdbfe;
}

.password-control { position: relative; min-width: 0; }
.field .password-control input { padding-right: 48px; }
.password-toggle { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); border: 0; background: transparent; }
.password-toggle:focus-visible { outline: 2px solid var(--app-blue); outline-offset: 1px; }

.kt-btn-danger {
  background: var(--app-red);
  border-color: var(--app-red);
  color: #fff;
}

.kt-btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stats-grid.compact-away {
  display: none;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.stat-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  font-size: 20px;
}

.stat-icon.slate {
  background: #e2e8f0;
  color: #334155;
}

.stat-icon.amber {
  background: #fef3c7;
  color: var(--app-amber);
}

.stat-icon.red {
  background: #fee2e2;
  color: var(--app-red);
}

.stat-icon.green {
  background: #dcfce7;
  color: var(--app-green);
}

.stat-icon.purple {
  background: #f3e8ff;
  color: var(--app-violet);
}

.stat-card p {
  margin: 0;
  color: var(--app-muted);
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.workspace-grid.app-view {
  display: none;
}

.workspace-grid.app-view.active {
  display: grid;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel-header {
  margin-bottom: 12px;
}

.panel-header.simple {
  align-items: flex-start;
}

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.list-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.select-control,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--app-text);
  padding: 9px 11px;
  outline: none;
}

.select-control {
  width: auto;
  min-width: 160px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.field textarea {
  resize: vertical;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.field small {
  color: var(--app-muted);
  font-size: 12px;
  line-height: 1.35;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.repeat-box {
  display: grid;
  gap: 12px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  padding: 12px;
  background: #f8fafc;
}

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

.calendar-surface {
  min-height: 620px;
}

.fc {
  --fc-border-color: var(--app-line);
  --fc-today-bg-color: #eff6ff;
  font-size: 13px;
}

.fc .fc-toolbar-title {
  font-size: 18px;
  letter-spacing: 0;
}

.fc .fc-button-primary {
  border-color: var(--app-blue);
  background: var(--app-blue);
}

.fc-event {
  border-radius: 6px;
  border: 0;
  padding: 2px 4px;
  cursor: pointer;
}

.task-list {
  display: grid;
  gap: 10px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 12px;
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 800;
}

.task-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--app-line);
  border-left: 4px solid var(--task-color, var(--app-blue));
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.task-owner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.user-color-dot {
  display: inline-block;
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--user-color, var(--app-blue));
}

.task-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.task-title-line h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0;
}

.task-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 5px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 700;
}

.task-desc {
  margin: 8px 0 0;
  color: #475569;
}

.task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.holiday-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.holiday-list {
  display: grid;
  gap: 10px;
}

.holiday-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.holiday-row div {
  display: grid;
  gap: 2px;
}

.holiday-row span {
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 700;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--app-line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.user-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.user-row-main .user-avatar {
  color: var(--user-color, #475569);
  font-size: 22px;
}

.user-row-main div {
  display: grid;
  min-width: 0;
}

.user-row-main span {
  color: var(--app-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.user-row-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.badge.pending {
  background: #fef3c7;
  color: #92400e;
}

.badge.completed {
  background: #dcfce7;
  color: #166534;
}

.badge.overdue {
  background: #fee2e2;
  color: #991b1b;
}

.badge.high {
  background: #ede9fe;
  color: var(--app-violet);
}

.badge.medium {
  background: #e0f2fe;
  color: #0369a1;
}

.badge.low {
  background: #f1f5f9;
  color: #475569;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 28px;
  color: var(--app-muted);
  text-align: center;
}

.modal {
  width: min(92vw, 520px);
  position: fixed;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.modal-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-card footer {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  font-weight: 700;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hours-dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.hours-dashboard h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.hours-goal {
  margin: 5px 0 0;
  color: var(--app-muted);
  font-size: 13px;
}

.hours-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hours-filters .select-control {
  width: auto;
  max-width: 100%;
  min-height: 40px;
}

.period-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--app-line);
  border-radius: 6px;
  background: #fff;
}

.period-switch button {
  min-width: 65px;
  min-height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--app-muted);
  font-size: 13px;
  cursor: pointer;
}

.period-switch button[aria-pressed="true"] {
  background: #eaf2ff;
  color: var(--app-blue);
  font-weight: 700;
}

.hours-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 20px 0 16px;
  font-size: 13px;
  color: var(--app-muted);
}

.hours-context strong {
  color: var(--app-text);
}

.hours-status {
  margin: 8px 0;
  color: var(--app-muted);
  font-size: 13px;
}

.hours-status:empty {
  display: none;
}

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

.hours-chart-grid[hidden] {
  display: none;
}

.hours-chart-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--app-line);
  border-radius: 8px;
  background: #fff;
}

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

.hours-chart-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.3;
}

.hours-chart-card header div > span {
  font-size: 12px;
  color: var(--app-muted);
}

.hours-chart-icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  border-radius: 6px;
  font-size: 19px;
}

.hours-chart-icon.planned {
  background: #eff6ff;
  color: var(--app-blue);
}

.hours-chart-icon.completed {
  background: #f0fdf4;
  color: var(--app-green);
}

.hours-chart-frame {
  position: relative;
  width: min(100%, 260px);
  height: 220px;
  margin: 8px auto 0;
}

.hours-chart {
  width: 100%;
  height: 220px;
}

.hours-chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  pointer-events: none;
}

.hours-chart-center strong { font-size: 28px; color: var(--app-text); }
.hours-chart-center span { font-size: 12px; color: var(--app-muted); }

.hours-chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  font-size: 13px;
}

.hours-chart-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hours-swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 3px;
}

.hours-swatch.planned { background: var(--app-blue); }
.hours-swatch.completed { background: var(--app-green); }
.hours-swatch.missing { background: #e2e8f0; }

.hours-chart-card footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--app-line);
  color: var(--app-muted);
  font-size: 12px;
}

.hours-extra,
.hours-warning {
  color: var(--app-amber);
}

@media (min-width: 821px) {
  .sidebar-collapsed .sidebar {
    padding: 16px 10px;
  }

  .sidebar-collapsed .sidebar-header {
    flex-direction: column;
  }

  .sidebar-collapsed .brand-logo {
    width: 44px;
    max-height: 24px;
  }

  .sidebar-collapsed .nav-label {
    display: none;
  }

  .sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 10px;
  }
}

.hours-warning {
  margin: 10px 0 0;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .holiday-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 820px) {
  .calendar-surface.fc .fc-header-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .calendar-surface .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .calendar-surface .fc-toolbar-chunk:nth-child(2) {
    grid-row: 1;
  }

  .hours-chart-grid {
    grid-template-columns: 1fr;
  }

  .hours-chart-card {
    padding: 16px;
  }

  .hours-filters {
    width: 100%;
  }

  .hours-filters select.select-control {
    flex: 1 1 160px;
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--app-line);
    padding: 16px;
    gap: 14px;
  }

  .sidebar .nav-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .sidebar .nav-item {
    padding: 10px 6px;
    gap: 5px;
    font-size: 12px;
  }

  .sidebar-collapsed .nav-stack {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .topbar,
  .panel-header,
  .task-row,
  .user-row {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .user-chip {
    justify-content: space-between;
  }

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

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

  .repeat-grid {
    grid-template-columns: 1fr;
  }

  .filters,
  .task-actions,
  .header-actions,
  .pagination-bar {
    justify-content: stretch;
  }

  .select-control,
  .task-actions .kt-btn,
  .header-actions .kt-btn,
  .pagination-bar .kt-btn {
    width: 100%;
  }

  .calendar-surface {
    min-height: 520px;
  }
}
