/* Tisdale App — Light theme only, professional UI
   - Single light logo
   - Mobile drawer menu on phones
   - Sidebar always visible on tablet/desktop
   - Clean tables/forms/buttons
*/

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root{
  color-scheme: light;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;

  /* Canvas */
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef3ff;

  /* Brand */
  --primary: #2563eb;
  --primary-ink: #ffffff;

  /* Text & lines */
  --text: #0f172a;
  --muted: #5b6b86;
  --line: #e6e9f3;

  /* Focus & shadows */
  --focus: #60a5fa;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* Layout */
  --topbar-h: 56px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 72px;

  /* Success colors */
  --success: #059669; /* emerald-600 */
  --success-hover: #10b981; /* emerald-500 */
}

*,
*::before,
*::after { box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font: 400 16px/1.5 var(--font-sans);
  background:
    radial-gradient(1100px 600px at 12% -8%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 55%),
    radial-gradient(800px 480px at 120% 8%, color-mix(in srgb, var(--focus) 7%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a{ color: var(--primary); text-underline-offset: 2px; text-decoration: none; }
a:hover{ text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference){
  * { transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .12s ease; }
}

/* ===== App Shell ===== */
.app{
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100vh;
}

/* Sidebar */
.sidebar{
  grid-area: sidebar;
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  border-right: 1px solid var(--line);
  padding: 14px 12px 16px;
  position: sticky; top: 0; height: 100vh;
  z-index: 3;
  overflow-y: auto;
}
.brand{ display:flex; align-items:center; gap:10px; margin-bottom: 10px; }
.brand .logo{ display:block; width: 100%; max-width: 180px; height: auto; }

.nav{
  display:flex; flex-direction: column; gap: 6px; margin-top: 8px;
}
.nav a{
  display:flex; align-items:center; gap:10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text);
  border: 1px solid transparent;
  background: transparent;
}
.nav a:hover{ background: color-mix(in srgb, var(--primary) 8%, transparent); text-decoration: none; }
.nav a.active{
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
}
.nav .label{ white-space: nowrap; }

.nav-group {
  margin-top: 12px;
}
.nav-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 8px 4px;
}
.nav-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin: 8px 8px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-group a {
  padding-left: 22px;
}
.nav-group a:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.nav-group a.active {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
}

/* Topbar */
.topbar{
  grid-area: topbar;
  display:flex; align-items:center; justify-content:space-between;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.65), rgba(255,255,255,.35));
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(6px);
  position: sticky; top: 0; z-index: 4;
}
.icon-btn{
  appearance:none; border:1px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 16px;
}
.icon-btn:hover{ background: color-mix(in srgb, var(--primary) 10%, var(--surface)); }
.title-wrap{ display:flex; align-items:center; gap:10px; min-width: 0; }
.page-title{ font-weight: 700; font-size: clamp(1rem, 0.9rem + .6vw, 1.25rem); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-ghost{
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px; border-radius: var(--r-sm);
  cursor: pointer;
}
.btn-ghost:hover{ background: color-mix(in srgb, var(--primary) 8%, transparent); }

/* Main */
.main{
  grid-area: main; position: relative; min-height: 0; /* allow iframe to size */
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 18%, var(--bg)) 0%, var(--bg) 120%);
}
#contentFrame{ width:100%; height: calc(100dvh - var(--topbar-h)); border:0; display:block; background: transparent; }

/* Scrim for mobile drawer */
.scrim{
  position: fixed; inset: 0; background: rgba(0,0,0,.25); border: 0;
  display: none;
}

/* ===== Responsive ===== */
/* Mobile: sidebar becomes drawer; full-width topbar */
@media (max-width: 860px){
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar{
    position: fixed; inset: var(--topbar-h) auto 0 0;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-sm);
    height: calc(100vh - var(--topbar-h));
  }
  body.drawer-open .sidebar{ transform: translateX(0); }
  body.drawer-open .scrim{ display:block; }
}

/* Menu button visibility */
@media (max-width: 860px){
  #menuBtn{ display:inline-flex; }
}
@media (min-width: 861px){
  #menuBtn{ display:none; }
}

/* Ensure sidebar is always visible on tablet/desktop */
@media (min-width: 861px){
  .sidebar{ transform: none !important; }
}

/* ===== Tables / Controls / Cards (light, clean) ===== */
.table{ width:100%; border-collapse: collapse; background: transparent; }
.table thead th{
  font-size:.8rem; font-weight:600; color:var(--muted);
  text-transform:uppercase; letter-spacing:.04em;
  background: linear-gradient(180deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, transparent));
  border-bottom: 1px solid var(--line);
}
.table tbody td{ border-bottom: 1px solid var(--line); }
.table tbody tr:hover td{ background: color-mix(in srgb, var(--primary) 6%, transparent); }

