/* =============================================================
   HAUT RITUALE — Global Styles & Components
   ============================================================= */

/* -------------------------------------------------------------
   Reset & Base
   ------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

ul, ol { list-style: none; }

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

img, svg { display: block; }

/* -------------------------------------------------------------
   Accessibility Utilities
   ------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* -------------------------------------------------------------
   Icons
   ------------------------------------------------------------- */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

.icon--lg {
  width: 24px;
  height: 24px;
}

/* -------------------------------------------------------------
   Spinner
   ------------------------------------------------------------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.spinner--large {
  width: 40px;
  height: 40px;
  border-width: 3px;
  border-color: var(--color-border);
  border-top-color: var(--color-accent);
}

.spinner--muted {
  border-color: var(--color-border);
  border-top-color: var(--color-accent);
}

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

/* -------------------------------------------------------------
   App Body Layout
   ------------------------------------------------------------- */
.app-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* -------------------------------------------------------------
   LOGIN SCREEN
   ------------------------------------------------------------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--color-bg) 0%, var(--color-bg-secondary) 100%);
  padding: var(--space-6);
}

.login-screen--hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
}

/* Brand block */
.login-brand {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-brand__logo {
  display: inline-block;
  font-size: var(--text-3xl);
  color: var(--color-accent);
  margin-bottom: var(--space-3);
  line-height: 1;
}

.login-brand__name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-light);
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-primary);
  line-height: var(--leading-tight);
}

.login-brand__tagline {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-top: var(--space-1);
}

/* Login form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.login-form__options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* -------------------------------------------------------------
   FORM COMPONENTS
   ------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  letter-spacing: var(--tracking-wide);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .form-input {
  padding-right: 2.75rem;
}

.form-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast),
              background-color var(--transition-fast);
}

.form-input::placeholder {
  color: var(--color-text-disabled);
}

.form-input:hover {
  border-color: var(--color-border-strong);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
  background: var(--color-surface);
}

.form-input--error {
  border-color: var(--color-error);
}

.form-input--error:focus {
  box-shadow: 0 0 0 3px rgba(184, 92, 92, 0.25);
}

.form-error {
  font-size: var(--text-sm);
  color: var(--color-error);
  min-height: 1.2em;
}

.form-error--global {
  text-align: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-error-bg);
  border-radius: var(--radius-md);
  border: 1px solid rgba(184, 92, 92, 0.2);
  display: none;
}

.form-error--global:not(:empty) {
  display: block;
}

/* Input action button (password toggle) */
.input-action-btn {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.input-action-btn:hover {
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
}

/* Textarea */
.form-textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

/* Select */
.form-select {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-8) 0 var(--space-4);
  background: var(--color-surface-raised)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a8a8a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right var(--space-3) center;
  background-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--text-base);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.checkbox-input:checked + .checkbox-custom {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.checkbox-input:checked + .checkbox-custom::after {
  content: '';
  display: block;
  width: 10px;
  height: 6px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

.checkbox-input:focus-visible + .checkbox-custom {
  box-shadow: var(--focus-ring);
}

/* -------------------------------------------------------------
   BUTTONS
   ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast), transform var(--transition-fast);
  border: 1px solid transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--color-accent);
  color: var(--color-text-on-accent);
  border-color: var(--color-accent);
}

.btn--primary:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent-light);
  box-shadow: var(--shadow-accent);
}

.btn--primary:active {
  background: var(--color-accent-dark);
  border-color: var(--color-accent-dark);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-border-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--color-bg-secondary);
}

.btn--danger {
  background: var(--color-error-bg);
  color: var(--color-error);
  border-color: rgba(184, 92, 92, 0.2);
}

.btn--danger:hover {
  background: var(--color-error);
  color: #fff;
}

.btn--full {
  width: 100%;
}

.btn--sm {
  height: 34px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
}

.btn--lg {
  height: 52px;
  padding: 0 var(--space-8);
  font-size: var(--text-md);
}

.btn__spinner {
  display: none;
}

.btn--loading .btn__text {
  visibility: hidden;
  position: absolute;
}

.btn--loading .btn__spinner {
  display: inline-block;
}

.btn--loading {
  pointer-events: none;
  opacity: 0.85;
  position: relative;
}

/* Link button */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--color-accent);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.link-btn:hover {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

/* Icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.icon-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

/* -------------------------------------------------------------
   APP SHELL
   ------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

.app-shell--hidden {
  display: none;
}

/* -------------------------------------------------------------
   SIDEBAR
   ------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-sidebar-border);
  z-index: var(--z-sticky);
  transition: width var(--transition-slow);
  overflow: hidden;
}

/* Brand */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-sidebar-border);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar__brand-logo {
  font-size: var(--text-lg);
  color: var(--color-accent);
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  line-height: 1;
}

.sidebar__brand-name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-light);
  color: var(--color-text-on-dark);
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-slow), width var(--transition-slow);
}

