:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --danger: #dc2626;
  --border: #e5e7eb;
  --sidebar: #111827;
  --shadow: 0 10px 30px rgba(0,0,0,0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.login-page {
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 18% 16%, rgba(245,158,11,0.24), transparent 34%),
    linear-gradient(135deg, #111827, #1f2937);
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.62);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(17, 24, 39, 0.28);
  padding: 34px 32px 30px;
}

.login-logo, .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-logo {
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  text-align: center;
}

.logo-box {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--primary);
  color: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
}

.brand-logo-img {
  width: 98px;
  height: auto;
  display: block;
  background: #ffffff;
  border-radius: 8px;
  padding: 6px;
}

.brand-logo-img-login {
  width: 176px;
  padding: 10px;
}

h1, h2, h3 { margin: 0; }

.login-card h1 {
  font-size: 26px;
  line-height: 1.15;
}

.login-card p {
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.45;
}

.login-footer {
  width: 100%;
  max-width: 460px;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.18);
}

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

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--text);
  font-size: 17px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover {
  border-color: var(--primary);
  background: #fef3c7;
}

.password-toggle:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.18);
  outline: none;
}

.password-toggle.is-visible::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-35deg);
}

button, .btn {
  border: none;
  cursor: pointer;
  border-radius: 12px;
  padding: 13px 16px;
  font-weight: bold;
  font-size: 15px;
  transition: 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: #111827;
}

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

.btn-secondary {
  background: #111827;
  color: #fff;
}

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

.btn-muted {
  background: #e5e7eb;
  color: #111827;
  cursor: not-allowed;
}

.btn-full { width: 100%; }

.btn-small {
  padding: 9px 12px;
  font-size: 13px;
}

.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.success {
  background: #dcfce7;
  color: #166534;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
}

.demo-info {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  line-height: 1.5;
}

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

body.sidebar-collapsed .app {
  grid-template-columns: 82px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
  overflow-y: auto;
}

.brand {
  margin-bottom: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .logo-box {
  width: 42px;
  height: 42px;
}

.brand-title {
  font-weight: bold;
  font-size: 17px;
}

.brand-subtitle {
  font-size: 12px;
  color: #9ca3af;
}

.sidebar-toggle {
  position: absolute;
  right: 0;
  bottom: 18px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 19px;
  line-height: 1;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  background: rgba(255,255,255,0.16);
  outline: none;
}

body.sidebar-collapsed .sidebar {
  padding: 18px 12px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
  margin-bottom: 18px;
  padding-bottom: 48px;
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-link span:not(.nav-icon) {
  display: none;
}

body.sidebar-collapsed .brand-logo-img {
  width: 54px;
  padding: 4px;
}

body.sidebar-collapsed .sidebar-toggle {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

body.sidebar-collapsed .nav {
  gap: 12px;
}

body.sidebar-collapsed .nav-link {
  grid-template-columns: 1fr;
  justify-items: center;
  min-height: 48px;
  padding: 6px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  min-height: 0;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.nav-section-bottom {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.nav-label {
  padding: 0 10px;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-link {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #d1d5db;
  text-decoration: none;
  text-align: left;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
  outline: none;
}

.nav-link.active {
  border-color: rgba(245,158,11,0.42);
  background: rgba(245,158,11,0.14);
  color: #ffffff;
}

.nav-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
}

.nav-link.active .nav-icon {
  background: var(--primary);
  color: #111827;
}

.nav-link strong,
.nav-link em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link strong {
  font-size: 14px;
}

.nav-link em {
  margin-top: 3px;
  color: #9ca3af;
  font-size: 11px;
  font-style: normal;
  font-weight: 400;
}

.nav-link.active em,
.nav-link:hover em,
.nav-link:focus-visible em {
  color: #e5e7eb;
}

.nav-button {
  font-family: inherit;
  cursor: pointer;
}

.nav-link-danger:hover,
.nav-link-danger:focus-visible {
  border-color: rgba(220,38,38,0.42);
  background: rgba(220,38,38,0.16);
}

.nav-link-danger .nav-icon {
  background: rgba(220,38,38,0.22);
}

.main { padding: 28px; }

.topbar {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-info strong { font-size: 18px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.role-badge {
  display: inline-block;
  width: fit-content;
  background: #fef3c7;
  color: #92400e;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: bold;
}

.section-header { margin-bottom: 20px; }

.section-header h2 {
  font-size: 28px;
  margin-bottom: 6px;
}

.section-header p {
  color: var(--muted);
  margin: 0;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 18px;
}

.system-card, .card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.narrow-card {
  max-width: 560px;
}

.system-card {
  border: 1px solid transparent;
  min-height: 205px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.system-card:hover { border-color: var(--primary); }

.system-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.system-card h3 {
  font-size: 19px;
  margin-bottom: 8px;
}

.system-card p, .card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.locked { opacity: 0.42; }

.admin-panel {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
}

.employee-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.employee-btn {
  background: #f9fafb;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--border);
  width: 100%;
}

.employee-btn.active {
  background: #fef3c7;
  border-color: var(--primary);
}

.employee-btn strong,
.employee-btn span,
.employee-btn em {
  display: block;
}

.employee-btn span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.employee-btn em {
  margin-top: 6px;
  color: #92400e;
  font-size: 12px;
  font-style: normal;
  font-weight: bold;
}

.employee-btn.inactive {
  opacity: 0.62;
}

.stacked-form {
  margin-top: 18px;
}

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

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 6px 0 18px;
}

.checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 0;
}

.checkbox-item input {
  width: auto;
  margin-top: 2px;
}

.admin-edit-card {
  margin-top: 20px;
}

.delete-form {
  border-top: 1px solid var(--border);
  margin-top: 18px;
  padding-top: 18px;
}

button:disabled,
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.permissions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.permission-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f9fafb;
}

.permission-item input {
  width: auto;
  margin-top: 3px;
}

.permission-item strong {
  display: block;
  margin-bottom: 4px;
}

.permission-item span {
  font-size: 13px;
  color: var(--muted);
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.notice {
  padding: 14px 16px;
  border-radius: 14px;
  background: #eff6ff;
  color: #1e40af;
  margin-bottom: 18px;
  border: 1px solid #bfdbfe;
}

.admin-overlay[hidden] {
  display: none;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.admin-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.62);
}

.admin-overlay-panel {
  position: absolute;
  inset: 28px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}

.admin-overlay-close {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #111827;
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.admin-overlay-frame {
  width: 100%;
  height: 100%;
  border: 0;
  flex: 1;
  background: #fff;
}

.admin-overlay-active {
  overflow: hidden;
}

.scanner-active {
  overflow: hidden;
}

.scanner-overlay[hidden] {
  display: none;
}

.scanner-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 18px;
}

.scanner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.7);
}

.scanner-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.32);
}

.scanner-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.scanner-header strong {
  display: block;
  font-size: 18px;
}

.scanner-header span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.scanner-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.scanner-video-wrap {
  position: relative;
  margin: 16px 18px 0;
  overflow: hidden;
  border-radius: 10px;
  background: #111827;
  aspect-ratio: 4 / 3;
}

.scanner-video-wrap video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-frame {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(17, 24, 39, 0.28);
}

.scanner-status,
.scanner-meta,
.scanner-manual,
.scanner-actions {
  margin: 14px 18px 0;
}

.scanner-status {
  color: var(--muted);
  font-size: 14px;
}

.scanner-status.error {
  color: var(--danger);
  font-weight: bold;
}

.scanner-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 13px;
  color: var(--muted);
}

