/* ==========================================
   MR DOC - Web Version
   Palette matched to DC Stock Manager:
   BG #1E1E1E | SIDEBAR #111111 | CARD #2B2B2B
   GREEN #00E676 | BLUE #2196F3 | RED #F44336
   ORANGE #FF9800 | PURPLE #7C4DFF | CYAN #4FC3F7
   ========================================== */

:root {
  --bg: #1E1E1E;
  --sidebar: #111111;
  --card: #2B2B2B;
  --white: #FFFFFF;
  --green: #00E676;
  --green-dark: #00A86B;
  --blue: #2196F3;
  --red: #F44336;
  --red-dark: #D9534F;
  --orange: #FF9800;
  --yellow: #FFC107;
  --purple: #7C4DFF;
  --cyan: #4FC3F7;
  --gray: #BDBDBD;
  --border: #424242;

  /* Boutique accents - dashboard cards only */
  --charcoal-bg: #241F1B;
  --charcoal-card: #2E2621;
  --acc-gold: #D4AF37;
  --acc-gold-soft: rgba(212, 175, 55, 0.16);
  --acc-rose: #E0607E;
  --acc-rose-soft: rgba(224, 96, 126, 0.16);
  --acc-teal: #2FA8A0;
  --acc-teal-soft: rgba(47, 168, 160, 0.16);
  --acc-amethyst: #9B7EDE;
  --acc-amethyst-soft: rgba(155, 126, 222, 0.18);
  --acc-sapphire: #4FA8E8;
  --acc-sapphire-soft: rgba(79, 168, 232, 0.16);
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
}

button { font-family: inherit; }

/* ---------- Login page ---------- */
body.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0f0f0f radial-gradient(circle at 50% 20%, #232323 0%, #0f0f0f 70%);
  padding: 20px;
}

.login-container {
  max-width: 360px;
  width: 100%;
  margin: 0 auto;
  background: #202020;
  padding: 26px 30px 22px;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  text-align: center;
}

.login-logo {
  max-width: 140px;
  margin-bottom: 14px;
  border-radius: 12px;
}

.login-container h1 {
  margin: 6px 0 18px;
  font-size: 22px;
  letter-spacing: 0.5px;
}

.login-container form { display: flex; flex-direction: column; text-align: left; }

