:root {
  /* ===== WARM TERRACOTTA / SUNSET PALETTE ===== */
  --primary: #2b2522; /* Deep warm charcoal */
  --primary-light: #4a3d37; /* Lighter warm brown */
  --primary-dark: #14110f; /* Almost black-brown */

  --accent: #e5734a; /* Vibrant terracotta / sunset orange */
  --accent-light: #fdf0ea; /* Warm peach/cream background */

  --green: #3d8c5a; /* Muted forest green */
  --green-bg: #edf5ef; /* Soft green background */

  --yellow: #d4a02b; /* Warm golden yellow */
  --yellow-bg: #fdf7ec; /* Soft yellow background */

  --red: #c94a3d; /* Brick red */
  --red-bg: #fbeeec; /* Soft red background */

  /* Warm Grayscale */
  --gray-50: #faf7f5;
  --gray-100: #f2edea;
  --gray-200: #e5ded9;
  --gray-300: #d2c9c2;
  --gray-400: #b5a99f;
  --gray-500: #94887e;
  --gray-600: #75695f;
  --gray-700: #534b44;
  --gray-800: #3a322d;
  --gray-900: #2b2522;

  --shadow-sm:
    0 1px 3px rgba(20, 17, 15, 0.08), 0 1px 2px rgba(20, 17, 15, 0.06);
  --shadow-md: 0 4px 12px rgba(20, 17, 15, 0.12);
  --shadow-lg: 0 8px 30px rgba(20, 17, 15, 0.18);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.25s ease;
  --font: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --signature-color: #1a1a2e;
  --img-max-width: 1200px;
  --img-max-height: 630px;
  --bottom-nav-height: 62px;
  --header-height: 56px;
  --img-mobile-width: 360px;
  --img-mobile-height: 240px;
  --img-thumb-size: 90px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--bottom-nav-height);
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--gray-100);
}
::-webkit-scrollbar-thumb {
  background: var(--gray-400);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gray-500);
}

@media (min-width: 901px) {
  body {
    padding-bottom: 0;
  }
}

/* ============================================================
           APP HEADER
           ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 1rem;
  background: var(--primary-dark);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
}
.app-header .brand i {
  font-size: 1.3rem;
  color: var(--accent);
}
.app-header .brand small {
  font-weight: 400;
  font-size: 0.6rem;
  opacity: 0.6;
  display: block;
  line-height: 1;
}
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-header .header-actions .menu-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-header .header-actions .menu-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}
.app-header .header-actions .menu-btn:active {
  transform: scale(0.92);
}

@media (min-width: 901px) {
  .app-header {
    display: none !important;
  }
  .sidebar {
    transform: translateX(0) !important;
    width: 240px !important;
    position: sticky !important;
    top: 0;
    height: 100vh !important;
    z-index: 100 !important;
    flex-shrink: 0;
  }
  .sidebar-overlay {
    display: none !important;
  }
  body {
    padding-bottom: 0;
  }
  .app-wrapper {
    flex-direction: row;
  }
  .bottom-nav {
    display: none !important;
  }
}

/* ============================================================
           BUTTONS & BADGES
           ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  justify-content: center;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover {
  background: #d45f35;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover {
  background: #2f7348;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover {
  background: #b03a2e;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-outline:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}
.btn-sm {
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
}
.btn-xs {
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  border-radius: 6px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-green {
  background: var(--green-bg);
  color: var(--green);
}
.badge-yellow {
  background: var(--yellow-bg);
  color: #a87d1e;
}
.badge-red {
  background: var(--red-bg);
  color: var(--red);
}
.badge-gray {
  background: var(--gray-200);
  color: var(--gray-700);
}
.badge-blue {
  background: var(--accent-light);
  color: var(--accent);
}
.badge-purple {
  background: #ede7f6;
  color: #5e35b1;
}

/* ============================================================
           LAYOUT – APP SHELL
           ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  flex: 1;
}

/* ---- LOGIN OVERLAY ---- */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(20, 17, 15, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: opacity 0.5s ease;
}
#loginOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}
#loginOverlay .login-box {
  background: #fff;
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  padding: 2rem 2.25rem;
  box-shadow: var(--shadow-lg);
  max-height: 95vh;
  overflow-y: auto;
  transform: translateY(0);
  transition: transform 0.4s ease;
}
#loginOverlay.hidden .login-box {
  transform: translateY(20px);
}
#loginOverlay .login-box .login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}
#loginOverlay .login-box .login-brand i {
  font-size: 1.8rem;
  color: var(--accent);
}
#loginOverlay .login-box .login-brand small {
  font-weight: 400;
  font-size: 0.65rem;
  opacity: 0.6;
  display: block;
}

