:root {
  --primary: #7B2CBF;
  --primary-dark: #5A189A;
  --primary-light: #E91E8C;
  --gradient: linear-gradient(135deg, #E91E8C 0%, #7B2CBF 100%);
  --sidebar-bg: #1a1025;
  --sidebar-hover: rgba(233, 30, 140, 0.15);
  --sidebar-active: rgba(123, 44, 191, 0.35);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #F8F7FC;
  --card: #ffffff;
  --text: #1a1025;
  --muted: #64748b;
  --border: #e9d5ff;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(26, 16, 37, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #f8f7fc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.2s ease, transform 0.25s ease;
}

.sidebar-brand {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 64px;
  overflow: hidden;
}

.sidebar-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1;
}

.sidebar-collapse-btn:hover {
  background: rgba(233, 30, 140, 0.25);
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1100;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: var(--gradient);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.sidebar-backdrop {
  display: none;
}

.sidebar-brand img,
.sidebar-logo {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.sidebar-user {
  padding: 14px 18px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
}

.sidebar-group-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4);
  padding: 12px 12px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 0.9rem;
  margin-bottom: 2px;
  transition: background 0.15s;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: white;
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .btn-outline {
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-footer .btn-outline:hover {
  background: rgba(233, 30, 140, 0.2);
  border-color: rgba(233, 30, 140, 0.5);
  color: white;
}

.main-content {
  flex: 1;
  padding: 28px 32px;
  overflow-x: auto;
  max-width: calc(100vw - 260px);
  transition: max-width 0.2s ease;
}

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

.app-shell.sidebar-collapsed .sidebar-logo,
.app-shell.sidebar-collapsed .sidebar-user,
.app-shell.sidebar-collapsed .sidebar-group-title,
.app-shell.sidebar-collapsed .sidebar-logout-btn {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-nav a {
  justify-content: center;
  padding-left: 8px;
  padding-right: 8px;
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.2;
}

.app-shell.sidebar-collapsed .main-content {
  max-width: calc(100vw - 72px);
}

.container {
  max-width: 1200px;
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.auth-brand-panel {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 28px 24px;
  color: white;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-brand-panel img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin-bottom: 32px;
}

.auth-brand-panel h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: white;
  margin-bottom: 8px;
}

.auth-brand-panel p {
  margin-top: 0;
  opacity: 0.7;
  text-align: left;
  font-size: 0.92rem;
  line-height: 1.5;
}

.auth-brand-features {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.auth-brand-features span {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  padding-left: 12px;
  border-left: 3px solid var(--primary-light);
}

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px;
  width: min(420px, 92vw);
  border: 1px solid rgba(233, 213, 255, 0.5);
}

.auth-card h1 {
  font-size: 1.6rem;
  margin-bottom: 8px;
  color: var(--primary-dark);
}

.auth-card p {
  color: var(--muted);
  margin-bottom: 24px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(233, 213, 255, 0.5);
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  color: var(--primary-dark);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.15);
}

.form-group textarea {
  min-height: 90px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  font-family: inherit;
}

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

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--gradient);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.punch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.punch-btn {
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.punch-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #fdf4ff;
}

.punch-btn.done {
  border-color: var(--success);
  background: #ecfdf5;
}

.punch-btn .label {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.punch-btn .time {
  font-size: 0.85rem;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

th {
  background: #fdf4ff;
  font-weight: 600;
  color: var(--primary-dark);
}

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover {
  background: #faf5ff;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-signed { background: #f3e8ff; color: #5A189A; }
.badge-blocked { background: #fee2e2; color: #991b1b; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.92rem;
}

.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-info { background: #f3e8ff; color: #5A189A; }

.hidden { display: none !important; }

.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
  color: var(--primary-dark);
}

.page-header p {
  color: var(--muted);
}

.filters-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}

.filters-row .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

.ficha-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.ficha-tab {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.ficha-tab.active {
  background: var(--gradient);
  color: white;
  border-color: transparent;
}

.ficha-section.hidden {
  display: none;
}

tr.row-active td {
  background: rgba(123, 44, 191, 0.06);
}

.photo-preview {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid var(--border);
  background: #f8fafc;
}

.photo-placeholder {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 16, 37, 0.6);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: min(480px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin-bottom: 16px;
  color: var(--primary-dark);
}

.camera-preview {
  width: 100%;
  max-height: 280px;
  background: #000;
  border-radius: 8px;
  margin-bottom: 12px;
}

.camera-preview video,
.camera-preview img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 8px;
}

.mirror-company-info {
  background: #fdf4ff;
  border: 1px solid rgba(233, 213, 255, 0.8);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.mirror-company-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 4px;
  word-break: break-word;
  line-height: 1.35;
}

.mirror-employee-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  word-break: break-word;
  line-height: 1.4;
}

.mirror-company-meta {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.mirror-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.mirror-info-block {
  background: #fdf4ff;
  border: 1px solid rgba(233, 213, 255, 0.8);
  border-radius: 10px;
  padding: 16px 18px;
}

.mirror-info-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  margin-bottom: 8px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.summary-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.summary-card .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.summary-card .label {
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .auth-brand-panel {
    min-height: auto;
    padding: 20px 24px;
    align-items: center;
    text-align: center;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .auth-brand-panel img {
    margin-bottom: 16px;
  }

  .auth-brand-features {
    display: none;
  }

  .auth-form-panel {
    padding: 24px 16px 32px;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1040;
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;
    width: min(280px, 86vw);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }

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

  .sidebar-collapse-btn {
    display: none;
  }

  .main-content {
    max-width: 100vw;
    padding: 68px 16px 20px;
  }

  .app-shell.sidebar-collapsed .sidebar {
    width: min(280px, 86vw);
  }

  .app-shell.sidebar-collapsed .sidebar-logo,
  .app-shell.sidebar-collapsed .sidebar-user,
  .app-shell.sidebar-collapsed .sidebar-group-title,
  .app-shell.sidebar-collapsed .sidebar-logout-btn {
    display: block;
  }

  .app-shell.sidebar-collapsed .main-content {
    max-width: 100vw;
  }

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

  .filters-row .form-group {
    min-width: 0;
    width: 100%;
  }

  .mirror-info-grid {
    grid-template-columns: 1fr;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .mirror-table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
    -webkit-overflow-scrolling: touch;
  }

  .mirror-table-wrap table {
    min-width: 720px;
    font-size: 0.78rem;
  }

  .mirror-table-wrap th,
  .mirror-table-wrap td {
    padding: 8px 6px;
    white-space: nowrap;
  }
}