.login-container label { margin-top: 14px; font-size: 13px; color: #DDDDDD; }

.login-container input {
  padding: 10px 12px;
  margin-top: 5px;
  border: none;
  border-radius: 4px;
  font-size: 15px;
  background: #fff;
  color: #111;
}

.login-container button {
  margin-top: 22px;
  padding: 11px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.login-container button:active { filter: brightness(0.85); }

.error-text { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

.credit-footer {
  margin-top: 18px;
  margin-bottom: 0;
  font-size: 12px;
  color: var(--gray);
  text-align: center;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--card);
  color: #fff;
  padding: 0 20px;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.app-header h2 { font-size: 18px; margin: 0; letter-spacing: 0.3px; }

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

.app-header nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.app-header nav a, .app-header nav button {
  color: #fff;
  background: #3a3a3a;
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: bold;
  transition: background 0.15s ease;
}

.app-header nav a:hover, .app-header nav button:hover { background: #474747; }

#logoutBtn { background: var(--red-dark); border-color: var(--red-dark); }
#logoutBtn:hover { background: #c9302c; }

#userLabel { color: var(--cyan); font-weight: bold; font-size: 13px; margin: 0 4px; }

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ---------- Dashboard grid (boutique theme) ---------- */
body.dashboard-page {
  background: var(--charcoal-bg) radial-gradient(circle at 50% 0%, #33291F 0%, var(--charcoal-bg) 70%);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
  font-family: 'Jost', Arial, sans-serif;
}

.sidebar {
  --card-accent: var(--cyan);
  --card-accent-soft: rgba(79, 195, 247, 0.16);
  background: var(--charcoal-card);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--card-accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.sidebar.accent-gold { --card-accent: var(--acc-gold); --card-accent-soft: var(--acc-gold-soft); }
.sidebar.accent-rose { --card-accent: var(--acc-rose); --card-accent-soft: var(--acc-rose-soft); }
.sidebar.accent-teal { --card-accent: var(--acc-teal); --card-accent-soft: var(--acc-teal-soft); }
.sidebar.accent-amethyst { --card-accent: var(--acc-amethyst); --card-accent-soft: var(--acc-amethyst-soft); }
.sidebar.accent-sapphire { --card-accent: var(--acc-sapphire); --card-accent-soft: var(--acc-sapphire-soft); }

.sidebar h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 16px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 25px;
  letter-spacing: 0.3px;
  color: var(--card-accent);
}

.card-title-group { display: flex; align-items: center; gap: 10px; }

.container-total {
  font-family: 'Jost', Arial, sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--card-accent);
  background: var(--card-accent-soft);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--card-accent-soft);
  font-size: 16px;
  flex-shrink: 0;
}

.ledger-row {
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--border);
}
.ledger-row:first-of-type { padding-top: 0; margin-top: 0; border-top: none; }

.ledger-row h4 {
  margin: 0 0 10px;
  color: var(--card-accent);
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 18px;
}

.add-toggle-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 9px 14px;
  background: transparent;
  border: 1.5px solid var(--card-accent);
  color: var(--card-accent);
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.add-toggle-btn:hover { background: var(--card-accent-soft); }

.add-form-collapse {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.32s ease, opacity 0.25s ease, margin-top 0.32s ease;
}
.add-form-collapse.open {
  max-height: 400px;
  opacity: 1;
  margin-top: 12px;
}

.form-actions { display: flex; gap: 8px; flex-basis: 100%; margin-top: 2px; }

.entry-form .btn-save, .entry-form .btn-cancel {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.entry-form .btn-save { background: var(--card-accent); color: #1a1512; }
.entry-form .btn-cancel { background: #555; color: #fff; }
.entry-form .btn-save:active, .entry-form .btn-cancel:active { filter: brightness(0.85); }

.entry-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.entry-form input, .entry-form select {
  flex: 1 1 120px;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 14px;
}

.entry-form button {
  padding: 8px 16px;
  background: var(--green-dark);
  color: #fff;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.entry-form button:active { filter: brightness(0.85); }

.entry-list { list-style: none; padding: 0; margin: 0; }

.entry-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 8px;
}
.entry-list li:hover { background: rgba(255,255,255,0.03); }
.entry-list li:last-child { border-bottom: none; }

.entry-list button {
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: bold;
  padding: 5px 10px;
  margin-left: 6px;
  transition: filter 0.15s ease;
}
.entry-list button.btn-red { background: var(--red-dark); }
.entry-list button:active { filter: brightness(0.85); }

.entry-info { display: flex; flex-direction: column; gap: 3px; }
.entry-main { font-size: 14px; }
.entry-deadline { font-size: 12px; color: var(--gray); }
.entry-amount { color: var(--card-accent, var(--cyan)); font-weight: 700; }

.empty-state { text-align: center; color: var(--gray); padding: 20px 10px; justify-content: center; }

/* Activity History list */
.history-list li { flex-wrap: wrap; }
.history-time { color: var(--gray); font-size: 12px; white-space: nowrap; }

/* ---------- Modal (Salary / Shop Value / Manage Users / History) ---------- */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal.hidden { display: none; }

.modal-box {
  position: relative;
  background: var(--card);
  padding: 22px;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-box h3 { margin-top: 0; color: var(--cyan); }

.close-modal {
  margin-top: 14px;
  padding: 8px 16px;
  cursor: pointer;
  background: #555;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-weight: bold;
}
.close-modal:hover { background: #666; }

.modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  margin-top: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#historyModal h3 { padding-right: 40px; }
#salesModal h3 { padding-right: 40px; }

.works-table { width: 100%; border-collapse: collapse; margin-top: 14px; }

.works-table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--cyan);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.works-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.works-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.works-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.works-table input[type="checkbox"]:disabled { cursor: default; opacity: 0.6; }

/* ---------- Sales modal (stats + chart) ---------- */
.sales-modal-box { max-width: 700px; }

.sales-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sales-stat-box {
  flex: 1;
  min-width: 140px;
  background: rgba(79, 195, 247, 0.08);
  border: 1px solid var(--cyan);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}

.sales-stat-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 4px;
}

.sales-stat-value { display: block; font-size: 20px; font-weight: 700; color: var(--cyan); }

.sales-chart-wrap {
  height: 240px;
  background: #191919;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

.sales-selected-info {
  text-align: center;
  font-size: 13px;
  color: var(--cyan);
  font-weight: 600;
  min-height: 18px;
  margin: 0 0 14px;
}

/* ---------- Invoice page (edit form) ---------- */
.invoice-page {
  max-width: 860px;
  margin: 20px auto;
  background: var(--card);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.invoice-customer-fields {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.invoice-customer-fields input {
  flex: 1;
  min-width: 150px;
  padding: 9px 10px;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #111;
}

.table-scroll { overflow-x: auto; margin-bottom: 12px; }

#itemsTable {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
}

#itemsTable th, #itemsTable td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  font-size: 14px;
}

#itemsTable th { color: var(--cyan); }

#itemsTable input, #itemsTable select {
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #111;
}

#addItemBtn {
  padding: 8px 16px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: var(--blue);
  margin-top: 6px;
}

.remove-item {
  background: var(--red-dark);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 4px 9px;
}

.invoice-totals { margin-top: 16px; font-size: 15px; }
.invoice-totals label { color: var(--gray); }
.invoice-totals input {
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: #fff;
  color: #111;
  width: 90px;
}

#invoiceForm > button[type="submit"] {
  padding: 9px 18px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: var(--green-dark);
  margin-top: 10px;
}

#downloadJpegBtn {
  padding: 9px 18px;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  cursor: pointer;
  color: #fff;
  background: var(--purple);
  margin-top: 16px;
}

/* ---------- Printable invoice (kept light on purpose - this is what
   gets exported as a JPEG and handed to the customer) ---------- */
.invoice-print {
  --inv-ink: #1C1A18;
  --inv-black: #0B0B0C;
  --inv-gold: #C9A227;
  --inv-gold-light: #E4C766;
  --inv-ivory: #FBF7EE;
  --inv-wine: #7A2E3A;
  --inv-wine-deep: #5A1F29;
  --inv-bronze: #B08D57;
  --inv-line: rgba(28, 26, 24, 0.14);

  font-family: 'Jost', Arial, sans-serif;
  color: var(--inv-ink);
  background: var(--inv-ivory);
  width: 794px;
  max-width: 100%;
  min-height: 1123px;
  margin: 20px auto 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Subtle dotted watermark pattern across the invoice background.
   A real element, not a ::before pseudo-element: html2canvas (used for
   the JPEG export) silently fails to render gradients on pseudo-elements. */
.ip-pattern {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Ccircle cx='60' cy='80' r='2.5' fill='%237A2E3A'/%3E%3Ccircle cx='340' cy='160' r='2.5' fill='%23C9A227'/%3E%3Ccircle cx='140' cy='340' r='2.5' fill='%237A2E3A'/%3E%3Ccircle cx='280' cy='360' r='2.5' fill='%23C9A227'/%3E%3C/svg%3E");
  background-size: 400px 400px;
  z-index: 0;
}

.invoice-print > *:not(.ip-pattern) { position: relative; z-index: 1; }

.ip-banner { line-height: 0; border-bottom: 4px solid var(--inv-gold); }
.ip-banner img { width: 100%; height: auto; display: block; }

.ip-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 28px 32px 16px;
  border-bottom: 1px solid var(--inv-line);
}

.ip-title-row h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 38px;
  letter-spacing: 3px;
  margin: 0;
  color: var(--inv-wine-deep);
  text-transform: uppercase;
}

.ip-sub {
  font-size: 11px;
  letter-spacing: 2.5px;
  color: var(--inv-bronze);
  text-transform: uppercase;
  display: block;
  margin-top: 4px;
}

.ip-meta { text-align: right; font-size: 13px; line-height: 1.9; }
.ip-meta b { color: var(--inv-wine-deep); }
.ip-inv-no {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--inv-gold);
  letter-spacing: 1px;
}