.sidebar__collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text-dim);
  margin-left: auto;
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast),
              transform var(--transition-slow);
}

.sidebar__collapse-btn:hover {
  color: var(--color-sidebar-text);
  background: var(--color-sidebar-hover);
}

/* Nav */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-sidebar-border) transparent;
}

.sidebar__nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar__nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar__nav::-webkit-scrollbar-thumb {
  background: var(--color-sidebar-border);
  border-radius: var(--radius-pill);
}

.nav-list {
  padding: 0 var(--space-2);
}

.nav-divider {
  height: 1px;
  background: var(--color-sidebar-border);
  margin: var(--space-2) var(--space-2);
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  transition: background-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-link:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text-on-dark);
}

.nav-link--active {
  background: var(--color-sidebar-active);
  color: var(--color-accent-light);
}

.nav-link--active .nav-icon {
  color: var(--color-accent);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-sidebar-icon);
  transition: color var(--transition-fast);
}

.nav-link:hover .nav-icon {
  color: var(--color-sidebar-text);
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition-slow);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: var(--weight-semi);
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
}

.nav-badge:empty {
  display: none;
}

/* Sidebar Footer */
.sidebar__footer {
  border-top: 1px solid var(--color-sidebar-border);
  flex-shrink: 0;
}

.sidebar__footer .nav-list {
  padding: var(--space-2) var(--space-2) 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  overflow: hidden;
}

.sidebar__user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  flex-shrink: 0;
  letter-spacing: var(--tracking-wide);
}

.sidebar__user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  transition: opacity var(--transition-slow);
}

.sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--text-xs);
  color: var(--color-sidebar-text-dim);
  white-space: nowrap;
}

.sidebar__logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--color-sidebar-text-dim);
  flex-shrink: 0;
  margin-left: auto;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.sidebar__logout-btn:hover {
  color: var(--color-error);
  background: rgba(184, 92, 92, 0.15);
}

/* Sidebar — Collapsed state */
.sidebar--collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar--collapsed .sidebar__brand-name,
.sidebar--collapsed .nav-label,
.sidebar--collapsed .nav-badge,
.sidebar--collapsed .sidebar__user-info,
.sidebar--collapsed .sidebar__logout-btn {
  opacity: 0;
  pointer-events: none;
  width: 0;
  overflow: hidden;
}

.sidebar--collapsed .sidebar__collapse-btn {
  transform: rotate(180deg);
  margin-left: 0;
}

.sidebar--collapsed .sidebar__user {
  justify-content: center;
  padding: var(--space-4) var(--space-3);
}

.sidebar--collapsed .nav-link {
  justify-content: center;
  padding: var(--space-2);
}

.sidebar--collapsed .nav-icon {
  margin: 0;
}

.sidebar--collapsed .sidebar__brand {
  justify-content: center;
  padding: var(--space-5) var(--space-2);
}

/* -------------------------------------------------------------
   MAIN WRAPPER
   ------------------------------------------------------------- */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-width: 0;
  transition: margin-left var(--transition-slow);
}

.app-shell:has(.sidebar--collapsed) .main-wrapper {
  margin-left: var(--sidebar-width-collapsed);
}