.login-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  margin-bottom: 1.25rem;
}
.login-tabs .tab-btn {
  flex: 1;
  padding: 0.5rem 0.8rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
  font-family: var(--font);
  background: transparent;
  color: var(--gray-600);
  cursor: pointer;
  transition: var(--transition);
}
.login-tabs .tab-btn.active {
  background: #fff;
  color: var(--gray-900);
  box-shadow: var(--shadow-sm);
}
.login-tabs .tab-btn:hover:not(.active) {
  color: var(--gray-800);
}
.login-tabs .tab-btn i {
  margin-right: 0.4rem;
}

.login-panel {
  display: block;
}
.login-panel.hidden {
  display: none;
}

.guard-verification-area {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem 1.25rem;
  border: 2px solid var(--gray-200);
  margin-bottom: 0.5rem;
}
.guard-verification-area .area-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.guard-verification-area .area-title i {
  color: var(--accent);
}

.signature-wrapper {
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: #fff;
  position: relative;
  transition: var(--transition);
  touch-action: none;
}
.signature-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 115, 74, 0.2);
}
.signature-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  border-radius: var(--radius-sm);
  cursor:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="30" viewBox="0 0 24 30"><circle cx="12" cy="12" r="6" fill="none" stroke="%23e5734a" stroke-width="2"/><circle cx="12" cy="12" r="2" fill="%23e5734a"/></svg>')
      12 12,
    crosshair;
  touch-action: none;
}
.signature-wrapper .sig-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem 0.5rem 0.75rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.signature-wrapper .sig-actions .btn-xs {
  font-size: 0.65rem;
  padding: 0.15rem 0.6rem;
}
.signature-wrapper .sig-status {
  font-size: 0.7rem;
  color: var(--gray-500);
  padding: 0.3rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.signature-wrapper .sig-status.signed {
  color: var(--green);
}
.signature-wrapper .sig-status i {
  font-size: 0.8rem;
}

/* ============================================================
           SIDEBAR
           ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--primary-dark);
  color: #fff;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 300;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}
.sidebar.open {
  transform: translateX(0);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 1.5rem;
}
.sidebar-brand i {
  font-size: 1.6rem;
  color: var(--accent);
}
.sidebar-brand span {
  color: #fff;
}
.sidebar-brand small {
  font-weight: 400;
  font-size: 0.65rem;
  opacity: 0.6;
  display: block;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.sidebar-nav .nav-item i {
  width: 1.25rem;
  font-size: 1rem;
}
.sidebar-nav .nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.sidebar-nav .nav-item.active {
  background: rgba(229, 115, 74, 0.25);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-nav .nav-item .badge {
  margin-left: auto;
  font-size: 0.6rem;
  padding: 0.1rem 0.5rem;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}
.sidebar-footer .user-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  font-size: 0.8rem;
  flex-wrap: wrap;
}
.sidebar-footer .user-row i {
  font-size: 1.2rem;
  opacity: 0.7;
}
.sidebar-footer .user-row .role-tag {
  font-size: 0.6rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.6rem;
  border-radius: 12px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
}
.sidebar-footer .user-row .user-name-display {
  font-weight: 600;
  color: #fff;
}

/* ---- Sidebar footer actions (Change Password + Logout) ---- */
.sidebar-footer .footer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-footer .footer-actions .btn {
  font-size: 0.7rem;
  padding: 0.25rem 0.7rem;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
  background: transparent;
}
.sidebar-footer .footer-actions .btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.sidebar-footer .footer-actions .btn-change-pw {
  color: var(--accent);
  border-color: rgba(229, 115, 74, 0.3);
}
.sidebar-footer .footer-actions .btn-change-pw:hover {
  background: rgba(229, 115, 74, 0.15);
  color: #fff;
}
.sidebar-footer .footer-actions .btn-logout {
  color: rgba(255, 255, 255, 0.5);
}
.sidebar-footer .footer-actions .btn-logout:hover {
  background: rgba(201, 74, 61, 0.15);
  color: #fff;
  border-color: rgba(201, 74, 61, 0.3);
}

/* sidebar overlay */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* ============================================================
           MAIN CONTENT
           ============================================================ */
.main {
  flex: 1;
  padding: 1.5rem 2rem 2rem;
  overflow-y: auto;
  min-width: 0;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}
.page-header h1 small {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--gray-500);
  display: block;
  margin-top: 0.1rem;
}
.page-header .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ============================================================
           CARDS & FORMS
           ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-800);
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
}
.form-group label .required {
  color: var(--red);
  margin-left: 0.2rem;
}
.form-control {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: #fff;
  transition: var(--transition);
  color: var(--gray-900);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 115, 74, 0.2);
}
.form-control:disabled,
.form-control[readonly] {
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: not-allowed;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.form-hint {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 0.2rem;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.5rem;
  padding: 0 0.5rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table th {
  text-align: left;
  padding: 0.7rem 0.6rem;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
table tr:hover td {
  background: var(--gray-50);
}

.container-card {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  transition: var(--transition);
}
.container-card:hover {
  border-color: var(--gray-400);
}
.container-card .left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.container-card .left .num {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gray-900);
}
.container-card .left .detail {
  font-size: 0.75rem;
  color: var(--gray-500);
}
.container-card .right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pending-card {
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
}

.verification-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
}
.verification-badge.pending {
  background: var(--yellow-bg);
  color: #a87d1e;
}
.verification-badge.verified {
  background: var(--green-bg);
  color: var(--green);
}

/* ============================================================
           PHOTO UPLOAD
           ============================================================ */
.photo-upload-area {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: var(--gray-50);
  position: relative;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.photo-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.photo-upload-area .upload-icon {
  font-size: 2.5rem;
  color: var(--gray-400);
}
.photo-upload-area .upload-text {
  font-weight: 500;
  color: var(--gray-600);
}
.photo-upload-area .upload-hint {
  font-size: 0.75rem;
  color: var(--gray-500);
}
.photo-upload-area .upload-progress {
  width: 100%;
  max-width: 200px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
  display: none;
}
.photo-upload-area .upload-progress .progress-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease;
}
.photo-upload-area .upload-progress.active {
  display: block;
}

.photo-preview-container {
  display: none;
  margin-top: 0.75rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  position: relative;
  max-width: var(--img-max-width);
  max-height: var(--img-max-height);
  width: 100%;
  aspect-ratio: 1200 / 630;
  background: var(--gray-100);
}
.photo-preview-container.active {
  display: block;
}
.photo-preview-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--gray-50);
}
.photo-preview-container .preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.photo-preview-container .preview-actions .btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(0, 0, 0, 0.4);
}
.photo-preview-container .preview-actions .btn:hover {
  background: rgba(255, 255, 255, 0.15);
}
.photo-preview-container .preview-actions .btn-danger {
  background: rgba(201, 74, 61, 0.7);
  border-color: var(--red);
}
.photo-preview-container .preview-actions .btn-danger:hover {
  background: var(--red);
}
.photo-preview-container .preview-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.6rem;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-weight: 500;
  z-index: 2;
}