.scanner-meta strong {
  color: var(--text);
}

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

.scanner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 18px;
}

.version-update-active {
  overflow: hidden;
}

.version-update-overlay {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.76);
}

.version-update-panel {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.34);
}

.version-update-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.version-update-panel h2 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.15;
}

.version-update-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.version-update-info {
  margin: 0 0 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f9fafb;
}

.version-update-info strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

.version-update-info ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.version-update-info li + li {
  margin-top: 5px;
}

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

.version-update-actions .btn {
  flex: 1 1 160px;
}

.version-update-floating {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 3999;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.22);
}

.not-found-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(17,24,39,0.96), rgba(31,41,55,0.9)),
    radial-gradient(circle at 18% 12%, rgba(245,158,11,0.25), transparent 36%);
}

.not-found-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.not-found-hero {
  width: min(1120px, 100%);
  min-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.86fr);
  gap: 34px;
  align-items: center;
}

.not-found-brand {
  width: 154px;
  display: inline-flex;
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(0,0,0,0.22);
}

.not-found-brand img {
  width: 100%;
  height: auto;
  display: block;
}

.not-found-kicker {
  display: block;
  margin-top: 34px;
  color: var(--primary);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.not-found-copy h1 {
  max-width: 12ch;
  margin-top: 12px;
  color: #ffffff;
  font-size: 62px;
  line-height: 0.98;
}

.not-found-copy p {
  max-width: 560px;
  margin: 22px 0 0;
  color: #d1d5db;
  font-size: 18px;
  line-height: 1.55;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.not-found-path {
  width: min(560px, 100%);
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  color: #d1d5db;
  overflow-wrap: anywhere;
}

.not-found-path strong {
  color: #ffffff;
}

.not-found-visual {
  position: relative;
  min-height: 420px;
  display: grid;
  place-items: center;
}

.not-found-code {
  position: absolute;
  top: 0;
  right: 0;
  color: rgba(255,255,255,0.08);
  font-size: 156px;
  font-weight: 900;
  line-height: 1;
}

.not-found-panel {
  width: min(390px, 100%);
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: #111827;
  box-shadow: 0 28px 80px rgba(0,0,0,0.38);
  transform: rotate(-2deg);
}

.not-found-panel span {
  border-radius: 6px;
  background: linear-gradient(145deg, #1f2937, #374151);
  border: 1px solid rgba(245,158,11,0.22);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

.not-found-panel span:nth-child(5) {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
}

.not-found-status {
  position: absolute;
  left: 18px;
  bottom: 34px;
  min-width: 230px;
  padding: 16px 18px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0,0,0,0.24);
}

.not-found-status strong,
.not-found-status span {
  display: block;
}

.not-found-status span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.maintenance-overlay-body {
  background: #fff;
}

.maintenance-overlay-content {
  padding: 22px;
}

@media (max-width: 900px) {
  .login-page {
    align-items: stretch;
    padding: 18px;
  }
  .login-card {
    align-self: center;
    padding: 28px 20px 24px;
  }
  .brand-logo-img-login {
    width: 152px;
  }
  .login-card h1 {
    font-size: 23px;
  }
  .app { grid-template-columns: 1fr; }
  body.sidebar-collapsed .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .admin-panel { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-overlay-panel { inset: 10px; }
  .scanner-overlay { padding: 10px; }
  .scanner-panel { max-height: calc(100vh - 20px); }
  .scanner-manual { grid-template-columns: 1fr; }
  .not-found-shell { padding: 18px; }
  .not-found-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .not-found-copy h1 { font-size: 42px; }
  .not-found-copy p { font-size: 16px; }
  .not-found-visual {
    min-height: 300px;
    order: -1;
  }
  .not-found-code { font-size: 96px; }
  .not-found-panel { width: min(280px, 86vw); }
  .not-found-status {
    left: 0;
    bottom: 0;
  }
}
