@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
  /* Dark Theme Variables (Default) */
  --bg-app: #090d16;
  --bg-sidebar: rgba(15, 23, 42, 0.8);
  --bg-card: rgba(22, 30, 49, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-input: rgba(15, 23, 42, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #14b8a6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --accent-teal: #14b8a6;
  --accent-teal-glow: rgba(20, 184, 166, 0.25);
  
  --accent-coral: #f43f5e;
  --accent-coral-glow: rgba(244, 63, 94, 0.25);

  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.25);

  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  
  --glass-blur: blur(16px);
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 15px rgba(20, 184, 166, 0.15);
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  --font-sans: 'Outfit', 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-theme="light"] {
  /* Light Theme Variables */
  --bg-app: #f1f5f9;
  --bg-sidebar: rgba(255, 255, 255, 0.9);
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-input: rgba(241, 245, 249, 0.9);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: #0d9488;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  --accent-teal: #0d9488;
  --accent-teal-glow: rgba(13, 148, 136, 0.2);
  
  --accent-coral: #e11d48;
  --accent-coral-glow: rgba(225, 29, 72, 0.2);

  --accent-blue: #2563eb;
  --accent-blue-glow: rgba(37, 99, 235, 0.2);

  --accent-amber: #d97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.2);
  
  --shadow-premium: 0 10px 30px -10px rgba(148, 163, 184, 0.3);
  --shadow-glow: 0 0 15px rgba(13, 148, 136, 0.1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* App Layout */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-smooth);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 15px rgba(20, 184, 166, 0.4);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-smooth);
}

.nav-link svg {
  width: 20px;
  height: 20px;
  transition: var(--transition-smooth);
}

.nav-link:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-color);
}

.nav-link.active {
  color: white;
  background: linear-gradient(135deg, var(--accent-teal), #0f766e);
  box-shadow: 0 4px 20px var(--accent-teal-glow);
  border-color: transparent;
}

.nav-link.active svg {
  transform: scale(1.1);
  color: white;
}

/* Sidebar Footer (Theme Toggle & User info) */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem;
  border-radius: 12px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.theme-toggle-btn svg {
  width: 18px;
  height: 18px;
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex-grow: 1;
  padding: 2.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  transition: var(--transition-smooth);
}

/* View Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

.view-title-group h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0.25rem;
}

.view-title-group p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Metric Stats Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-premium);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: var(--transition-bounce);
}

.metric-card:hover {
  transform: translateY(-5px);
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -1px;
}

.metric-trend {
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-trend.up { color: var(--accent-teal); }
.metric-trend.down { color: var(--accent-coral); }

.metric-icon-box {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-icon-box.teal {
  background: var(--accent-teal-glow);
  color: var(--accent-teal);
}

.metric-icon-box.coral {
  background: var(--accent-coral-glow);
  color: var(--accent-coral);
}

.metric-icon-box.blue {
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
}

.metric-icon-box.amber {
  background: var(--accent-amber-glow);
  color: var(--accent-amber);
}

/* Dashboard Filter Controls */
.filter-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
  box-shadow: var(--shadow-premium);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.select-custom, .input-custom {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  min-width: 180px;
  transition: var(--transition-smooth);
}

.select-custom:focus, .input-custom:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 10px rgba(20, 184, 166, 0.2);
}

.quick-date-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.75rem 1.2rem;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.quick-date-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.quick-date-btn.active {
  background: var(--accent-teal);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px var(--accent-teal-glow);
}

.quick-date-container {
  display: flex;
  gap: 0.5rem;
}

/* Dashboard Layout Visuals */
.dashboard-visuals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 1100px) {
  .dashboard-visuals {
    grid-template-columns: 1fr;
  }
}

.panel-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}

.filter-group-inline {
  display: flex;
  align-items: center;
}

.visual-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-height: 400px;
}

