@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: local('Inter'),
       url('https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS0Z2.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #f9fafb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #3b82f6;
  --primary-contrast: #ffffff;
  --outline: #d1d5db;
  --success-light: #d1fae5;
  --success-text: #065f46;
  --warning-light: #fef3c7;
  --warning-text: #92400e;
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  padding-bottom: 80px; /* clear fixed footer */
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.card-title { margin: 0 0 12px; font-size: 20px; }

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
label { color: var(--muted); font-size: 14px; }
input, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  background: #ffffff;
  color: var(--text);
  outline: none;
  margin-top: 5px;
  margin-bottom: 5px;
}
input::placeholder { color: #9ca3af; }

.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Buttons */
.btn,
button {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.05s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}
.btn:hover,
button:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: var(--primary-contrast); border: 1px solid #2563eb; }
.btn-outline { border: 1px solid var(--outline); color: var(--text); background: transparent; }
.btn-danger { border: 1px solid var(--outline); background: var(--danger-bg); color: var(--danger-text); }

/* Notices */
.notice { margin-bottom: 16px; }
.notice.success { border-left: 4px solid var(--success-text); background: var(--success-light); padding: 8px; }
.notice.error { border-left: 4px solid var(--warning-text); background: var(--warning-light); padding: 8px; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--outline);
}
.topbar-left .brand { font-weight: 700; font-size: 18px; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.welcome { color: var(--muted); }

/* Fixed full-width footer */
.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  width: 100%;
  background: #f3f4f6;
  color: var(--text);
  border-top: 1px solid var(--outline);
  z-index: 1000;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--muted);
}

/* Prevent content overlap with footer */
main { padding-bottom: 80px; }

/* Centered login card */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-container { width: 100%; max-width: 420px; }
.card-center { text-align: center; }
.card-center .form-group { text-align: left; }

/* Mobile-first tweaks */
@media (max-width: 480px) {
  .container { padding-bottom: 100px; }
  .footer-inner { flex-direction: column; gap: 8px; }
}

/* Login */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 20px;
}
.login-button {
  padding: 12px 24px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.login-button:hover { background-color: #2563eb; }
.reset-label { margin-left: auto; margin-right: auto; }

/* Hamburger toggle */
.menu-toggle {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text);
  cursor: pointer;
  display: none;
  transition: transform 0.3s ease;
}
.menu-toggle.open { transform: rotate(90deg); }

.desktop-menu { display: flex; align-items: center; gap: 12px; }

/* Fancy mobile menu */
.mobile-menu {
  display: none;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  padding: 12px;
  border-radius: 8px;
  position: absolute;
  right: 12px;
  top: 48px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  z-index: 2000;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.mobile-menu.open {
  display: flex;
  opacity: 1;
  transform: translateY(0);
  margin-top: 15px;
}
.menu-spacer { height: 12px; }

@media (max-width: 768px) {
  .desktop-menu { display: none; }
  .menu-toggle { display: block; }
}

/* Company list table for Admin Dashboard */
.company-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.company-table th,
.company-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--outline);
}

/* Status badges */
.status {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  text-transform: capitalize;
}
.status.active {
  background: var(--success-light);
  color: var(--success-text);
}
.status.waiting {
  background: var(--warning-light);
  color: var(--warning-text);
}

/* ========================= */
/* Stock list view styles    */
/* ========================= */

.stock-list {
  display: flex;
  flex-direction: column;   /* stack cards vertically */
  gap: 24px;                /* space between cards */
  width: 100%;              /* full width of container */
}

.stock-card {
  width: 100%;              /* span full width */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--outline);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  min-height: 220px;        /* breathing room */
}

