:root {
  --bg: #f2ede4;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-2: rgba(255, 255, 255, 0.68);
  --surface-dark: #18212f;
  --text: #202635;
  --muted: #67758a;
  --line: rgba(32, 38, 53, 0.1);
  --accent: #e6672d;
  --accent-2: #f4952f;
  --success: #178860;
  --warning: #cc7b15;
  --danger: #d24962;
  --info: #2b66db;
  --shadow: 0 18px 45px rgba(20, 27, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(230, 103, 45, 0.18), transparent 26%),
    radial-gradient(circle at 85% 12%, rgba(43, 102, 219, 0.12), transparent 22%),
    linear-gradient(180deg, #f7f1e9 0%, #eee7dd 100%);
  color: var(--text);
  font-family:
    "Be Vietnam Pro",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

body {
  padding: 24px;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  min-height: 50px;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

.login-card,
.sidebar,
.hero,
.panel {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.login-card {
  width: min(460px, 100%);
  padding: 36px;
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255, 249, 241, 0.96), rgba(255, 255, 255, 0.78));
  box-shadow: var(--shadow);
}

.login-card h1,
.brand h1,
.hero h2,
.panel h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
}

.login-copy,
.hero-copy,
.login-hint {
  color: var(--muted);
  line-height: 1.7;
}

.login-form,
.inline-form {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.login-form label,
.inline-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.login-form input,
.inline-form input,
.inline-form select {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.9);
  appearance: none;
  -webkit-appearance: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  min-height: calc(100vh - 48px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.sidebar {
  background: rgba(24, 33, 47, 0.95);
  border-radius: 28px;
  padding: 28px;
  color: #f3eee7;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: var(--shadow);
}

.sidebar .eyebrow {
  color: rgba(243, 238, 231, 0.62);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  color: rgba(243, 238, 231, 0.9);
}

.nav-link:hover,
.nav-link.is-active {
  background: linear-gradient(135deg, rgba(230, 103, 45, 0.28), rgba(244, 149, 47, 0.2));
  color: #fff;
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  line-height: 1.6;
}

.sidebar-action {
  min-height: 48px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-action-light {
  background: rgba(255, 255, 255, 0.98) !important;
  color: var(--text) !important;
  box-shadow: 0 10px 20px rgba(10, 16, 24, 0.18);
}

.sidebar-card .primary-button.sidebar-action {
  color: #fff !important;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  padding: 32px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 249, 241, 0.96), rgba(255, 255, 255, 0.76));
  box-shadow: var(--shadow);
}

.hero h2 {
  max-width: 13ch;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.04;
}

.hero-actions,
.calendar-actions,
.form-actions,
.chip-actions,
.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.chip-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 24px rgba(230, 103, 45, 0.24);
}

.secondary-button,
.chip-button {
  background: rgba(32, 38, 53, 0.06);
  color: var(--text);
}

.full {
  width: 100%;
}

.section {
  display: none;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.section.is-visible {
  display: flex;
}

.stats-grid,
.panel-grid,
.department-grid,
.policy-grid,
.members-grid {
  display: grid;
  gap: 18px;
  min-width: 0;
}

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

.panel-grid.two-col,
.department-grid,
.policy-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-grid.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.attendance-capture,
.attendance-side,
.status-stack {
  display: grid;
  gap: 14px;
}

.camera-card {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(32, 38, 53, 0.08);
  min-height: 320px;
}

#camera-stream {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  background: #111823;
}

.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.status-box {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  padding: 14px;
  line-height: 1.6;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-heading,
.section-head,
.member-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  min-width: 0;
  flex-wrap: wrap;
}

.stat-card,
.person-card,
.alert-card,
.request-card,
.schedule-card,
.rule-card,
.payroll-card,
.department-card,
.policy-card,
.office-card,
.member-card,
.permission-card,
.email-card,
.empty-card,
.payroll-self-card {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  margin: 12px 0 8px;
}

.people-list,
.alert-list,
.request-list,
.schedule-summary,
.rule-list,
.timeline,
.payroll-rules,
.permission-list,
.email-log {
  display: grid;
  gap: 14px;
}

.person-card,
.request-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.person-button {
  width: 100%;
  text-align: left;
}

.person-meta,
.request-meta,
.member-body {
  display: grid;
  gap: 4px;
}

.person-name,
.request-title {
  font-weight: 700;
}

.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  background: rgba(32, 38, 53, 0.06);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-green {
  background: var(--success);
}

.dot-orange {
  background: var(--warning);
}

.dot-red {
  background: var(--danger);
}

.alert-card {
  border-left: 5px solid var(--danger);
}

.alert-card.warning {
  border-left-color: var(--warning);
}

.badge.pending {
  background: rgba(204, 123, 21, 0.12);
  color: var(--warning);
}

.badge.review {
  background: rgba(43, 102, 219, 0.12);
  color: var(--info);
}

.badge.approved {
  background: rgba(23, 136, 96, 0.12);
  color: var(--success);
}

.reject-note {
  color: var(--danger);
}

.inline-form.wide {
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  align-items: end;
}

.schedule-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  width: 100%;
  min-width: 0;
}

.schedule-form > * {
  min-width: 0;
}

.schedule-form .wide-field {
  grid-column: span 2;
}

.schedule-form-actions {
  grid-column: 1 / -1;
}

.inline-form.two-rows {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-field {
  grid-column: 1 / -1;
}

.timeline-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 6px;
}

.timeline-calendar {
  display: grid;
  gap: 12px;
  min-width: max-content;
}

.timeline-row {
  display: grid;
  gap: 12px;
  min-width: max-content;
}

.timeline-head,
.timeline-slot,
.timeline-cell {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  padding: 14px;
  min-height: 110px;
}

.timeline-head {
  min-height: auto;
  background: rgba(32, 38, 53, 0.05);
}

.timeline-slot {
  position: sticky;
  left: 0;
  z-index: 1;
  background: linear-gradient(135deg, rgba(230, 103, 45, 0.08), rgba(244, 149, 47, 0.1));
  min-height: 110px;
}

.slot-column {
  position: sticky;
  left: 0;
  z-index: 2;
}

.timeline-cell {
  display: grid;
  gap: 10px;
  align-content: start;
}

.cell-count {
  font-size: 0.82rem;
  color: var(--muted);
}

.cell-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.shift-chip {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(230, 103, 45, 0.12), rgba(244, 149, 47, 0.14));
  border: 1px solid rgba(230, 103, 45, 0.12);
}

.shift-chip.online {
  background: linear-gradient(135deg, rgba(43, 102, 219, 0.12), rgba(43, 102, 219, 0.16));
  border-color: rgba(43, 102, 219, 0.12);
}

.shift-chip-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.icon-button {
  border: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(32, 38, 53, 0.07);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 0.88rem;
}

.member-card,
.permission-card,
.email-card,
.payroll-self-card {
  line-height: 1.6;
}

.compact {
  gap: 8px;
}

.request-card.compact,
.member-card.compact,
.email-card.compact,
.payroll-self-card.compact,
.schedule-card.compact,
.department-card.compact,
.office-card.compact,
.payroll-card.compact {
  padding: 14px;
}

.request-meta.compact,
.member-body.compact {
  gap: 2px;
}

.face-thumb {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.face-preview {
  width: 100%;
  max-width: 220px;
  border-radius: 18px;
  border: 1px solid var(--line);
  margin-top: 8px;
}

.permission-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.permission-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.permission-copy strong,
.permission-copy small {
  display: block;
}

.permission-copy small {
  color: var(--muted);
}

.permission-input {
  width: 20px;
  height: 20px;
}

.permission-toggle.is-readonly {
  opacity: 0.72;
}

.member-face-card-body {
  display: grid;
  gap: 12px;
}

#member-face-preview {
  max-width: 280px;
}

.my-payroll .big {
  font-size: 1.8rem;
  margin: 10px 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 20;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 18, 28, 0.42);
}