.ip-cust-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 22px 32px;
  background: linear-gradient(180deg, rgba(201, 162, 39, 0.06), transparent);
}

.ip-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--inv-bronze);
  margin-bottom: 6px;
  display: block;
}

.ip-value { font-size: 15px; font-weight: 500; color: var(--inv-ink); }

.ip-items { padding: 6px 32px 8px; }

#printItemsTable { width: 100%; border-collapse: collapse; }

#printItemsTable thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--inv-ivory);
  background: var(--inv-wine-deep);
  padding: 10px 12px;
}

#printItemsTable thead th:last-child, #printItemsTable tbody td:last-child { text-align: right; }
#printItemsTable thead th:nth-child(3), #printItemsTable tbody td:nth-child(3) { text-align: center; }

#printItemsTable tbody td {
  padding: 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--inv-line);
}

#printItemsTable tbody tr:nth-child(odd) { background: rgba(201, 162, 39, 0.05); }

.ip-material-cell { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.ip-material-cell svg { flex-shrink: 0; color: var(--inv-wine); }
.ip-line-total { font-weight: 600; color: var(--inv-wine-deep); }

.ip-totals-wrap { display: flex; justify-content: flex-end; padding: 18px 32px 6px; }
.ip-totals { width: 260px; font-size: 13px; }

.ip-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--inv-line);
}