/* -------------------------------------------------------------
   TOPBAR
   ------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-4);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.topbar__menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.topbar__menu-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

.topbar__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.topbar__search {
  position: relative;
  display: flex;
  align-items: center;
}

.topbar__search-icon {
  position: absolute;
  left: var(--space-3);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.topbar__search-input {
  height: 36px;
  width: 220px;
  padding: 0 var(--space-4) 0 calc(var(--space-3) + 16px + var(--space-2));
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  transition: width var(--transition-slow), border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.topbar__search-input::placeholder {
  color: var(--color-text-muted);
}

.topbar__search-input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
  width: 280px;
}

.topbar__action-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.topbar__action-btn:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

.topbar__notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-surface);
  display: none;
}

.topbar__notification-dot--visible {
  display: block;
}

/* -------------------------------------------------------------
   CONTENT AREA & VIEWS
   ------------------------------------------------------------- */
.content-area {
  flex: 1;
  padding: var(--content-padding);
  width: 100%;
  position: relative;
  min-height: calc(100dvh - var(--topbar-height));
}

/* View containers */
.view {
  display: none;
}

.view--active {
  display: block;
}

/* View loading */
.view-loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16);
  color: var(--color-text-muted);
}

.view-loading--visible {
  display: flex;
}

.view-loading__text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* -------------------------------------------------------------
   PAGE HEADER
   ------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-header__content {
  min-width: 0;
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   CARDS
   ------------------------------------------------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-xs);
}

.card--raised {
  box-shadow: var(--shadow-md);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.card__subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Stat cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-xs);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  line-height: 1;
}

.stat-card__delta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.stat-card__delta--up   { color: var(--color-success); }
.stat-card__delta--down { color: var(--color-error); }

/* Grid layouts */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
}

/* -------------------------------------------------------------
   TABLE
   ------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  background: var(--color-surface-raised);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--color-bg);
}

.table--clickable tbody tr {
  cursor: pointer;
}

/* -------------------------------------------------------------
   BADGES / STATUS
   ------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.badge--pending   { background: var(--color-warning-bg);   color: var(--color-warning); }
.badge--confirmed { background: var(--color-info-bg);      color: var(--color-info); }
.badge--completed { background: var(--color-success-bg);   color: var(--color-success); }
.badge--cancelled { background: var(--color-bg-secondary); color: var(--color-text-muted); }
.badge--no-show   { background: var(--color-error-bg);     color: var(--color-error); }
.badge--draft     { background: var(--color-bg-secondary); color: var(--color-text-muted); }
.badge--sent      { background: var(--color-info-bg);      color: var(--color-info); }
.badge--paid      { background: var(--color-success-bg);   color: var(--color-success); }
.badge--overdue   { background: var(--color-error-bg);     color: var(--color-error); }
.badge--void      { background: var(--color-bg-secondary); color: var(--color-text-disabled); }

/* -------------------------------------------------------------
   EMPTY STATE
   ------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16) var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state__icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-disabled);
}

.empty-state__title {
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.empty-state__text {
  font-size: var(--text-sm);
  max-width: 320px;
}

/* -------------------------------------------------------------
   MODAL LAYER
   ------------------------------------------------------------- */
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.modal-layer[aria-hidden="true"] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--color-surface-overlay);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 540px;
  max-height: calc(100dvh - var(--space-12));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modal-in var(--transition-slow) var(--transition-spring) both;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--color-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.modal--wide   { max-width: 720px; }
.modal--narrow { max-width: 400px; }

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-6) var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.modal__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.modal__close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

.modal__body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  background: var(--color-surface-raised);
}