.modal-card {
  position: relative;
  width: min(980px, calc(100vw - 64px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--surface);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  padding: 22px;
  box-shadow: var(--shadow);
}

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

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

.payroll-weekday {
  padding: 8px 10px;
  font-size: 0.84rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.payroll-day {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 12px;
  min-height: 130px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.payroll-day.is-empty {
  background: transparent;
  border-style: dashed;
  min-height: 90px;
}

.payroll-day strong {
  font-size: 0.95rem;
}

.payroll-shift-tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(43, 102, 219, 0.1);
  color: var(--text);
  font-size: 0.82rem;
}

.office-actions {
  margin-top: 10px;
}

.payroll-summary-card {
  display: grid;
  gap: 8px;
}

.payroll-detail-link {
  color: var(--info);
  cursor: pointer;
}

.payroll-detail-link:hover {
  text-decoration: underline;
}

.storage-metrics {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.date-inline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.flash {
  position: fixed;
  right: 24px;
  bottom: 24px;
  color: #fff;
  background: rgba(32, 38, 53, 0.92);
  padding: 14px 18px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 180ms ease;
}

.flash.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .inline-form.wide {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 1080px) {
  body {
    padding: 16px;
  }

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

  .hero {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-grid.two-col,
  .panel-grid.three-col,
  .department-grid,
  .policy-grid,
  .members-grid,
  .inline-form.two-rows,
  .modal-form,
  .payroll-calendar {
    grid-template-columns: 1fr;
  }

  .timeline-calendar {
    min-width: 860px;
  }

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

@media (max-width: 760px) {
  .stats-grid,
  .inline-form.wide {
    grid-template-columns: 1fr;
  }

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

  .sidebar,
  .hero,
  .panel,
  .login-card {
    border-radius: 22px;
  }
}