.stock-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.stock-card-header .stock-date {
  font-size: 14px;
  color: var(--muted);
}
.stock-card-header .stock-invoice {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

/* Items container: grid on larger screens */
.items {
  margin: 12px 0;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr; /* name, qty, price, total */
  gap: 8px;
}

.item-row {
  display: contents; /* allow children to align to grid columns */
}

/* Name column */
.item-name {
  grid-column: 1;
  font-weight: 600;
  color: var(--text);
  min-width: 160px;
  text-align: left;
}

/* Detail columns (Qty, Price, Total) */
.item-detail {
  font-weight: 600;
  color: var(--text);
  min-width: 90px;
  text-align: left;
}

/* Place each detail in its column */
.item-detail:nth-of-type(2) { grid-column: 2; } /* Qty */
.item-detail:nth-of-type(3) { grid-column: 3; } /* Price */
.item-detail:nth-of-type(4) { grid-column: 4; } /* Total */

/* Row background and separation for readability */
.items .item-row > * {
  padding: 8px 10px;
  border: 1px solid var(--outline);
  border-radius: 10px;
  background: #ffffff;
}

/* Actions inside stock cards */
.stock-card .form-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Ensure buttons sit at the bottom if card grows */
.stock-card { min-height: 100%; }

/* ========================= */
/* Supplier card styles      */
/* ========================= */

.supplier-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--outline);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.supplier-card .card-title {
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.supplier-card p {
  margin: 4px 0;
  font-size: 14px;
  color: var(--text);
}

.supplier-card .form-actions {
  margin-top: auto;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ========================= */
/* Warning card (empty state)*/
/* ========================= */

.warning-card {
  border: 1px solid var(--warning-text);
  background: var(--warning-light);
  padding: 20px;
  border-radius: 16px;
  text-align: center;
}

.warning-card .card-title {
  color: var(--warning-text);
  margin-bottom: 12px;
}

/* ========================= */
/* Collapsible item list     */
/* ========================= */

.collapse { display: none; }
.collapse.open { display: block; }

.toggle-items {
  margin: 8px 0;
  font-size: 14px;
  cursor: pointer;
}

/* ========================= */
/* Compact totals section    */
/* ========================= */

.invoice-summary {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding: 8px 12px;
  margin: 12px 0;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--outline);
}

@media (max-width: 640px) {
  .invoice-summary {
    flex-direction: column;
    gap: 6px;
    text-align: left;
  }
}

/* ========================= */
/* Sticky mobile action bar  */
/* ========================= */

.stock-actions-mobile { display: none; }

@media (max-width: 640px) {
  .desktop-actions { display: none; }

  .stock-actions-mobile {
    display: flex;
    position: sticky;
    bottom: 0;
    background: var(--card);
    padding: 8px;
    justify-content: space-around;
    border-top: 1px solid var(--outline);
    z-index: 500;
  }

  .stock-actions-mobile .btn {
    flex: 1;
    text-align: center;
    font-size: 18px;
    padding: 10px;
  }
}

/* ========================= */
/* Mobile item layout pills  */
/* ========================= */

@media (max-width: 640px) {
  .items {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .item-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--outline);
    border-radius: 12px;
    background: #ffffff;
    margin-bottom: 12px;
    padding-bottom: 12px;
  }

  .item-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--text);
  }

  .item-detail {
    font-size: 14px;
    color: var(--text);
    text-align: left;
    padding: 6px 10px;
    border-radius: 20px;
    background: var(--bg);
    border: 1px solid var(--outline);
    display: inline-block;
    width: fit-content;
  }
}

/* Force collapsible items to stack vertically */
.collapse.open .items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.collapse.open .item-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 12px;
}

.collapse.open .item-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}

.collapse.open .item-detail {
  font-size: 14px;
  color: var(--text);
  text-align: left;
  padding: 6px 10px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--outline);
  display: inline-block;
  width: fit-content;
}
/* Default: desktop actions visible, mobile hidden */
.desktop-actions { display: flex; }
.stock-actions-mobile { display: none; }

/* Mobile: hide desktop actions, show sticky bar */
@media (max-width: 640px) {
  .desktop-actions { display: none; }
  .stock-actions-mobile {
    display: flex;
    position: sticky;
    bottom: 0;
    background: var(--card);
    padding: 8px;
    justify-content: space-around;
    border-top: 1px solid var(--outline);
    z-index: 500;
  }
  .stock-actions-mobile .btn {
    flex: 1;
    text-align: center;
    font-size: 18px;
    padding: 10px;
  }
}
/* --- Stock list filter bar --- */
.filter-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-field {
  flex: 1;
  display: flex;
  flex-direction: column;
}

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

/* Mobile stacking */
@media (max-width: 640px) {
  .filter-row {
    flex-direction: column;
  }
  .filter-actions {
    justify-content: center;
  }
  .filter-field input,
  .filter-field select {
    width: 100%;
  }
}

/* --- Collapsible items fix --- */
.items.collapse {
  display: none;
}
.items.collapse.open {
  display: block;
}

/* Collapse behavior (desktop default) */
.items.collapse { display: none; }
.items.collapse.open { display: block; }

/* Mobile: always show items, hide toggle button */
@media (max-width: 640px) {
  .items.collapse { display: block !important; }
  .toggle-items { display: none; }
}

.back-button {
  margin-top: 20px;
  text-align: left;
}

.back-btn {
  border: 1px solid #007bff;
  color: #007bff;
  background: #fff;
  padding: 6px 12px;
  border-radius: 4px;
  text-decoration: none;
  display: inline-block;
}

.back-btn:hover {
  background: #f0f8ff;
}