.photo-url-display {
  font-size: 0.7rem;
  color: var(--gray-500);
  margin-top: 0.3rem;
  word-break: break-all;
  font-family: monospace;
  background: var(--gray-100);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  display: none;
}
.photo-url-display.active {
  display: block;
}

/* ============================================================
           ALERT / TOAST
           ============================================================ */
.alert-banner {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  font-size: 0.9rem;
  border-left: 4px solid transparent;
}
.alert-banner i {
  font-size: 1.2rem;
}
.alert-banner.danger {
  background: var(--red-bg);
  border-left-color: var(--red);
  color: #a51d15;
}
.alert-banner.warning {
  background: var(--yellow-bg);
  border-left-color: var(--yellow);
  color: #8d6e00;
}
.alert-banner.success {
  background: var(--green-bg);
  border-left-color: var(--green);
  color: #0a6e3a;
}
.alert-banner.info {
  background: var(--accent-light);
  border-left-color: var(--accent);
  color: #7a3d1a;
}

.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 1rem);
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
  width: calc(100% - 2rem);
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--accent);
}
.toast.success {
  border-left-color: var(--green);
}
.toast.warning {
  border-left-color: var(--yellow);
}
.toast.danger {
  border-left-color: var(--red);
}
.toast.info {
  border-left-color: var(--accent);
}
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.loading-spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid var(--gray-300);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}
.text-muted {
  color: var(--gray-500);
  font-size: 0.8rem;
}
.text-center {
  text-align: center;
}
.w-full {
  width: 100%;
}
.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.flex {
  display: flex;
}
.flex-center {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gap-1 {
  gap: 0.5rem;
}
.gap-2 {
  gap: 1rem;
}
.wrap {
  flex-wrap: wrap;
}

.flash-red {
  animation: flashRed 1.2s infinite;
}
@keyframes flashRed {
  0%,
  100% {
    color: var(--red);
    opacity: 1;
  }
  50% {
    color: #ff6b6b;
    opacity: 0.4;
  }
}

/* ============================================================
           MONITORING PAGE
           ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue {
  background: var(--accent-light);
  color: var(--accent);
}
.stat-card .stat-icon.green {
  background: var(--green-bg);
  color: var(--green);
}
.stat-card .stat-icon.yellow {
  background: var(--yellow-bg);
  color: #a87d1e;
}
.stat-card .stat-icon.red {
  background: var(--red-bg);
  color: var(--red);
}

.stat-card .stat-info h4 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gray-900);
  margin: 0;
}
.stat-card .stat-info p {
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0.1rem 0 0;
}

.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}
.bar-track {
  flex: 1;
  height: 6px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.bar-fill.green {
  background: var(--green);
}
.bar-fill.yellow {
  background: var(--yellow);
}
.bar-fill.red {
  background: var(--red);
}
.bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-600);
  min-width: 36px;
  text-align: right;
}

/* ============================================================
           ANALYSIS PAGE
           ============================================================ */
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  text-align: center;
  transition: var(--transition);
}
.metric-box:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-box .value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}
.metric-box .value.green {
  color: var(--green);
}
.metric-box .value.red {
  color: var(--red);
}
.metric-box .value.blue {
  color: var(--accent);
}
.metric-box .value.yellow {
  color: #a87d1e;
}
.metric-box .label {
  font-size: 0.7rem;
  color: var(--gray-500);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.2rem;
}