.visual-panel h2 {
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-wrapper {
  position: relative;
  flex-grow: 1;
  width: 100%;
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Premium Tables */
.table-wrapper {
  overflow-x: auto;
  width: 100%;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.premium-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.premium-table th {
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

[data-theme="light"] .premium-table th {
  background: rgba(241, 245, 249, 0.7);
}

.premium-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  white-space: nowrap;
}

/* Compact layout for goods issue and history views to fit all columns without screen overflow */
#view-issue .premium-table,
#view-history .premium-table {
  font-size: 0.825rem;
}
#view-issue .premium-table th,
#view-issue .premium-table td,
#view-history .premium-table th,
#view-history .premium-table td {
  padding: 0.6rem 0.75rem;
}

.premium-table tbody tr {
  transition: var(--transition-smooth);
}

.premium-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.premium-table tbody tr:last-child td {
  border-bottom: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.success {
  background: var(--accent-teal-glow);
  color: var(--accent-teal);
}

.badge.danger {
  background: var(--accent-coral-glow);
  color: var(--accent-coral);
}

.badge.neutral {
  background: var(--border-color);
  color: var(--text-muted);
}

/* Forms: Page A & Card layout */
.form-container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-field label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-field label span {
  color: var(--accent-coral);
}

/* Button UI */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-teal), #0f766e);
  color: white;
  border: none;
  padding: 0.9rem 1.75rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px var(--accent-teal-glow);
  transition: var(--transition-bounce);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(20, 184, 166, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.9rem 1.75rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: linear-gradient(135deg, var(--accent-coral), #be123c);
  color: white;
  border: none;
  padding: 0.9rem 1.75rem;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px var(--accent-coral-glow);
  transition: var(--transition-bounce);
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(244, 63, 94, 0.4);
}

.btn-submit-full {
  width: 100%;
  margin-top: 1rem;
}

/* Page B & D: Responsive Search & Filter UI Styles */
.search-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow-premium);
  margin-bottom: 2rem;
  width: 100%;
}

.search-main-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
  align-items: center;
}

.search-input-box {
  position: relative;
  flex: 1 1 300px;
}

.search-input-box svg {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}

.search-input-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 3.25rem;
  border-radius: 10px;
  font-size: 0.95rem;
  height: 44px;
}

.filter-grid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  width: 100%;
  align-items: flex-end;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 160px;
  min-width: 130px;
}

.filter-item-large {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 2 1 230px;
  min-width: 180px;
}

.filter-item-date-group {
  display: flex;
  gap: 0.35rem;
  flex: 2 1 310px;
  min-width: 260px;
  align-items: center;
}

.filter-item select,
.filter-item-large select,
.filter-item-date-group select {
  width: 100%;
  height: 44px;
  padding: 0.75rem 2rem 0.75rem 1rem;
  min-width: 0 !important;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;
}

.filter-actions .btn-secondary,
.filter-actions .btn-primary {
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  height: 44px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  margin: 0;
  justify-content: center;
}

/* Modal Form Grid */
.modal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 868px) {
  .filter-actions {
    margin-left: 0;
    width: 100%;
  }
  .filter-actions .btn-secondary,
  .filter-actions .btn-primary {
    flex: 1 1 auto;
  }
}

@media (max-width: 600px) {
  .modal-form-grid {
    grid-template-columns: 1fr;
  }
  .filter-item-date-group {
    flex-wrap: wrap;
    flex: 1 1 100%;
  }
  .filter-item-date-group select {
    flex: 1 1 80px;
  }
  .select-custom, .input-custom {
    min-width: 0 !important;
  }
}

/* Card Grid for Stock Items */
.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-premium);
  transition: var(--transition-bounce);
}

.stock-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-teal);
  box-shadow: var(--shadow-glow);
}

.stock-card.selected {
  border-color: var(--accent-teal);
  background: rgba(20, 184, 166, 0.05);
  box-shadow: 0 0 20px rgba(20, 184, 166, 0.15);
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.stock-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}

.stock-card-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  color: var(--text-muted);
}