/* Compact grid helpers kept for Schedule 4s */
.table.compact th, .table.compact td {
  padding: 6px 10px; vertical-align: middle; white-space: nowrap; line-height: 1.45;
}
.table.compact th { font-size: 12.75px; font-weight: 600; letter-spacing: .02em; }
.table.compact td { font-size: 14.25px; }

.col-date, .col-unit, .col-odo, .col-tech, .col-loc, .col-view { white-space: nowrap; }
.col-date { width: 200px; }
.col-unit { width: 130px; }
.col-odo  { width: 140px; text-align: left; }
.col-tech { max-width: 110px; }
.col-loc  { max-width: 360px; }
.col-view { width: 56px; text-align: center; }

.tabular-nums, #grid td.col-odo, #grid th.col-odo { font-variant-numeric: tabular-nums; }
.cell-ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Inputs */
label{ font-weight:600; display:block; margin-bottom:6px; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="url"],
input[type="tel"],
select,
textarea {
  display:block; width:100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 10px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
}
input::placeholder, textarea::placeholder{ color: var(--muted); }
input:focus, select:focus, textarea:focus{
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent);
}

/* Buttons */
.btn, .btn-ghost {
  font-weight: 600;
  border-radius: var(--r-md);
}
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:.5rem;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 88%, white 8%), var(--primary));
  color: var(--primary-ink); cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn:hover{ filter: brightness(1.04); }
.btn:active{ transform: translateY(1px); }
.btn.primary {
  background-color: var(--success);
  color: white;
}

.btn.primary:hover {
  background-color: var(--success-hover);
}
.btn-ghost{
  background: transparent; color: var(--text);
  border: 1px solid var(--line);
  padding: 8px 12px;
}

/* Search box */
.search{
  display:flex; align-items:center; gap:8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 8px 10px;
}
.search input{ border:none; outline:none; background:transparent; width:100%; color:var(--text); font:inherit; }
.search input::placeholder{ color: var(--muted); }

/* ===== Desktop-only compact tuning for Schedule 4 grid ===== */
@media (min-width: 861px){
    #grid {
    width: 85%;
    margin: 0 auto;
  }
  /* Make compact tables tighter on desktop */
  .table.compact th, .table.compact td{
    padding: 5px 8px;
    line-height: 1.35;
  }
  .table.compact th{ font-size: 12px; }
  .table.compact td{ font-size: 13px; }

  /* Tighter column widths for desktop */
  .table.compact .col-date { width: 170px; }
  .table.compact .col-unit { width: 110px; }
  .table.compact .col-odo  { width: 120px; }
  .table.compact .col-tech { max-width: 100px; }
  .table.compact .col-loc  { max-width: 320px; }
  .table.compact .col-view { width: 48px; }

  /* Softer hover on big grids */
  .table.compact tbody tr:hover td{ background: color-mix(in srgb, var(--primary) 4%, transparent); }
  
}

/* ===== Mobile tweaks for Schedule 4 grid ===== */
@media (max-width: 640px) {
  #grid { width: 100%; table-layout: fixed; }
  .col-odo, .col-tech, .col-loc { display: none; }
  .col-date { width: 50%; }
  .col-unit { width: 25%; }
  .col-view { width: 25%; text-align: right; }
  .table.compact th, .table.compact td { padding: 8px 10px; }
}

.hidden {
  display: none !important;
}

/* ===== Modals (global) =====
   Framework-independent popups with grey backdrop and centered panel.
   Toggle visibility by adding/removing the `.open` class on `.modal`.
*/
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal.open { display: flex; }
.modal .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.50);
}
.modal .panel {
  position: relative;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  width: min(92vw, 420px);
  padding: 20px;
  border: 1px solid var(--line);
}
.modal .panel h3 {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 1.05rem;
}
.modal .panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .925rem;
}
.modal .actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }

/* Contenteditable grid cell hint */
td[contenteditable="true"] { background: #fffef7; outline: none; }
td[contenteditable="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }

/* ====== Layout width constraints for pages with .container ====== */
/* Keep content readable on desktop/tablet; still full-bleed on phones. */
:root { --content-max: 1180px; }

.container {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* Optional utility for even tighter sections (apply as needed) */
.narrow {
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}

/* Phones: allow full width with a bit less padding */
@media (max-width: 768px) {
  .container {
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ================================================================
   Daily Report / Worksheet tuning (global + reusable)
   - Keep controls short & consistent inside compact tables
   - Make MultiSelect height match inputs
   - Clean 24h time selects
   ================================================================ */

/* Inputs/selects inside compact tables: consistent short height */
.table.compact input[type="number"],
.table.compact input[type="text"],
.table.compact select {
  height: 28px;
  line-height: 26px;
  font-size: 14px;
}

/* 24-hour time pair (HH : MM) */
.time24 { display: flex; align-items: center; gap: 2px; }
.time24 .time-select {
  width: 6.2ch;          /* two digits + breathing room */
  min-width: 6.2ch;
  text-align: center;
  padding: 2px 4px;
  height: 28px;
  line-height: 26px;
}
.time24 .time-sep { padding: 0 2px; }
