:root {
  --primary: #2563eb;
  --bg: #f5f7fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
}

.app-header {
  position: relative;
  text-align: center;
  padding: 12px 0;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

.app-header img {
  display: block;
  margin: 0 auto;
  width: 220px;       /* Good size for 300x122 logo */
  max-width: 90%;
  height: auto;
}

/* ================= COMMON PAGES ================= */
.page {
  display: none;
  padding: 16px;
  max-width: 500px;
  margin: auto;
}

.page.active { display: block; }

h2 {
  text-align: center;
  margin-bottom: 12px;
}

/* ===== FORM CONTROLS (FULL WIDTH) ===== */
/* 🔥 MODERN INPUT + SELECT (UNIFIED STYLE) */

input,
select {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: white;
  transition: all 0.2s ease;
}

/* 🔥 FOCUS EFFECT */
input:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

/* 🔥 SELECT CUSTOM ARROW */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;

  background-image: url("data:image/svg+xml;utf8,<svg fill='%23666' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

/* 🔥 HOVER EFFECT */
input:hover,
select:hover {
  border-color: #9ca3af;
}

/* 🔥 READONLY */
input[readonly] {
  background: #f3f4f6;
  cursor: not-allowed;
}

/* 🔥 PLACEHOLDER */
input::placeholder {
  color: #9ca3af;
}

/* 🔥 NUMBER CLEAN */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  appearance: textfield;        /* standard */
  -webkit-appearance: none;     /* Chrome, Safari */
  -moz-appearance: textfield;   /* Firefox */
}

button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: .2s;
}

button:hover{
    opacity:.9;
}

button.secondary {
  background: #444;
}

/* ================= BROWSE PAGE ONLY ================= */
.page.browse {
  max-width: 100%;
  margin: 0;
}

.page.browse .page-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
}

/* ---- TABLE ---- */
.table-wrapper {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;              /* take remaining height */
}


table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: #f9fafb;
  color: #374151;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  position: relative;
}

/* resize handle */
.resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

tbody td {
  padding: 12px 14px;
  border: 1px solid #f1f5f9;
}

thead th:not(:last-child),
tbody td:not(:last-child) {
  border-right: 2px solid #d1d5db;
}

tbody tr:hover {
  background: #f8fafc;
}
.table-wrapper table {
  border: 1px solid #e5e7eb;
}
/* ===== SMALL ACTION BUTTONS ===== */
.action-btn {
  width: auto;
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  margin: 0;
}

.action-btn.delete {
  color: #dc2626;
}

/* prevent wrapping */
td:last-child {
  white-space: nowrap;
}

/* ---- MOBILE CARDS ---- */
.mobile-cards {
  display: none;
}

.card {
  background: white;
  padding: 12px;
  margin: 10px 0;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* card buttons should be small */
.card button {
  width: auto;
  padding: 6px 10px;
  font-size: 14px;
  margin-right: 6px;
}

.browse-header {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 12px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .table-wrapper { display: none; }
  .mobile-cards { display: block; }
}

.browse-top{
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;

    position:sticky;
    top:0;
    background:var(--bg);
    z-index:5;
    padding-bottom:8px;
}

.page:not(.browse) button {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  font-size: 16px;
}

/* 🌙 DARK MODE ONLY (ADD THIS BELOW YOUR EXISTING CSS) */

body.dark {
  --bg: #172137;
  --text: #f9fafb;
  --card: #031123;
  --border: #374151;
}

/* apply colors */
body.dark {
  background: var(--bg);
  color: var(--text);
}

/* header */
body.dark .app-header {
  background: var(--card);
  border-color: var(--border);
}

/* inputs */
body.dark input,
body.dark select {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

/* table */
body.dark .table-wrapper {
  background: var(--card);
  border-color: var(--border);
}

body.dark thead th {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

body.dark tbody td {
  border-color: var(--border);
}

body.dark tbody tr:hover {
  background: rgba(255,255,255,0.05);
}

/* cards */
body.dark .card{
    background:var(--card);
    border:1px solid var(--border);
}

/* top bar */
body.dark .browse-top {
  background: var(--bg);
}

/* scrollbar (important) */
body.dark ::-webkit-scrollbar-track {
  background: #111827;
}

/* LEFT BACK BUTTON */
#backBtn {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 14px;
}

/* RIGHT DARK MODE BUTTON */
.app-header button:last-child {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 14px;
}

/* ===== SCROLLBAR DARK MODE ===== */

/* Chrome, Edge, Safari */
body.dark ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.dark ::-webkit-scrollbar-thumb {
  background: #4b5563; /* grey thumb */
  border-radius: 6px;
}

body.dark ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* Firefox */
body.dark {
  scrollbar-color: #4b5563 #111827;
}

.upload-status{
    margin-top:6px;
}

progress{
    width:100%;
}

.title-zero{
    margin:0;
}

.row-count{
    font-size:13px;
    color:#555;
}

.toolbar{
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    align-items:center;
}

.machine-count{
    margin:10px 0;
    font-weight:bold;
}

.customer-row{
    cursor:pointer;
}

#pdfOverlay{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.85);
    z-index:9999;
    padding:20px;
}

.pdf-container{
    background:#fff;
    width:100%;
    height:100%;
    border-radius:10px;
    display:flex;
    flex-direction:column;
}

.pdf-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:10px 15px;
    border-bottom:1px solid #ddd;
}

.pdf-close{
    width:auto;
    padding:6px 12px;
}

#pdfViewer{
    flex:1;
    width:100%;
    border:none;
}