.stock-card-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.detail-label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-value {
  font-weight: 600;
  color: var(--text-main);
}

.stock-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
}

.stock-qty-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.stock-qty-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent-teal);
}

.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.no-results svg {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
}

/* Modal Overlay for Withdrawal input */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  width: 100%;
  max-width: 500px;
  padding: 2.25rem;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  transform: scale(0.9);
  transition: var(--transition-bounce);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

.modal-close-btn:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-item-summary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.9rem;
}

.modal-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
}

.modal-summary-row span:first-child {
  color: var(--text-muted);
}

.modal-summary-row span:last-child {
  font-weight: 600;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

/* Settings View UI Styles */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.settings-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 2000;
}

.toast {
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  color: var(--text-main);
  box-shadow: var(--shadow-premium);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn 0.3s forwards cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.success {
  border-left: 4px solid var(--accent-teal);
}

.toast.error {
  border-left: 4px solid var(--accent-coral);
}

.toast.info {
  border-left: 4px solid var(--accent-blue);
}

.toast svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast.success svg { color: var(--accent-teal); }
.toast.error svg { color: var(--accent-coral); }
.toast.info svg { color: var(--accent-blue); }

@keyframes toastIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* CSS Page Tab Visibility Utility */
.view-panel-tab {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.view-panel-tab.active {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Autocomplete suggestion UI */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 10px 10px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-premium);
}

.autocomplete-suggestion-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.autocomplete-suggestion-item:hover {
  background: var(--bg-input);
  color: var(--accent-teal);
}

/* Responsive Overrides */
@media (max-width: 868px) {
  body {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1.5rem;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .brand-section {
    margin-bottom: 1.5rem;
  }
  .nav-links {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
  .nav-link {
    padding: 0.75rem 1rem;
    white-space: nowrap;
  }
  .sidebar-footer {
    display: none; /* Hide toggle footer from mobile sidebar, or handle differently */
  }
  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }
}

/* History Interactive Table Rows */
#history-table-body tr {
  cursor: pointer;
}
#history-table-body tr:hover {
  background: rgba(20, 184, 166, 0.06) !important;
}

/* Clickable Date link styled cell */
.clickable-date {
  color: var(--accent-blue);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease, text-decoration 0.2s ease;
  border-bottom: 1px dashed rgba(59, 130, 246, 0.4);
}
.clickable-date:hover {
  color: var(--accent-teal);
  text-decoration: none;
  border-bottom: 1px dashed var(--accent-teal);
}

/* Highlight Flash Animation for History Rows */
@keyframes row-highlight-flash {
  0% { background-color: rgba(59, 130, 246, 0.35) !important; }
  30% { background-color: rgba(59, 130, 246, 0.35) !important; }
  100% { background-color: transparent; }
}
.row-highlight {
  animation: row-highlight-flash 3s ease-out;
}

/* Print Preview Modal Table Styles */
.print-table {
  border-collapse: collapse;
  width: 100%;
}
.print-table th,
.print-table td {
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  font-size: 0.9rem;
}
.print-table th:nth-child(2),
.print-table td:nth-child(2), /* วันที่รับแผ่น */
.print-table th:nth-child(3),
.print-table td:nth-child(3), /* ชื่อแผ่นโลหะ */
.print-table th:nth-child(4),
.print-table td:nth-child(4) /* Coil Number */ {
  white-space: nowrap !important;
}
.print-table th:nth-child(3),
.print-table td:nth-child(3) {
  min-width: 280px !important;
  text-align: left !important;
}

