/* Global Reset & Typography */
:root {
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --secondary: #0d9488;
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --fifo-green: #dcfce7;
  --fifo-green-dark: #15803d;
  --banner-yellow: #fef08a;
  --target-size: 32px;
}

@media (pointer: coarse), (max-width: 768px) {
  :root {
    --target-size: 40px;
  }
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.4;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Main App Wrapper */
.main-app-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 10;
  flex-shrink: 0;
}

@media (min-width: 901px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-mobile-menu {
  display: none;
  padding: 6px 10px;
  min-height: var(--target-size);
}
@media (max-width: 900px) {
  .btn-mobile-menu {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
}

.hamburger-icon {
  font-size: 16px;
  line-height: 1;
}

.brand-badge {
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.brand-title h1 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  text-wrap: balance;
}

.brand-title p {
  font-size: 11px;
  color: var(--text-muted);
}

.header-center {
  display: flex;
  justify-content: center;
  width: 100%;
}

@media (min-width: 901px) {
  .header-center {
    width: auto;
    flex: 1;
  }
}

.drive-file-selector-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: 8px;
  width: 100%;
  max-width: 620px;
  justify-content: space-between;
}

@media (max-width: 600px) {
  .drive-file-selector-box {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
}

.file-select-group, .sheet-select-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.select-label {
  font-size: 11px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.form-select-header {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background-color: #ffffff;
  color: #0f172a;
  outline: none;
  width: 100%;
  min-height: 30px;
  cursor: pointer;
  text-overflow: ellipsis;
}
.form-select-header:focus {
  border-color: var(--primary);
}

.header-right {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
  min-height: var(--target-size);
}

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

.btn-secondary {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.btn-secondary:hover {
  background: #bae6fd;
}

.btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 32px;
}

@media (max-width: 600px) {
  .hide-mobile {
    display: none;
  }
}

/* App Container Layout */
.app-container {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  width: 100%;
}

/* Sidebar (Desktop) */
.sidebar {
  width: 360px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  z-index: 40;
}

.sidebar-mobile-header {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}
.sidebar-mobile-header h3 {
  font-size: 14px;
  font-weight: 700;
}
.btn-close-drawer {
  background: none;
  border: none;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  padding: 4px 8px;
}

/* Mobile Sidebar Drawer */
@media (max-width: 900px) {
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 360px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    transform: translateX(-100%);
  }

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

  .sidebar-mobile-header {
    display: flex;
  }

  .sidebar-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 35;
  }
}

.sidebar-search-box {
  padding: 10px 14px 6px;
}

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

.search-icon {
  position: absolute;
  left: 10px;
  font-size: 13px;
  opacity: 0.6;
}

.search-input-wrapper input {
  width: 100%;
  padding: 8px 30px 8px 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  min-height: 38px;
}
.search-input-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30,58,138,0.1);
}

.btn-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

.template-filter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px 14px;
}

.tpl-filter-tab {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 34px;
  transition: all 0.15s;
}

.tpl-filter-tab:hover {
  background: #f1f5f9;
}

.tpl-filter-tab.active {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #7dd3fc;
}

.filter-row {
  padding: 4px 14px;
}

.form-select {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #fff;
  color: #334155;
  outline: none;
  min-height: 38px;
}

.filter-toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  color: #475569;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--secondary);
}
input:checked + .slider:before {
  transform: translateX(14px);
}

.count-badge {
  margin-left: auto;
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.items-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.item-card {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  margin-bottom: 5px;
  cursor: pointer;
  transition: all 0.1s ease;
  background: #ffffff;
}

.item-card:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.item-card.active {
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: 0 1px 3px rgba(30,58,138,0.06);
}

.item-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.item-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.25;
}

.item-card.active .item-card-title {
  color: var(--primary);
}

