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

:root {
    --primary-color: #1c1c1c;
    --secondary-color: #e8e8e8;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --text-color: #1c1c1c;
    --bg-color: #fafafa;
    --bg-secondary: #f3f4f6;
    --bg-accent: #fff4e6;
    --border-color: #e8e8e8;
    --interactive-color: #0066cc;
    --neutral-gray: #d0d0d0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.login-box h2 {
    text-align: center;
    font-size: 1.2rem;
    color: var(--secondary-color);
    margin-bottom: 30px;
    font-weight: 400;
}

.login-box .hint {
    text-align: center;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 15px;
}

.navbar {
    background: white;
    padding: 15px 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.3s;
}

.nav-link:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.dashboard-content {
    padding: 40px 20px;
}

.welcome-section {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-section h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.welcome-section p {
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.dashboard-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.dashboard-card h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

.dashboard-card p {
    color: var(--secondary-color);
    margin-bottom: 20px;
}

.quick-stats {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.quick-stats h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

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

.stat-item {
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
}

.stat-item label {
    font-weight: 600;
}

.stat-item span {
    color: var(--primary-color);
    font-weight: 700;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--interactive-color);
    color: white;
}

.btn-primary:hover {
    background: #0052a3;
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background: #d4d4d4;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

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

.btn-danger:hover {
    background: #dc2626;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--interactive-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    color: var(--primary-color);
    margin-bottom: 8px;
}

.page-header p {
    color: var(--secondary-color);
}

.admin-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.form-section {
    margin-bottom: 35px;
    padding-bottom: 35px;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

.purity-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.purity-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 6px;
    cursor: pointer;
}

.purity-checkbox {
    width: auto;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
}

.success-message {
    background: var(--success-color);
    color: white;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    margin-top: 20px;
}

.invoice-form-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.item-row {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

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

.item-row-header h4 {
    color: var(--primary-color);
}

.btn-remove {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-remove:hover {
    background: #dc2626;
}

.invoice-summary {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
    margin: 25px 0;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    background: transparent;
    padding: 10px 0;
    margin-top: 10px;
    border: none;
}

.printable-invoice {
    background: white;
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
    position: relative;
    z-index: 1;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.invoice-watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    opacity: 0.25;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.watermark-logo {
    width: 350px;
    height: 350px;
    opacity: 1;
    object-fit: contain;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.invoice-header {
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    position: relative;
    z-index: 20;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 20px;
    gap: 20px;
    background: white;
    page-break-inside: avoid;
}

.invoice-logo {
    flex-shrink: 0;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.invoice-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.shop-details {
    flex: 1;
}

.shop-details h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.shop-details p {
    margin: 5px 0;
    color: var(--text-color);
}

.invoice-title {
    text-align: right;
    flex-shrink: 0;
}

.invoice-title h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.customer-details {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    position: relative;
    z-index: 5;
}
.customer-details h3 {
    margin-top: 10px;
    position: relative;
    z-index: 5;
}
/* Bill To + Tax Invoice row */
.bill-invoice-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    margin-bottom: 30px;
}

.invoice-title-inline {
    text-align: right;
    min-width: 220px;
}

.customer-details h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    position: relative;
    z-index: 2;
}

.invoice-table th,
.invoice-table td {
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.invoice-table th {
    background: transparent;
    color: var(--primary-color);
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
}

.invoice-table td {
    background: transparent;
    color: var(--text-color);
}

.invoice-table tbody tr:hover td {
    background: transparent;
}

.invoice-footer {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    position: relative;
    z-index: 5;
}

.payment-details {
    flex: 1;
}

.invoice-totals {
    flex: 1;
    max-width: 350px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.total-row.grand-total {
    background: transparent;
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 10px;
    border: none;
}

.invoice-signature {
    position: absolute;
    bottom: 40px;
    left: 40px;
    z-index: 2;
}

.signature-section {
    text-align: left;
    min-width: 220px;
}

.signature-line {
    width: 220px;
    border-top: 1px solid #000;
    margin-bottom: 6px;
}

.signature-name {
    font-weight: 600;
    margin: 0;
}

.signature-label {
    font-size: 12px;
    margin-top: 2px;
    color: #555;
}


.invoice-notes {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.invoice-notes p {
    margin: 5px 0;
}

.print-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.records-table-container {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 30px;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
}

.records-table th,
.records-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.records-table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.records-table tbody tr:hover {
    background: var(--bg-color);
}

.no-records {
    text-align: center;
    color: var(--secondary-color);
    padding: 40px;
}

.btn-action {
    padding: 6px 12px;
    margin: 0 3px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-action:hover {
    background: #1d4ed8;
}

.header-actions {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.search-input,
.filter-date {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.search-input {
    flex: 1;
    min-width: 250px;
}

.records-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h4 {
    color: var(--secondary-color);
    margin-bottom: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.stat-card p {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--secondary-color);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.invoice-detail {
    display: grid;
    gap: 25px;
}

.detail-section h4 {
    color: var(--primary-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.detail-section p {
    margin: 8px 0;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.detail-table th,
.detail-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.detail-table th {
    background: var(--bg-color);
    font-weight: 600;
}

@media print {

  /* ============================= */
  /* PAGE SETUP */
  /* ============================= */
  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  html, body {
    background: white;
    overflow: hidden;
  }

  /* ============================= */
  /* HIDE NON-PRINT ELEMENTS */
  /* ============================= */
  .no-print,
  .navbar,
  .container,
  .print-buttons {
    display: none !important;
  }

  /* ============================= */
  /* MAIN CONTAINER */
  /* ============================= */
  .printable-invoice {
    display: block !important;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    background: white;
  }

  * {
    transform: none !important;
  }

  /* ============================= */
  /* HEADER */
  /* ============================= */
  .invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 20px;
    page-break-inside: avoid;
  }

  .invoice-logo {
    width: 140px;
    flex-shrink: 0;
  }

  /* ============================= */
  /* BILL + TAX INFO */
  /* ============================= */
  .bill-invoice-row {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
    page-break-inside: avoid;
  }

  /* ============================= */
  /* WATERMARK */
  /* ============================= */
  .invoice-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
  }

  .watermark-logo {
    width: 320px;
    height: 320px;
    object-fit: contain;
  }

  /* ============================= */
  /* TABLE */
  /* ============================= */
  .invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    position: relative;
    z-index: 5;
    page-break-inside: avoid;
  }

  .invoice-table th {
    border-bottom: 2px solid #000;
    background: transparent;
  }

  .invoice-table td {
    background: transparent;
  }

  /* ============================= */
  /* FOOTER LAYOUT (KEY FIX) */
  /* ============================= */
  .invoice-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    page-break-inside: avoid;
  }

  .payment-details {
    flex: 1;
  }

  .invoice-signature {
    flex: 0 0 auto;
    margin-top: 40px;
  }

  .invoice-totals {
    flex: 0 0 40%;
    max-width: 350px;
  }

  /* ============================= */
  /* TOTAL STYLES */
  /* ============================= */
  .total-row.grand-total {
    background: transparent !important;
    border: none !important;
    font-weight: 700;
  }
}


/* ============================= */
/* MOBILE / TABLET PRINT */
 /* ============================= */
@media print and (max-width: 794px) {

  @page {
    size: A4;
    margin: 12mm;
  }

  .printable-invoice {
    padding: 10px;
    font-size: 12px;
  }

  /* Stack header */
  .invoice-header {
    flex-direction: column;
    gap: 10px;
  }

  .invoice-logo {
    width: 80px;
    align-self: flex-end;
  }

  /* Stack bill details */
  .bill-invoice-row {
    flex-direction: column;
    gap: 15px;
  }

  /* Stack footer but keep order */
  .invoice-footer {
    flex-direction: column;
  }

  .invoice-totals {
    order: 1;
    max-width: 100%;
  }

  .invoice-signature {
    order: 2;
    margin-top: 30px;
  }

  /* Table */
  .invoice-table th,
  .invoice-table td {
    font-size: 11px;
    padding: 6px;
  }

  /* Watermark lighter */
  .invoice-watermark {
    opacity: 0.08;
  }

  .watermark-logo {
    width: 240px;
    height: 240px;
  }

  .invoice-header,
  .bill-invoice-row,
  .invoice-table,
  .invoice-footer {
    page-break-inside: avoid;
  }
}
