:root {
  --primary: #2563eb;
  --bg: #e4dad6;
}

* { 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 #868687;
}

.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;
  position: relative;
  flex: 1;              /* take remaining height */
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

thead th {
  background: #f9fafb;
  color: #374151;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1000;
  background-clip: padding-box;
}

th {
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

/* resize handle */
.resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
    z-index: 10;
}

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) */

html.dark {
  color-scheme: dark;
}

html:not(.dark) {
  color-scheme: light;
}

html.dark {
  --bg: #172137;
  --text: #f9fafb;
  --card: #031123;
  --border: #374151;
}

/* apply colors */
html.dark {
  background: var(--bg);
  color: var(--text);
}

/* header */
html.dark .app-header {
  background: var(--card);
  border-color: var(--border);
}

/* inputs */
html.dark input,
html.dark select {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

/* Date input */
input[type="date"] {
    color: #111827;
    color-scheme: light;
}

/* Dark mode */
html.dark input[type="date"] {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
    color-scheme: dark;
}

/* Calendar icon */
html.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Chrome / Edge */
html.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(100%);
    opacity: 1;
}

/* table */
html.dark .table-wrapper {
  background: var(--card);
  border-color: var(--border);
}

html.dark thead th {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

html.dark tbody td {
  border-color: var(--border);
}

html.dark tbody tr:hover {
  background: rgba(255,255,255,0.05);
}

/* cards */
html.dark .card{
    background:var(--card);
    border:1px solid var(--border);
}

/* top bar */
html.dark .browse-top {
  background: var(--bg);
}

/* scrollbar (important) */
html.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 */
html.dark ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html.dark ::-webkit-scrollbar-thumb {
  background: #4b5563; /* grey thumb */
  border-radius: 6px;
}

html.dark ::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* Firefox */
html.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;
}

.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;
}

/* Common container */
.container{
    max-width:900px;
    margin:20px auto;
    padding:25px;
    background:#fff;
    border-radius:10px;
    box-shadow:0 2px 10px rgba(0,0,0,.12);
}

html.dark .container{
    background:var(--card);
    color:var(--text);
}

/* ===== Service Report Entry ===== */

.service-grid{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:18px;
    align-items:start;
}

.service-full{
    grid-column:1 / -1;
}

.service-grid label{
    display:block;
    margin-bottom:6px;
    font-weight:600;
}

.service-grid input,
.service-grid textarea{
    width:100%;
}

.service-grid textarea{
    min-height:120px;
    resize:vertical;
}

.service-actions{
    display:flex;
    justify-content:center;
    gap:12px;
    margin-top:24px;
}

.service-actions button{
    min-width:180px;
}

#serviceUploadProgress{
    width:100%;
    margin-top:10px;
}

#serviceUploadStatus{
    margin-top:8px;
    font-weight:600;
}

@media (max-width:768px){

.service-grid{
    grid-template-columns:1fr;
}

.service-full{
    grid-column:1;
}

.service-actions{
    flex-direction:column;
}

.service-actions button{
    width:100%;
}

}

input,
select,
textarea{
    width:100%;
    padding:12px;
    margin:8px 0;
    font-size:16px;
    border-radius:8px;
    border:1px solid #d1d5db;
    background:white;
}

input:focus,
select:focus,
textarea:focus{
    outline:none;
    border-color:#2563eb;
    box-shadow:0 0 0 2px rgba(37,99,235,.2);
}

html.dark input,
html.dark select,
html.dark textarea{
    background:var(--card);
    color:var(--text);
    border-color:var(--border);
}

/* ===== Service Report Search ===== */

.service-search{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:nowrap;
}

.service-search input[type="text"]{
    flex:1;
    min-width:300px;
}

.service-search input[type="date"]{
    width:160px;
    flex:none;
}

@media (max-width:768px){

.service-search{
    flex-wrap:wrap;
}

.service-search input{
    width:100% !important;
}

}