.item-card-category {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-tpl {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-tpl.susu { background: #e0f2fe; color: #0284c7; }
.badge-tpl.telur { background: #fef3c7; color: #d97706; }
.badge-tpl.daging_unggas { background: #fee2e2; color: #dc2626; }
.badge-tpl.sayuran_buah { background: #dcfce7; color: #16a34a; }
.badge-tpl.umum { background: #f1f5f9; color: #475569; }

.item-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
}

.item-stock-stat {
  color: #334155;
  font-weight: 600;
}

.item-trans-badge {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.item-trans-badge.has-mutasi {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Main Content */
.main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  overflow: hidden;
  width: 100%;
}

/* Toolbar */
.card-toolbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

@media (min-width: 769px) {
  .card-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.toolbar-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

@media (min-width: 769px) {
  .toolbar-row-top {
    width: auto;
    justify-content: flex-start;
  }
}

.toolbar-row-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

@media (min-width: 769px) {
  .toolbar-row-bottom {
    width: auto;
  }
}

.nav-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.item-counter {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  min-width: 90px;
  text-align: center;
}

.template-customizer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  width: 100%;
}

.form-select-sm {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  outline: none;
  min-height: 32px;
  flex: 1;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-status {
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
}
.save-status.saving .status-dot {
  background-color: #eab308;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Sheet Viewport */
.sheet-viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

@media (max-width: 768px) {
  .sheet-viewport {
    padding: 8px 6px;
  }
}

/* THE OFFICIAL SHEET PAPER */
.sheet-paper {
  width: 100%;
  max-width: 1080px;
  background: #ffffff;
  border: 2px solid #000000;
  padding: 20px 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  box-sizing: border-box;
  color: #000000;
  font-family: Arial, Helvetica, sans-serif;
  height: auto;
  flex-shrink: 0;
  margin-bottom: 50px;
}

@media (max-width: 768px) {
  .sheet-paper {
    padding: 12px 10px;
    border-width: 1.5px;
  }
}

.sheet-meta-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: bold;
}

@media (max-width: 600px) {
  .sheet-meta-header {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
}

.meta-sppg {
  display: flex;
  align-items: center;
  flex: 1;
}

.meta-id {
  display: flex;
  align-items: center;
}

.meta-label {
  white-space: nowrap;
  font-weight: bold;
}

.meta-input {
  border: none;
  border-bottom: 1px dotted #000;
  padding: 2px 6px;
  font-weight: bold;
  font-size: 13px;
  font-family: inherit;
  color: #000;
  outline: none;
  background: transparent;
}
.meta-input:focus {
  background: #fef08a;
}
.meta-input.bold-dotted {
  flex: 1;
  margin: 0 8px;
  min-width: 120px;
}
.meta-input.short {
  width: 140px;
  margin-left: 8px;
}

.sheet-title-banner {
  background-color: var(--banner-yellow);
  border-top: 1.5px solid #000;
  border-bottom: 1.5px solid #000;
  padding: 8px 10px;
  text-align: center;
  margin-bottom: 12px;
}

.sheet-title-banner h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #000000;
  margin: 0;
  text-transform: uppercase;
}

@media (max-width: 600px) {
  .sheet-title-banner h2 {
    font-size: 13px;
    letter-spacing: 0.5px;
  }
}

.sheet-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: bold;
}

@media (max-width: 600px) {
  .sheet-info-row {
    flex-direction: column;
    gap: 4px;
  }
}

.info-group {
  display: flex;
  align-items: center;
}
.info-group.right-aligned {
  justify-content: flex-end;
}
@media (max-width: 600px) {
  .info-group.right-aligned {
    justify-content: flex-start;
  }
}
.info-group.full-width {
  width: 100%;
}

.info-label {
  min-width: 130px;
  font-weight: bold;
}

.info-colon {
  margin: 0 6px;
  font-weight: bold;
}

.info-input {
  border: none;
  border-bottom: 1px dotted #555;
  padding: 1px 4px;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  color: #000;
  outline: none;
  min-width: 180px;
  flex: 1;
  background: transparent;
}
.info-input:focus {
  background: #fef9c3;
}

/* Mobile Table Swipe Hint */
.mobile-table-hint {
  display: none;
  background: #f0fdf4;
  border: 1px dashed #86efac;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
  color: #166534;
  text-align: center;
  margin-bottom: 8px;
  font-weight: 600;
}
@media (max-width: 768px) {
  .mobile-table-hint {
    display: block;
  }
}

/* Main Table Container */
.sheet-table-wrapper {
  margin-top: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #000000;
  max-width: 100%;
}

.kartu-stok-table {
  width: 100%;
  min-width: 860px; /* Ensures table columns maintain readable widths */
  border-collapse: collapse;
  font-size: 12px;
}

.kartu-stok-table th, 
.kartu-stok-table td {
  border: 1px solid #000000;
  padding: 6px 4px;
  vertical-align: middle;
}

.kartu-stok-table thead th {
  background-color: #e2e8f0;
  color: #000000;
  font-weight: bold;
  text-align: center;
  line-height: 1.2;
  position: sticky;
  top: 0;
  z-index: 2;
}

.kartu-stok-table th.col-fifo-prio,
.kartu-stok-table td.col-fifo-prio {
  background-color: var(--fifo-green) !important;
  color: #000000;
  text-align: center;
  font-weight: bold;
}

.kartu-stok-table td.text-center { text-align: center; }
.kartu-stok-table td.text-right { text-align: right; }

.table-input {
  width: 100%;
  border: 1px solid transparent;
  padding: 4px 4px;
  font-size: 12px;
  font-family: inherit;
  background: transparent;
  color: #000000;
  border-radius: 2px;
  box-sizing: border-box;
  min-height: 28px;
}

@media (pointer: coarse), (max-width: 768px) {
  .table-input {
    font-size: 13px; /* Prevents auto-zoom on mobile */
    min-height: 34px;
  }
}

.table-input:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.table-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 1px var(--primary);
}

.table-input.center {
  text-align: center;
}

.fifo-select {
  border: 1px solid transparent;
  background: transparent;
  font-weight: bold;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  padding: 3px;
  min-height: 30px;
}
.fifo-select:focus {
  outline: none;
  background: #fff;
  border-color: var(--fifo-green-dark);
}

.blank-row td {
  height: 28px;
}

.fifo-guide-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 11px;
}

.guide-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 6px;
}

@media (max-width: 600px) {
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

.guide-item {
  background: #fff;
  padding: 5px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.guide-item.p1 { border-left: 3px solid #16a34a; }
.guide-item.p2 { border-left: 3px solid #2563eb; }
.guide-item.p3 { border-left: 3px solid #d97706; }
.guide-item.p4 { border-left: 3px solid #dc2626; }

.guide-note {
  font-size: 10.5px;
  color: #64748b;
  font-style: italic;
}

.sheet-signature-block {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding: 0 10px;
  text-align: center;
  font-size: 11px;
}

@media (max-width: 600px) {
  .sheet-signature-block {
    flex-direction: column;
    gap: 16px;
  }
  .sig-col {
    width: 100% !important;
  }
  .sig-space {
    height: 35px !important;
  }
}

.sig-col {
  width: 200px;
}

.sig-role {
  font-weight: bold;
  margin-top: 2px;
}

.sig-space {
  height: 50px;
}

.sig-name {
  font-weight: bold;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 12px;
}

.modal-card {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
  overflow: hidden;
}

.modal-header {
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #64748b;
  padding: 4px;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-footer {
  padding: 10px 18px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #334155;
}
.form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  min-height: 38px;
}

.files-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin: 6px 0 14px;
}

.file-item-btn {
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}
.file-item-btn:hover {
  background: #eff6ff;
}
.file-item-btn.active {
  background: #dbeafe;
  font-weight: 700;
  color: #1d4ed8;
}

.upload-dropzone {
  border: 2px dashed #94a3b8;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-dropzone:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.upload-icon {
  font-size: 26px;
  margin-bottom: 4px;
  display: block;
}
.upload-dropzone h4 {
  font-size: 13px;
  margin-bottom: 3px;
}
.upload-dropzone p {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 8px;
}

.upload-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  z-index: 3000;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================== */
/* GOOGLE LOGIN OVERLAY                       */
/* ========================================== */
.login-overlay-container {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fadeIn 0.25s ease-out;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 440px;
  padding: 32px 28px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.brand-badge-lg {
  display: inline-block;
  background: #1e3a8a;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  padding: 4px 14px;
  border-radius: 20px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 20px;
}

.login-info-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  font-size: 12.5px;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 20px;
  text-align: left;
}

.btn-google-signin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  background: #ffffff;
  color: #1f2937;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 16px;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-google-signin:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.btn-quick-signin {
  width: 100%;
  background: #0f172a;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  margin-top: 10px;
}

.btn-quick-signin:hover {
  background: #1e293b;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0 14px;
  color: #94a3b8;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid #e2e8f0;
}

.login-divider span {
  padding: 0 10px;
}

.btn-link-sm {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.btn-link-sm:hover {
  text-decoration: underline;
  background: #eff6ff;
}

.login-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  font-size: 11px;
  color: #64748b;
  line-height: 1.4;
}

/* ========================================== */
/* HEADER DRIVE & SYNC BADGES                */
/* ========================================== */
.header-drive-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.header-folder-pill,
.header-sync-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}

.header-folder-pill {
  border-color: #cbd5e1;
}

.header-sync-pill {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.pill-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.pill-label {
  font-size: 9.5px;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.pill-value {
  font-size: 12px;
  color: #0f172a;
  font-weight: 700;
  white-space: nowrap;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-pill-action {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: #2563eb;
  padding: 2px 7px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-pill-action:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

.btn-pill-sync {
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
}

.btn-pill-sync:hover {
  background: #15803d;
}

.sync-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.sync-status-dot.active {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.sync-icon-spin.spinning {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

/* User Profile Badge */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 20px;
  padding: 3px 8px 3px 4px;
  border: 1px solid #e2e8f0;
}

.user-avatar-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1e3a8a;
  color: #ffffff;
  font-weight: 700;
  font-size: 10.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-profile-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  text-align: left;
}

.user-name {
  font-size: 11px;
  font-weight: 700;
  color: #0f172a;
}

.user-email {
  font-size: 9.5px;
  color: #64748b;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout-icon {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.btn-logout-icon:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* ========================================== */
/* MODAL: DRIVE FOLDER PICKER                 */
/* ========================================== */
.modal-lg {
  max-width: 680px;
}

.modal-title-with-icon {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header-icon {
  font-size: 24px;
}

.modal-subtitle {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 1px;
}

.folder-url-input-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.input-with-button {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.input-with-button .form-input {
  flex: 1;
}

.section-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.btn-link-xs {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 11px;
  cursor: pointer;
  font-weight: 600;
}

.btn-link-xs:hover {
  text-decoration: underline;
}

.drive-folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 2px;
}

.folder-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.folder-card:hover {
  border-color: #93c5fd;
  background: #f0f9ff;
}

.folder-card.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

.folder-card-icon {
  font-size: 20px;
}

.folder-card-info {
  flex: 1;
  min-width: 0;
}

.folder-card-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-card-meta {
  font-size: 10.5px;
  color: #64748b;
  margin-top: 1px;
}

.folder-files-preview-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 8px;
}

.files-preview-list {
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 11px;
}

.file-preview-item.active {
  background: #ecfdf5;
  border-color: #86efac;
}

/* ========================================== */
/* MODAL: AUTO-SYNC SETTINGS                  */
/* ========================================== */
.sync-config-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.config-toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 12px;
}

.toggle-info strong {
  font-size: 13.5px;
  color: #0f172a;
}

.toggle-info p {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 2px;
}

.config-interval-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.config-interval-row select {
  max-width: 220px;
}

.sync-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status-msg {
  font-size: 11.5px;
  color: #475569;
}

.sync-log-table-wrapper {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.sync-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.sync-log-table th {
  background: #f1f5f9;
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  color: #475569;
  position: sticky;
  top: 0;
}

.sync-log-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
}

.badge-sync-ok {
  display: inline-block;
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

/* OAuth Guide */
.oauth-help-guide {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  color: #166534;
  margin-bottom: 16px;
}

.oauth-help-guide ol {
  padding-left: 20px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.copyable-code {
  background: #dcfce7;
  color: #14532d;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm;
  }

  body {
    background: #ffffff !important;
    height: auto !important;
    overflow: visible !important;
  }

  .no-print,
  .app-header,
  .sidebar,
  .sidebar-backdrop,
  .card-toolbar,
  .fifo-guide-box,
  .modal-backdrop,
  .mobile-table-hint,
  .toast {
    display: none !important;
  }

  .app-container,
  .main-content,
  .sheet-viewport {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .sheet-paper {
    border: 1.5px solid #000 !important;
    box-shadow: none !important;
    padding: 12px !important;
    max-width: 100% !important;
    width: 100% !important;
    page-break-inside: avoid;
  }

  .sheet-title-banner {
    background-color: #fef08a !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .kartu-stok-table thead th {
    background-color: #e2e8f0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .kartu-stok-table th.col-fifo-prio,
  .kartu-stok-table td.col-fifo-prio {
    background-color: #dcfce7 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .table-input {
    border: none !important;
    padding: 2px !important;
  }
}