/* -------------------------------------------------------------
   TOAST NOTIFICATIONS
   ------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  max-width: 360px;
  animation: toast-in var(--transition-slow) var(--transition-spring) both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast--out {
  animation: toast-out var(--transition-base) ease both;
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(24px); }
}

.toast--success { border-left: 3px solid var(--color-success); }
.toast--error   { border-left: 3px solid var(--color-error); }
.toast--warning { border-left: 3px solid var(--color-warning); }
.toast--info    { border-left: 3px solid var(--color-info); }

.toast__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast--success .toast__icon { color: var(--color-success); }
.toast--error   .toast__icon { color: var(--color-error); }
.toast--warning .toast__icon { color: var(--color-warning); }
.toast--info    .toast__icon { color: var(--color-info); }

.toast__content {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  margin-bottom: 2px;
}

.toast__message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-snug);
}

.toast__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.toast__close:hover {
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
}

/* -------------------------------------------------------------
   SEARCH / FILTER BAR
   ------------------------------------------------------------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.filter-bar__search {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.filter-bar__search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.filter-bar__input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-4) 0 calc(var(--space-3) + 16px + var(--space-2));
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.filter-bar__input:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

.filter-bar__select {
  height: 40px;
  padding: 0 var(--space-8) 0 var(--space-3);
  background: var(--color-surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a8a8a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right var(--space-3) center;
  background-size: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition-fast);
}

.filter-bar__select:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
}

/* -------------------------------------------------------------
   PAGINATION
   ------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.pagination__controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.pagination__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  border: 1px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.pagination__btn:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-border);
}

.pagination__btn--active {
  background: var(--color-accent-muted);
  color: var(--color-accent);
  border-color: var(--color-accent-muted);
  font-weight: var(--weight-medium);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* -------------------------------------------------------------
   DROPDOWN MENU
   ------------------------------------------------------------- */
.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  display: none;
}

.dropdown__menu--open {
  display: block;
  animation: dropdown-in var(--transition-fast) ease both;
}

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.dropdown__item:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.dropdown__item--danger {
  color: var(--color-error);
}

.dropdown__item--danger:hover {
  background: var(--color-error-bg);
}

.dropdown__divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-1) 0;
}

/* -------------------------------------------------------------
   TABS
   ------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.tab:hover {
  color: var(--color-text-secondary);
}

.tab--active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* -------------------------------------------------------------
   DIVIDER
   ------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-6) 0;
}

/* -------------------------------------------------------------
   UTILITY CLASSES
   ------------------------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.font-medium  { font-weight: var(--weight-medium); }
.font-semi    { font-weight: var(--weight-semi); }
.font-display { font-family: var(--font-display); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2        { gap: var(--space-2); }
.gap-3        { gap: var(--space-3); }
.gap-4        { gap: var(--space-4); }

/* -------------------------------------------------------------
   TABLE — Sort button
   ------------------------------------------------------------- */
.sort-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
}

.sort-btn:hover { color: var(--color-text-primary); }

.sort-icon {
  font-style: normal;
  opacity: 0.5;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  justify-content: flex-end;
  white-space: nowrap;
}

/* -------------------------------------------------------------
   Customer Avatar
   ------------------------------------------------------------- */
.customer-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-accent-muted);
  color: var(--color-accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-wide);
  flex-shrink: 0;
}

.customer-name {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

/* -------------------------------------------------------------
   Tag Chips
   ------------------------------------------------------------- */
.tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-accent-subtle);
  color: var(--color-accent-dark);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  border: 1px solid var(--color-accent-muted);
}

.tag-chip--input {
  background: var(--color-accent-muted);
}

.tag-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  color: var(--color-accent-dark);
  cursor: pointer;
  padding: 0;
  transition: background-color var(--transition-fast);
}

.tag-chip__remove:hover {
  background: rgba(160, 120, 120, 0.3);
}

/* Tag input widget */
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: text;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.tag-input-wrapper:focus-within {
  border-color: var(--color-border-focus);
  box-shadow: var(--focus-ring);
  background: var(--color-surface);
}

.tag-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  font-size: var(--text-base);
  color: var(--color-text-primary);
  outline: none;
  padding: 2px 0;
}

.tag-input::placeholder {
  color: var(--color-text-disabled);
}

.tag-chips {
  display: contents;
}

/* Form hint */
.form-hint {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* 2-column form row */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 540px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

/* skin badge — neutral style */
.badge--skin {
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
}

/* icon-btn danger variant */
.icon-btn--danger:hover {
  color: var(--color-error);
  background: var(--color-error-bg);
}

/* -------------------------------------------------------------
   Treatments — Category Groups
   ------------------------------------------------------------- */
.treat-category-group {
  margin-bottom: var(--space-8);
}

.treat-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.treat-category-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.treat-category-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wide);
}