/* ============================================================
           VIEW: SUMMARY IFRAME
           ============================================================ */
#view-summary {
  height: 100%;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#view-summary iframe {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: none;
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
@media (max-width: 640px) {
  #view-summary iframe {
    min-height: 60vh;
  }
}

.receive-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.receive-stats .stat-chip {
  background: var(--gray-50);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  text-align: center;
}
.receive-stats .stat-chip .num {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gray-900);
}
.receive-stats .stat-chip .lbl {
  font-size: 0.65rem;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.receive-stats .stat-chip .num.green {
  color: var(--green);
}
.receive-stats .stat-chip .num.red {
  color: var(--red);
}
.receive-stats .stat-chip .num.yellow {
  color: #a87d1e;
}
.receive-stats .stat-chip .num.blue {
  color: var(--accent);
}

.receive-pending-item {
  border-left: 4px solid var(--yellow);
  background: #fffdf7;
}

/* ============================================================
           BOTTOM NAV
           ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: 150;
  background: var(--primary-dark);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav .nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.5);
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  font-family: var(--font);
  padding: 0.2rem 0.1rem;
  gap: 0.1rem;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav .nav-tab i {
  font-size: 1.15rem;
  transition: var(--transition);
}
.bottom-nav .nav-tab span {
  font-size: 0.5rem;
  letter-spacing: 0.02em;
  font-weight: 500;
}
.bottom-nav .nav-tab .tab-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.25rem;
  font-size: 0.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  line-height: 1.3;
}
.bottom-nav .nav-tab.active {
  color: #fff;
}
.bottom-nav .nav-tab.active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2.5px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
}
.bottom-nav .nav-tab:active {
  transform: scale(0.92);
}
.bottom-nav .nav-tab .tab-badge.green-badge {
  background: var(--green);
}
.bottom-nav .nav-tab .tab-badge.yellow-badge {
  background: var(--yellow);
  color: #000;
}

@media (min-width: 901px) {
  .bottom-nav {
    display: none !important;
  }
}

/* ============================================================
           MODAL — CHANGE PASSWORD
           ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 5000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-overlay .modal-box {
  background: #fff;
  border-radius: var(--radius);
  max-width: 440px;
  width: 100%;
  padding: 2rem 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.3s ease;
  max-height: 95vh;
  overflow-y: auto;
}
.modal-overlay.active .modal-box {
  transform: scale(1) translateY(0);
}
.modal-box .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
}
.modal-box .modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.modal-box .modal-header h2 i {
  color: var(--accent);
}
.modal-box .modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: var(--transition);
  line-height: 1;
}
.modal-box .modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-700);
}
.modal-box .form-group {
  margin-bottom: 1rem;
}
.modal-box .form-group label {
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--gray-700);
  display: block;
  margin-bottom: 0.25rem;
}
.modal-box .form-group .form-control {
  font-size: 0.9rem;
}
.modal-box .form-group .form-hint {
  font-size: 0.65rem;
  color: var(--gray-500);
  margin-top: 0.2rem;
}
.modal-box .modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}
.modal-box .modal-actions .btn {
  flex: 1;
}
.modal-box .modal-actions .btn-cancel {
  background: var(--gray-100);
  color: var(--gray-700);
}
.modal-box .modal-actions .btn-cancel:hover {
  background: var(--gray-200);
}
.modal-box .modal-actions .btn-change {
  background: var(--accent);
  color: #fff;
}
.modal-box .modal-actions .btn-change:hover {
  background: #d45f35;
}
.modal-box .modal-actions .btn-change:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.modal-box .pw-strength {
  font-size: 0.7rem;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.modal-box .pw-strength .strength-bar {
  flex: 1;
  height: 3px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}
.modal-box .pw-strength .strength-bar .fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.modal-box .pw-strength .strength-label {
  font-size: 0.65rem;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}

/* ============================================================
           RESPONSIVE TWEAKS
           ============================================================ */
@media (max-width: 900px) {
  .main {
    padding: 1rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }
  .page-header .actions {
    justify-content: stretch;
  }
  .page-header .actions .btn {
    flex: 1;
  }
  #loginOverlay .login-box {
    padding: 1.5rem;
    margin: 0.5rem;
  }
  .photo-preview-container {
    max-width: var(--img-mobile-width);
    max-height: var(--img-mobile-height);
    aspect-ratio: 360 / 240;
  }
  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .stat-card {
    padding: 0.9rem 1rem;
    flex-direction: column;
    text-align: center;
  }
  .stat-card .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
  .stat-card .stat-info h4 {
    font-size: 1.2rem;
  }
  .metric-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }
  .metric-box {
    padding: 0.9rem 0.5rem;
  }
  .metric-box .value {
    font-size: 1.2rem;
  }
  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 0.75rem);
    right: 0.75rem;
    max-width: calc(100% - 1.5rem);
  }
  .container-card .left {
    gap: 0.4rem;
  }
  .container-card .left .num {
    font-size: 0.8rem;
  }
  .container-card .left .detail {
    font-size: 0.65rem;
  }
  .container-card .right .badge {
    font-size: 0.6rem;
    padding: 0.1rem 0.5rem;
  }
  .btn-sm {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
  }
  .btn-xs {
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
  }
  table {
    font-size: 0.75rem;
  }
  table th,
  table td {
    padding: 0.4rem 0.3rem;
  }
  #loginOverlay .login-box {
    padding: 1rem;
  }
  .app-header .brand {
    font-size: 0.85rem;
  }
  .app-header .brand i {
    font-size: 1.1rem;
  }
  .app-header .header-actions .menu-btn {
    font-size: 1.2rem;
    padding: 0.2rem 0.3rem;
  }
  .modal-overlay .modal-box {
    padding: 1.5rem 1.25rem;
    margin: 0.5rem;
  }
}