.ip-discount span:last-child { color: var(--inv-wine); }

.ip-final {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--inv-wine-deep);
  color: var(--inv-ivory);
  border: 1px solid var(--inv-gold);
}

.ip-amt {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--inv-gold-light);
  letter-spacing: 1px;
}

.ip-lbl { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; }

.ip-seal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 22px 32px 8px;
}

.ip-thanks {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--inv-wine-deep);
}

.ip-seal {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--inv-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  color: var(--inv-gold);
  font-weight: 700;
  font-size: 10px;
  text-align: center;
  letter-spacing: 1px;
  line-height: 1.2;
  transform: rotate(-8deg);
  flex-shrink: 0;
}

.ip-footer {
  margin-top: auto;
  padding-top: 18px;
  background: var(--inv-black);
  color: var(--inv-ivory);
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 3px solid var(--inv-gold);
}

.ip-tag {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--inv-gold-light);
  font-size: 14px;
}

.ip-contact { font-size: 11.5px; color: #D9D2C2; display: flex; gap: 14px; flex-wrap: wrap; }

.hidden { display: none; }

/* ---------- Responsive: tablet and mobile ---------- */
@media (max-width: 1024px) {
  /* Show the four dashboard containers one at a time, stacked, instead of 2x2 */
  .dashboard-grid { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
}

@media (max-width: 640px) {
  .app-header {
    height: auto;
    position: static;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .app-header nav { width: 100%; }
  .app-header nav a, .app-header nav button { flex: 1 1 auto; text-align: center; }

  .login-container { padding: 22px 20px 18px; }

  .invoice-page { padding: 18px 14px; }
  .invoice-customer-fields input { min-width: 100%; }

  .modal-box { padding: 18px 16px; width: 94%; }

  .entry-form label { flex-basis: 100%; margin-top: 2px; }

  .ip-title-row { padding: 20px 18px 12px; }
  .ip-title-row h1 { font-size: 28px; }
  .ip-cust-row { grid-template-columns: 1fr; padding: 16px 18px; }
  .ip-items { padding: 6px 18px 8px; }
  .ip-totals-wrap { padding: 14px 18px 6px; }
  .ip-seal-row { padding: 18px 18px 8px; }
  .ip-footer { padding: 16px 18px; }
}