.treat-name {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

.treat-price {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.treat-row--inactive td {
  opacity: 0.55;
}

/* Duration preset buttons */
.dur-presets {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Toggle / Switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  background: var(--color-border-strong);
  border-radius: var(--radius-pill);
  transition: background-color var(--transition-base);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-base);
}

.toggle-input:checked + .toggle-track {
  background: var(--color-success);
}

.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
}

.toggle-input:focus-visible + .toggle-track {
  box-shadow: var(--focus-ring);
}

.toggle-text {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

/* -------------------------------------------------------------
   Appointments — Day Groups
   ------------------------------------------------------------- */
.appt-day-group {
  margin-bottom: var(--space-8);
}

.appt-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.appt-day-header--today .appt-day-label {
  color: var(--color-accent);
}

.appt-day-label {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.appt-day-count {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: var(--tracking-wide);
}

.appt-time {
  font-weight: var(--weight-semi);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-wide);
}

.appt-customer {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
}

.appt-price {
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
}

.appt-row--overdue td {
  background: var(--color-warning-bg);
}

/* -------------------------------------------------------------
   Sidebar Backdrop (mobile overlay)
   ------------------------------------------------------------- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: calc(var(--z-sticky) - 1);
}
.sidebar-backdrop.sidebar-backdrop--visible {
  display: block;
}

/* -------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .topbar__search-input { width: 180px; }
  .topbar__search-input:focus { width: 220px; }
}

@media (max-width: 768px) {
  :root {
    --content-padding: var(--space-4);
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    box-shadow: var(--shadow-xl);
    transition: transform var(--transition-slow), width var(--transition-slow);
  }

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

  .sidebar--collapsed {
    transform: translateX(-100%);
  }

  .main-wrapper {
    margin-left: 0 !important;
  }

  .topbar__search {
    display: none;
  }

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .modal-container {
    max-width: 100%;
    align-self: flex-end;
    max-height: 90dvh;
  }

  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .toast-container {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header__actions {
    justify-content: flex-end;
  }

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

  .filter-bar__search {
    min-width: unset;
  }
}

/* =============================================================
   CASHBOOK
   ============================================================= */

/* -- Month navigation --------------------------------------- */
.cb-month-nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.cb-month-label {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 160px;
  text-align: center;
}

/* -- Stat cards (income/expense colors) --------------------- */
.stat-card__value--income  { color: #16a34a; }
.stat-card__value--expense { color: var(--color-error, #dc2626); }
.stat-card__value--warn    { color: var(--color-warning, #d97706); }

/* -- Amount colors in table --------------------------------- */
.cb-amount--income  { color: #16a34a; }
.cb-amount--expense { color: var(--color-error, #dc2626); }

/* -- Category chip ------------------------------------------ */
.cb-category {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* -- Type toggle in modal ----------------------------------- */
.cb-type-toggle {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.cb-type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
              color var(--transition-fast);
}

.cb-type-btn:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.cb-type-btn--active.cb-type-btn--income {
  border-color: #16a34a;
  background: color-mix(in srgb, #16a34a 10%, transparent);
  color: #15803d;
}

.cb-type-btn--active.cb-type-btn--expense {
  border-color: var(--color-error, #dc2626);
  background: color-mix(in srgb, var(--color-error, #dc2626) 10%, transparent);
  color: var(--color-error, #dc2626);
}

/* -- Tagesabschluss stats ----------------------------------- */
.cb-closing-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.cb-closing-stat {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  text-align: center;
}

.cb-closing-stat__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}

.cb-closing-stat__value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}

.cb-closing-stat--income      { border-color: #bbf7d0; background: #f0fdf4; }
.cb-closing-stat--income      .cb-closing-stat__value { color: #15803d; }
.cb-closing-stat--expense     { border-color: #fecaca; background: #fef2f2; }
.cb-closing-stat--expense     .cb-closing-stat__value { color: #b91c1c; }
.cb-closing-stat--saldo-pos   { border-color: var(--color-primary); background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.cb-closing-stat--saldo-pos   .cb-closing-stat__value { color: var(--color-primary); }
.cb-closing-stat--saldo-neg   { border-color: #fecaca; background: #fef2f2; }
.cb-closing-stat--saldo-neg   .cb-closing-stat__value { color: #b91c1c; }

/* -- Filter tab income/expense tint ------------------------- */
.filter-tab--income.filter-tab--active {
  background: #16a34a;
  border-color: #16a34a;
}

.filter-tab--expense.filter-tab--active {
  background: var(--color-error, #dc2626);
  border-color: var(--color-error, #dc2626);
}

/* =============================================================
   INVOICES  (& shared finance components)
   ============================================================= */

/* -- Filter tabs (status bar) -------------------------------- */
.inv-status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-tab {
  padding: 5px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              border-color var(--transition-fast);
  white-space: nowrap;
}

.filter-tab:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
}

.filter-tab--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.filter-tab--active:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

/* -- Invoice number (monospace) ------------------------------ */
.inv-number {
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: 0.8125rem;
  background: var(--color-bg-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  letter-spacing: 0.03em;
}

/* -- Action buttons group ------------------------------------ */
.action-btns {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}

/* -- Overdue row -------------------------------------------- */
.row--overdue td {
  background: color-mix(in srgb, var(--color-warning, #d97706) 6%, transparent);
}

/* -- Danger text -------------------------------------------- */
.text-danger {
  color: var(--color-error, #dc2626);
  font-weight: 500;
}

/* -- Modal size variants ------------------------------------ */
.modal--sm {
  max-width: 440px;
}

.modal--lg {
  max-width: 760px;
}

/* -- Form sections inside modal ----------------------------- */
.form-section {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.form-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.form-section-header .form-section-title {
  margin-bottom: 0;
}

/* -- Items table in modal ----------------------------------- */
.inv-items-table-wrap {
  overflow-x: auto;
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.inv-items-table {
  margin: 0;
  min-width: 500px;
}

.inv-items-table thead th {
  background: var(--color-bg-secondary);
  font-size: 0.75rem;
  padding: 8px 6px;
}

/* -- Compact form input (for items table) ------------------- */
.form-input--sm {
  padding: 5px 8px;
  font-size: 0.8125rem;
  height: 32px;
}

/* -- Invoice totals summary --------------------------------- */
.inv-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0;
  margin-top: var(--space-3);
}

.inv-totals__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  width: 260px;
  padding: 4px 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.inv-totals__row:last-child {
  border-bottom: none;
}

.inv-totals__row--total {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text-primary);
  margin-top: 2px;
  padding-top: 6px;
}

/* =============================================================
   CALENDAR
   ============================================================= */

/* -- View container override (flex column) ------------------- */
#view-calendar.view--active {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  height: 100%;
}

/* -- Toolbar ------------------------------------------------- */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cal-toolbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cal-toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  min-width: 160px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* -- View toggle buttons ------------------------------------- */
.cal-view-toggle {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cal-view-btn {
  background: transparent;
  border: none;
  border-left: 1px solid var(--color-border);
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 1;
}

.cal-view-btn:first-child {
  border-left: none;
}

.cal-view-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.cal-view-btn--active {
  background: var(--color-primary);
  color: #fff;
}

.cal-view-btn--active:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

/* -- Scrollable body ----------------------------------------- */
.cal-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* =============================================================
   MONTH VIEW
   ============================================================= */

.cal-month-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.cal-month-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
}

.cal-month-dow {
  padding: 6px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  flex: 1;
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
}

.cal-month-cell {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 6px;
  cursor: pointer;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--transition-fast);
}

.cal-month-cell:hover {
  background: var(--color-bg-secondary);
}

.cal-month-cell--other {
  background: var(--color-bg-tertiary);
}

.cal-month-cell--other .cal-month-day-num {
  color: var(--color-text-tertiary);
}

.cal-month-cell--today {
  background: color-mix(in srgb, var(--color-primary) 4%, transparent);
}

.cal-month-day-num {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  line-height: 1;
  margin-bottom: 2px;
  flex-shrink: 0;
  align-self: flex-start;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-month-day-num--today {
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
}

.cal-month-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.cal-month-event {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: filter var(--transition-fast);
}

.cal-month-event:hover {
  filter: brightness(0.9);
}

.cal-month-more {
  font-size: 0.7rem;
  color: var(--color-text-tertiary);
  padding: 2px 5px;
  font-weight: 500;
}

/* =============================================================
   WEEK / DAY GRID VIEW
   ============================================================= */

.cal-grid-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Sticky header row */
.cal-grid-header {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  flex-shrink: 0;
}

.cal-gutter-head {
  width: 52px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
}

.cal-day-headers {
  display: grid;
  grid-template-columns: repeat(var(--day-count, 7), 1fr);
  flex: 1;
}

.cal-day-header-cell {
  padding: 8px 4px 6px;
  text-align: center;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.cal-day-header-cell:last-child {
  border-right: none;
}

.cal-day-header-cell--today .cal-day-num {
  background: var(--color-primary);
  color: #fff;
}

.cal-day-dow {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-day-num {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-day-num--today {
  background: var(--color-primary);
  color: #fff;
}

/* Scrollable body */
.cal-scroll-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.cal-scroll-inner {
  display: flex;
  position: relative;
}

/* Time labels column */
.cal-time-col {
  width: 52px;
  flex-shrink: 0;
  position: relative;
  border-right: 1px solid var(--color-border);
}

.cal-hour-label {
  position: absolute;
  right: 8px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  transform: translateY(-50%);
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}

/* Day columns grid */
.cal-grid-cols {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--day-count, 7), 1fr);
  position: relative;
}

/* Hour lines (behind everything) */
.cal-hour-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.cal-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--color-border);
}

/* Individual day column */
.cal-day-col {
  position: relative;
  border-right: 1px solid var(--color-border);
  cursor: crosshair;
  z-index: 1;
}

.cal-day-col:last-child {
  border-right: none;
}

.cal-day-col--today {
  background: color-mix(in srgb, var(--color-primary) 3%, transparent);
}

/* =============================================================
   EVENT BLOCKS (Week/Day)
   ============================================================= */

.cal-event {
  position: absolute;
  border-radius: 4px;
  padding: 3px 6px;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
  transition: filter var(--transition-fast), box-shadow var(--transition-fast);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 3px solid rgba(0,0,0,0.2);
}

.cal-event:hover {
  filter: brightness(0.92);
  box-shadow: var(--shadow-md);
  z-index: 3;
}

.cal-event-time {
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event-name {
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.9;
}

/* =============================================================
   STATUS COLORS  (shared month + week/day)
   ============================================================= */

.cal-color--confirmed {
  background: color-mix(in srgb, var(--color-primary) 18%, #fff);
  color: var(--color-primary-dark, var(--color-primary));
}

.cal-color--completed {
  background: color-mix(in srgb, var(--color-success, #16a34a) 15%, #fff);
  color: var(--color-success-dark, #15803d);
}

.cal-color--cancelled {
  background: color-mix(in srgb, var(--color-danger, #dc2626) 12%, #fff);
  color: var(--color-danger-dark, #b91c1c);
}

.cal-color--no_show {
  background: color-mix(in srgb, #9ca3af 20%, #fff);
  color: #6b7280;
}

.cal-color--pending {
  background: color-mix(in srgb, var(--color-warning, #d97706) 18%, #fff);
  color: var(--color-warning-dark, #b45309);
}

/* =============================================================
   NOW LINE
   ============================================================= */

.cal-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-danger, #dc2626);
  z-index: 10;
  pointer-events: none;
}

.cal-now-dot {
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-danger, #dc2626);
}

/* -------------------------------------------------------------
   Settings — Öffnungszeiten
   ------------------------------------------------------------- */
.settings-hours-row {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.settings-hours-row:last-child {
  border-bottom: none;
}

.settings-hours-row > .toggle-label {
  min-width: 130px;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle-day {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.hours-time-fields {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
}

.hours-time-fields .form-group {
  margin-bottom: 0;
}

.hours-time-fields .form-input {
  width: 110px;
}

.hours-time-fields--disabled {
  opacity: 0.4;
  pointer-events: none;
}

.hours-sep {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  padding: 0 var(--space-1);
}

/* -------------------------------------------------------------
   Dashboard — Stat-Card Extensions
   ------------------------------------------------------------- */
.stat-card--loading {
  opacity: 0.5;
  pointer-events: none;
}

.stat-card__footer {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
}

.stat-card__sub {
  color: var(--color-text-muted);
}

.stat-card__link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--weight-medium);
}

.stat-card__link:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------
   Dashboard — Schnellzugriff Grid
   ------------------------------------------------------------- */
.dash-quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.dash-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-base), border-color var(--transition-base), box-shadow var(--transition-base);
  text-align: center;
}

.dash-quick-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  color: var(--color-primary);
}

.dash-quick-btn .icon {
  color: var(--color-text-muted);
  transition: color var(--transition-base);
}

.dash-quick-btn:hover .icon {
  color: var(--color-primary);
}

/* -------------------------------------------------------------
   Dashboard — Shared List
   ------------------------------------------------------------- */
.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dash-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.dash-list__item:last-child {
  border-bottom: none;
}

.dash-list__item--warn {
  background: var(--color-warning-bg, #fffbeb);
  margin: 0 calc(var(--card-padding) * -1);
  padding-left: var(--card-padding);
  padding-right: var(--card-padding);
}

.dash-list__content {
  flex: 1;
  min-width: 0;
}

.dash-list__primary {
  font-weight: var(--weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-list__secondary {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* -------------------------------------------------------------
   Dashboard — Heutige Termine
   ------------------------------------------------------------- */
.dash-appt-time {
  min-width: 3rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* -------------------------------------------------------------
   Dashboard — Aktivitäten
   ------------------------------------------------------------- */
.dash-act-icon {
  flex-shrink: 0;
}

.dash-act-icon__wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full, 50%);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.dash-act-time {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* -------------------------------------------------------------
   Statistics Module
   ------------------------------------------------------------- */
.stats-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-xs);
  margin-bottom: var(--space-6);
}

.stats-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.stats-section__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  color: var(--color-text-primary);
  letter-spacing: var(--tracking-wide);
}

.stats-section__meta {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.stats-chart-wrap {
  width: 100%;
  min-height: 180px;
}

.stats-chart-wrap--sm {
  min-height: 120px;
}

.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
}

@media (max-width: 900px) {
  .stats-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* -------------------------------------------------------------
   Templates Module
   ------------------------------------------------------------- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-5);
}

.tpl-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--card-padding);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: box-shadow var(--transition-fast);
}

.tpl-card:hover {
  box-shadow: var(--shadow-md);
}

.tpl-card--inactive {
  opacity: 0.6;
}

.tpl-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.tpl-card__actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.tpl-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.tpl-card__name {
  font-weight: var(--weight-semi);
  font-size: var(--text-base);
  color: var(--color-text-primary);
}

.tpl-card__subject {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.tpl-card__preview {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-snug);
  flex: 1;
}

.tpl-card__foot {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
  margin-top: var(--space-1);
}

.tpl-var-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tpl-var-chip {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.tpl-var-chip:hover {
  background: var(--color-accent-muted);
  border-color: var(--color-accent);
  color: var(--color-accent-dark);
}

.tpl-preview {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  min-height: 80px;
  max-height: 260px;
  overflow-y: auto;
}

/* -------------------------------------------------------------
   Todos Module
   ------------------------------------------------------------- */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.todo-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  transition: box-shadow var(--transition-fast);
}

.todo-item:hover {
  box-shadow: var(--shadow-xs);
}

.todo-item--done {
  opacity: 0.6;
  background: var(--color-bg-secondary);
}

.todo-item--overdue {
  border-left: 3px solid var(--color-error);
}

.todo-check {
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 2px;
}

.todo-check__box {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border-strong);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.todo-check__box svg {
  width: 12px;
  height: 12px;
  color: var(--color-surface);
}

.todo-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.todo-check input[type="checkbox"]:checked + .todo-check__box {
  background: var(--color-success);
  border-color: var(--color-success);
}

.todo-check:hover .todo-check__box {
  border-color: var(--color-accent);
}

.todo-content {
  flex: 1;
  min-width: 0;
}

.todo-title {
  font-weight: var(--weight-medium);
  color: var(--color-text-primary);
  line-height: var(--leading-snug);
}

.todo-title--done {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.todo-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
  line-height: var(--leading-snug);
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .todo-actions {
    flex-direction: column;
    align-items: flex-end;
  }

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