@media (max-width: 480px) {
  .main {
    padding: 0.75rem;
  }
  .card {
    padding: 0.9rem;
  }
  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .stat-card {
    padding: 0.6rem 0.5rem;
    border-radius: var(--radius-sm);
  }
  .stat-card .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
    border-radius: 8px;
  }
  .stat-card .stat-info h4 {
    font-size: 1rem;
  }
  .stat-card .stat-info p {
    font-size: 0.6rem;
  }
  .metric-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
  }
  .metric-box {
    padding: 0.6rem 0.3rem;
    border-radius: var(--radius-sm);
  }
  .metric-box .value {
    font-size: 1rem;
  }
  .metric-box .label {
    font-size: 0.6rem;
  }
  .sidebar {
    width: 260px;
  }
  .page-header h1 {
    font-size: 1.2rem;
  }
  .page-header h1 small {
    font-size: 0.75rem;
  }
  .bottom-nav .nav-tab i {
    font-size: 1rem;
  }
  .bottom-nav .nav-tab span {
    font-size: 0.45rem;
  }
  .bottom-nav .nav-tab .tab-badge {
    font-size: 0.45rem;
    min-width: 14px;
    padding: 0.05rem 0.3rem;
  }
  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 0.5rem);
    right: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  .toast {
    font-size: 0.75rem;
    padding: 0.6rem 1rem;
  }
  .modal-overlay .modal-box {
    padding: 1.25rem 1rem;
  }
  .modal-box .modal-header h2 {
    font-size: 1rem;
  }
  .modal-box .modal-actions {
    flex-direction: column;
  }
  .modal-box .modal-actions .btn {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }
  .stat-card {
    padding: 0.4rem 0.3rem;
  }
  .stat-card .stat-icon {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }
  .stat-card .stat-info h4 {
    font-size: 0.85rem;
  }
  .metric-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }
  .metric-box {
    padding: 0.4rem 0.2rem;
  }
  .metric-box .value {
    font-size: 0.85rem;
  }
  .bottom-nav {
    height: 54px;
  }
  .bottom-nav .nav-tab i {
    font-size: 0.85rem;
  }
  .bottom-nav .nav-tab span {
    font-size: 0.4rem;
  }
  .app-header {
    height: 48px;
    padding: 0 0.6rem;
  }
  .app-header .brand {
    font-size: 0.75rem;
  }
  .app-header .brand i {
    font-size: 0.95rem;
  }
  .app-header .header-actions .menu-btn {
    font-size: 1rem;
  }
}

/* ============================================================
           MOBILE DISPLAY FIX
           ============================================================ */
@media (max-width: 900px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
    padding: 0;
  }
  body {
    display: flex;
    flex-direction: column;
  }
  .app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    flex: 0 0 auto;
  }
  .app-header {
    flex-shrink: 0;
  }
  .main {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 0.75rem calc(var(--bottom-nav-height) + 0.75rem);
  }
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    flex-shrink: 0;
  }
  .main .card {
    padding: 0.9rem;
  }
  .main .page-header {
    margin-bottom: 0.75rem;
  }
  .main .page-header h1 {
    font-size: 1.1rem;
  }
  .main .form-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .main .table-wrap {
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
  }
}