/* @media print styles */
@media print {
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Hide all main page containers */
  body > * {
    display: none !important;
  }

  /* Show only the print preview modal and reset its styles for standard paper printing */
  body #print-preview-modal {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
  }

  #print-preview-modal .modal-content {
    background: white !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  #print-preview-modal .modal-header,
  #print-preview-modal .modal-footer,
  #print-preview-modal .print-no-print {
    display: none !important;
  }

  #print-preview-modal .modal-body {
    max-height: none !important;
    overflow-y: visible !important;
    padding: 0 !important;
  }

  #print-preview-area {
    background: white !important;
    color: black !important;
    padding: 0 !important;
    border-radius: 0 !important;
  }

  #print-preview-area h2 {
    color: black !important;
  }

  #print-preview-area p {
    color: #444 !important;
  }

  .print-table {
    width: 100% !important;
    table-layout: fixed !important;
    border: 1px solid #000 !important;
    color: black !important;
    margin-top: 1.5rem !important;
  }

  .print-table th, 
  .print-table td {
    border: 1px solid #000 !important;
    color: black !important;
    padding: 6px 8px !important;
    font-size: 9.5pt !important;
    background: transparent !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .print-table th {
    font-weight: bold !important;
    background-color: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-table tfoot td {
    border: 1px solid #000 !important;
    color: black !important;
    background-color: #fafafa !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Override min-width and nowrap from screen styles for printing */
  .print-table th:nth-child(3),
  .print-table td:nth-child(3) {
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .print-table th:nth-child(8),
  .print-table td:nth-child(8) {
    min-width: 0 !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  /* Set percentage widths for columns when printing */
  .print-table th:nth-child(1), .print-table td:nth-child(1) { width: 5% !important; text-align: center !important; } /* ลำดับ */
  .print-table th:nth-child(2), .print-table td:nth-child(2) { width: 12% !important; } /* วันที่รับแผ่น */
  .print-table th:nth-child(3), .print-table td:nth-child(3) { width: 26% !important; } /* ชื่อแผ่นโลหะ */
  .print-table th:nth-child(4), .print-table td:nth-child(4) { width: 14% !important; } /* Coil Number */
  .print-table th:nth-child(5), .print-table td:nth-child(5) { width: 10% !important; } /* ขนาดแผ่น */
  .print-table th:nth-child(6), .print-table td:nth-child(6) { width: 11% !important; text-align: right !important; } /* จำนวนเริ่มต้น */
  .print-table th:nth-child(7), .print-table td:nth-child(7) { width: 11% !important; text-align: right !important; } /* ยอดคงคลัง */
  .print-table th:nth-child(8), .print-table td:nth-child(8) { width: 11% !important; } /* หมายเหตุ */
}

/* Login Screen Styles */
.login-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-app);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: var(--transition-smooth);
}

.login-screen-overlay.active {
  display: flex;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 3rem;
  border-radius: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.login-brand .brand-icon {
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand .brand-name {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* Cloud Connection Indicator */
.cloud-status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  width: fit-content;
  margin-bottom: 0.25rem;
  font-family: var(--font-sans);
  transition: var(--transition-smooth);
}

.cloud-status-badge .connection-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.cloud-status-badge.online {
  color: var(--accent-teal);
  border-color: rgba(20, 184, 166, 0.2);
  background: rgba(20, 184, 166, 0.05);
}

.cloud-status-badge.online .connection-status {
  background: var(--accent-teal);
  box-shadow: 0 0 8px var(--accent-teal);
}

.cloud-status-badge.offline {
  color: var(--text-muted);
  border-color: var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}

.cloud-status-badge.offline .connection-status {
  background: var(--text-muted);
}

/* Dashboard Chart Metric Tabs */
.chart-tab-btn {
  color: var(--text-muted);
}

.chart-tab-btn:hover {
  color: var(--text-main);
}

.chart-tab-btn.active {
  background: var(--bg-card) !important;
  color: var(--accent-teal) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .chart-tab-btn.active {
  background: #ffffff !important;
  color: var(--accent-teal) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Clickable Table Headers Syncing with Chart */
.clickable-header {
  transition: background-color 0.2s, color 0.2s;
  user-select: none;
}

.clickable-header:hover {
  background-color: var(--bg-card-hover) !important;
  color: var(--accent-teal) !important;
}


