/* ============================================================
   Olus Machine Management System — App Styles
   ============================================================ */

/* ── Variables ──────────────────────────────────────────── */
:root {
  --brand:       #166534;
  --brand-dark:  #14532d;
  --brand-light: #dcfce7;
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --sidebar-w:   240px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:   0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; touch-action: manipulation; }
input, select, textarea, button { font: inherit; touch-action: manipulation; }
a { color: var(--brand); text-decoration: none; }

/* ── Utilities ──────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.required { color: var(--danger); }

/* ── Loading screen ─────────────────────────────────────── */
.loading-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: #14532d; color: #fff; z-index: 9999;
}
.loading-logo { display: flex; align-items: center; justify-content: center; }
.loading-logo-img { width: 220px; mix-blend-mode: luminosity; opacity: .92; }
.loading-subtext { color: rgba(255,255,255,.7); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; margin-top: -4px; }
.loading-text { color: rgba(255,255,255,.45); font-size: .8rem; margin-top: 8px; }

/* ── Offline banner ─────────────────────────────────────── */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--warning); color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; font-size: .875rem; font-weight: 500;
}
.offline-banner svg { width: 16px; height: 16px; }

/* ── View containers ────────────────────────────────────── */
.view { min-height: 100vh; }

/* ─────────────────────────────────────────────────────────
   OPERATOR VIEW
   ───────────────────────────────────────────────────────── */

#view-operator {
  background: linear-gradient(160deg, #14532d 0%, #166534 100%);
  min-height: 100vh;
}

.screen {
  max-width: 480px; margin: 0 auto; padding: 0 16px 32px;
  min-height: 100vh; display: flex; flex-direction: column;
}

.screen-header {
  padding: 48px 0 24px; color: white;
}
.screen-header.branded { text-align: center; }
.landing-logo { width: 200px; mix-blend-mode: luminosity; opacity: .92; margin-bottom: 2px; }
.screen-header.branded .branded-subtitle { color: rgba(255,255,255,.7); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; margin-top: 0; margin-bottom: 8px; }
.screen-header.branded p { color: #94a3b8; margin-top: 4px; }
.screen-header h2 { font-size: 1.25rem; font-weight: 600; }
.screen-header p { color: #94a3b8; font-size: .875rem; margin-top: 4px; }

.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #94a3b8; font-size: .875rem; }

.screen-footer { margin-top: auto; padding: 24px 0 16px; text-align: center; }

/* Back button */
.btn-back {
  background: rgba(255,255,255,.1); border: none; color: white;
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem; margin-bottom: 12px;
}
.btn-back:hover { background: rgba(255,255,255,.2); }

/* Operator grid */
.operator-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  flex: 1;
}
.operator-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg); padding: 20px 12px;
  color: white; cursor: pointer; transition: all .15s;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.operator-btn:hover { background: rgba(255,255,255,.15); border-color: var(--brand); }
.operator-btn:active { transform: scale(.97); }
.operator-btn .avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; font-weight: 700;
}
.operator-btn .op-name { font-weight: 600; font-size: .9rem; text-align: center; }

/* PIN pad */
.pin-dots {
  display: flex; gap: 12px; justify-content: center; margin: 40px 0 8px;
}
.dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); transition: all .15s;
}
.dot.filled { background: var(--brand); border-color: var(--brand); }

.pin-error { color: #fca5a5; text-align: center; font-size: .875rem; margin-bottom: 8px; white-space: pre-line; }
.pin-error--locked { color: #fbbf24; font-size: .95rem; line-height: 1.5; }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  padding: 16px 0;
}
.pin-key {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg); padding: 20px;
  color: white; font-size: 1.4rem; font-weight: 600; cursor: pointer;
  transition: all .1s; user-select: none;
}
.pin-key:hover { background: rgba(255,255,255,.15); }
.pin-key:active { transform: scale(.94); background: rgba(255,255,255,.22); }
.pin-key--clear { color: #94a3b8; font-size: 1rem; }
.pin-key--del { color: #94a3b8; }

/* Machine grid */
.machine-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; flex: 1;
}
.machine-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg); padding: 16px;
  color: white; cursor: pointer; transition: all .15s; text-align: left;
}
.machine-btn:hover { background: rgba(255,255,255,.15); border-color: var(--brand); }
.machine-btn:active { transform: scale(.97); }
.machine-btn .mcode { font-size: .75rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.machine-btn .mname { font-weight: 600; margin: 4px 0; }
.machine-btn .mtype { font-size: .8rem; color: #94a3b8; }
.machine-btn.has-open-job { border-color: #fca5a5; }
.machine-btn .job-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; margin-left: 4px; }

/* Choice screen (Machine Check vs Site Jobs) */
.choice-grid {
  display: flex; flex-direction: column; gap: 16px; flex: 1; justify-content: center;
}
.choice-btn {
  position: relative;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-lg); padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: white; cursor: pointer; transition: all .15s; text-align: center;
}
.choice-btn:hover { background: rgba(255,255,255,.15); border-color: var(--brand); }
.choice-btn:active { transform: scale(.98); }
.choice-icon { font-size: 2.5rem; line-height: 1; margin-bottom: 4px; }
.choice-label { font-size: 1.15rem; font-weight: 700; }
.choice-sub { font-size: .8rem; color: #94a3b8; }
.choice-badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--danger); color: white; font-size: .75rem; font-weight: 700;
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
}

/* Site jobs (operator) */
.site-jobs-list { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.site-job-card {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-lg); padding: 16px;
}
.site-job-title { color: white; font-weight: 600; }
.site-job-desc { color: #94a3b8; font-size: .85rem; margin-top: 4px; }
.site-job-notes { margin-top: 12px; }
.site-job-actions { margin-top: 12px; display: flex; gap: 8px; }

/* Hours input */
.hours-input-row {
  background: rgba(255,255,255,.08); border-radius: var(--radius-lg);
  padding: 16px; margin: 16px 0; color: white;
}
.hours-input-row label { font-size: .875rem; color: #94a3b8; display: block; margin-bottom: 8px; }
.hours-input {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius); padding: 10px 14px; color: white; font-size: 1.1rem;
}
.hours-input::placeholder { color: #64748b; }

/* Check sheet form */
.checksheet-form { display: flex; flex-direction: column; gap: 12px; }

.cs-question {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-lg); padding: 16px;
  transition: border-color .15s;
}
.cs-question.fail { border-color: var(--danger); background: rgba(220,38,38,.1); }
.cs-question.pass { border-color: var(--success); }
.cs-question--active-job { opacity: 0.55; border-color: rgba(255,255,255,.06); background: rgba(255,255,255,.03); }
.cs-question--active-job .cs-q-label { color: rgba(255,255,255,.5); }
.cs-active-job-notice { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.3); border-radius: 6px; font-size: .8rem; color: rgba(255,255,255,.7); }
.cs-active-job-icon { font-size: 1rem; flex-shrink: 0; }
.cs-active-job-status { margin-left: auto; padding: 2px 8px; border-radius: 20px; background: rgba(251,191,36,.2); color: #fbbf24; font-size: .75rem; font-weight: 600; }
.cs-active-job-notice--inline { margin-bottom: 8px; font-size: .78rem; align-items: flex-start; }
.cs-active-job-body { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cs-active-job-detail { font-style: italic; color: rgba(255,255,255,.6); }
.cs-active-job-hint { font-size: .72rem; color: rgba(255,255,255,.4); margin-top: 1px; }
.cs-q-label { color: white; font-weight: 500; margin-bottom: 12px; display: block; }
.cs-q-required { color: #fca5a5; margin-left: 4px; }

/* Pass/Fail toggle */
.pf-toggle { display: flex; gap: 8px; }
.pf-btn {
  flex: 1; padding: 12px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: white; cursor: pointer; font-weight: 600;
  transition: all .15s;
}
.pf-btn.pass-btn.selected { background: var(--success); border-color: var(--success); }
.pf-btn.fail-btn.selected { background: var(--danger); border-color: var(--danger); }
.pf-btn:not(.selected):hover { background: rgba(255,255,255,.1); }

/* Yes/No toggle */
.yn-toggle { display: flex; gap: 8px; }
.yn-btn {
  flex: 1; padding: 12px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,.2);
  background: transparent; color: white; cursor: pointer; font-weight: 600;
  transition: all .15s;
}
.yn-btn.yes-btn.selected { background: var(--brand); border-color: var(--brand); }
.yn-btn.no-btn.selected { background: var(--warning); border-color: var(--warning); }

/* Numeric input */
.cs-numeric {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius); padding: 12px 14px; color: white; font-size: 1rem;
}
.cs-numeric::placeholder { color: #64748b; }

/* Free text */
.cs-text {
  width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius); padding: 12px 14px; color: white; font-size: .9rem;
  resize: vertical; min-height: 80px;
}

/* Fail note */
.fail-note {
  margin-top: 8px;
}
.fail-note-input {
  width: 100%; background: rgba(220,38,38,.15); border: 1px solid rgba(220,38,38,.4);
  border-radius: var(--radius); padding: 10px 14px; color: white; font-size: .875rem;
  resize: vertical; min-height: 64px;
}
.fail-note-input::placeholder { color: #f87171; }

.checksheet-actions { margin-top: 24px; }

/* Success screen */
.success-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px; padding: 32px;
}
.success-icon svg { width: 80px; height: 80px; }
.success-screen h2 { color: white; font-size: 1.5rem; font-weight: 700; }
.success-screen p { color: #94a3b8; text-align: center; }
.job-notice {
  background: rgba(37,99,235,.2); border: 1px solid rgba(37,99,235,.4);
  border-radius: var(--radius-lg); padding: 12px 20px; text-align: center; color: white;
}
.job-notice strong { display: block; margin-bottom: 4px; }
.job-notice span { color: #93c5fd; font-size: .875rem; }

/* ─────────────────────────────────────────────────────────
   STAFF VIEW (Fitter + Management)
   ───────────────────────────────────────────────────────── */

#view-staff { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: #14532d; color: white;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 175; transition: transform .25s;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700; font-size: .95rem;
}
.sidebar-logo svg { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-icon-img { width: 32px; height: 32px; flex-shrink: 0; mix-blend-mode: luminosity; opacity: .9; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: .875rem; }
.user-role { font-size: .75rem; color: #94a3b8; }

.sidebar-nav { list-style: none; flex: 1; padding: 8px 0; overflow-y: auto; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; color: #94a3b8; font-size: .875rem; font-weight: 500;
  border-radius: 6px; margin: 1px 8px; transition: all .15s; cursor: pointer;
}
.sidebar-nav li a:hover { background: rgba(255,255,255,.07); color: white; }
.sidebar-nav li a.active { background: var(--brand); color: white; }
.sidebar-nav li a .nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

/* Mobile top bar (hidden on desktop) */
.topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: #14532d; color: white;
  align-items: center; padding: 0 16px; height: 56px;
  gap: 12px; box-shadow: var(--shadow);
}

/* Sidebar backdrop overlay for mobile */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,.45);
}
.topbar-menu { background: none; border: none; color: white; font-size: 1.3rem; cursor: pointer; }
.topbar-title { flex: 1; font-weight: 600; font-size: 1rem; }
.topbar-status { font-size: .75rem; color: #94a3b8; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; padding: 32px;
  max-width: 1280px;
}

/* Page sections */
.page { display: block; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-date { color: var(--text-muted); font-size: .875rem; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-description { color: var(--text-muted); margin-bottom: 20px; max-width: 640px; }

/* Stat cards */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); border-left: 4px solid var(--border);
}
.stat-card--urgent { border-left-color: var(--danger); }
.stat-card--open { border-left-color: var(--brand); }
.stat-card--due { border-left-color: var(--warning); }
.stat-card--compliance { border-left-color: var(--success); }
.stat-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.stat-card--urgent .stat-value { color: var(--danger); }
.stat-card--open .stat-value { color: var(--brand); }
.stat-card--due .stat-value { color: var(--warning); }
.stat-card--compliance .stat-value { color: var(--success); }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* Dashboard grid */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* Cards */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card:last-child { margin-bottom: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-link { font-size: .8rem; color: var(--brand); }
.card-header-standalone { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-header-standalone h3 { font-size: 1.1rem; font-weight: 600; }
.description-readonly { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: .9rem; line-height: 1.5; color: var(--text); min-height: 48px; white-space: pre-wrap; }
.upcoming-service-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.upcoming-service-row:last-child { border-bottom: none; }
.upcoming-service-row:hover { background: var(--surface); margin: 0 -4px; padding-left: 4px; padding-right: 4px; border-radius: var(--radius); }
.upcoming-service-info { display: flex; flex-direction: column; gap: 2px; }
.table-toolbar { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 8px; }
.show-inactive-label { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--text-muted); cursor: pointer; user-select: none; }
.show-inactive-label input[type="checkbox"] { cursor: pointer; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left; padding: 8px 12px; font-weight: 600; font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.table-empty { text-align: center; color: var(--text-muted); padding: 24px !important; }

/* Filters */
.filter-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-select {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: .875rem; cursor: pointer;
}
.filter-input {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; font-size: .875rem; flex: 1; min-width: 160px;
}
.filter-input:focus, .filter-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.badge-urgent { background: #fee2e2; color: var(--danger); }
.badge-high { background: #ffedd5; color: #c2410c; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-low { background: #f0fdf4; color: var(--success); }
.badge-open { background: var(--brand-light); color: var(--brand-dark); }
.badge-progress { background: #fef9c3; color: #854d0e; }
.badge-parts { background: #f3e8ff; color: #7e22ce; }
.badge-completed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #f1f5f9; color: var(--text-muted); }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-inactive { background: #fef9c3; color: #854d0e; }
.badge-decommissioned { background: #f1f5f9; color: var(--text-muted); }
.badge-locked { background: #fef3c7; color: #b45309; }

/* Warning button */
.btn-warning { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; border-radius: var(--radius); padding: 6px 12px; cursor: pointer; font-size: .8rem; font-weight: 500; }
.btn-warning:hover { background: #fde68a; }

/* Admin lockout alerts */
.lockout-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fef2f2; border: 1px solid #fca5a5; border-radius: var(--radius); padding: 10px 14px; font-size: .875rem; color: #991b1b; }
.lockout-warning { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius); padding: 10px 14px; font-size: .875rem; color: #92400e; }
.pin-key:disabled { opacity: .35; cursor: not-allowed; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.detail-main { margin-bottom: 0; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }
.detail-side .card { margin-bottom: 0; }
.detail-side h3 { font-size: .95rem; font-weight: 600; margin-bottom: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font-size: .9rem; background: var(--surface); color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.detail-main h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 16px; }
.detail-meta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; font-size: .8rem; color: var(--text-muted); }

/* Work log */
.work-log { display: flex; flex-direction: column; gap: 10px; max-height: 240px; overflow-y: auto; margin-bottom: 12px; }
.work-log-item { font-size: .8rem; }
.work-log-item .log-time { color: var(--text-muted); }
.work-log-item .log-note { margin-top: 2px; }
.work-log-input { display: flex; flex-direction: column; gap: 6px; }
.work-log-input textarea { resize: none; }

/* Checksheet preview */
.checksheet-preview { font-size: .8rem; }
.cs-preview-item { padding: 6px 0; border-bottom: 1px solid var(--border); }
.cs-preview-item:last-child { border: none; }
.cs-preview-q { color: var(--text-muted); }
.cs-preview-a { font-weight: 500; }
.cs-preview-a.fail { color: var(--danger); }
.cs-preview-a.pass { color: var(--success); }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { font-size: .8rem; padding: 8px; background: var(--surface2); border-radius: var(--radius); }
.history-item .h-date { color: var(--text-muted); font-size: .75rem; }
.history-item .h-event { font-weight: 600; margin: 2px 0; }
.history-item .h-detail { color: var(--text-muted); }

/* History / check sheet detail modal */
.hist-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.hist-detail-item { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.hist-detail-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 4px; }
.hist-detail-value { font-size: 1rem; font-weight: 600; color: var(--text); }
.hist-detail-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.hist-detail-body { font-size: .9rem; color: var(--text); line-height: 1.6; white-space: pre-wrap; background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; margin-top: 6px; }

/* Check sheet detail rows */
.cs-detail-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.cs-detail-row:last-child { border: none; }
.cs-detail-q { color: var(--text-muted); }
.cs-detail-a { font-weight: 500; text-align: right; }

/* Work log in history modal */
.hist-worklog { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hist-worklog-entry { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.hist-worklog-time { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.hist-worklog-note { font-size: .9rem; color: var(--text); line-height: 1.5; }

/* Clickable table rows */
.clickable-row:hover { background: var(--surface2); }

/* Parts list */
#parts-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.part-row { display: flex; gap: 6px; align-items: center; }
.part-row input { flex: 1; }
.part-row input.qty { width: 70px; flex: none; }
.part-row input.cost { width: 90px; flex: none; }

/* Upcoming list */
.upcoming-list { display: flex; flex-direction: column; gap: 8px; }
.upcoming-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.upcoming-item:last-child { border: none; }
.upcoming-item .u-name { font-weight: 500; }
.upcoming-item .u-machine { color: var(--text-muted); font-size: .8rem; }
.upcoming-item .u-due { font-size: .8rem; }
.upcoming-item .u-due.overdue { color: var(--danger); font-weight: 600; }

/* Tabs */
.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Templates grid */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 16px;
  box-shadow: var(--shadow);
}
.template-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.template-card h4 { font-weight: 600; margin-bottom: 3px; font-size: .95rem; }
.template-card p { font-size: .78rem; color: var(--text-muted); margin: 0; }
.tpl-freq-badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }
.tpl-preview-section { margin-bottom: 10px; }
.tpl-preview-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 4px; }
.tpl-preview-item { display: flex; align-items: center; gap: 6px; font-size: .8rem; padding: 3px 0; border-bottom: 1px solid var(--border); }
.tpl-preview-item:last-child { border-bottom: none; }
.tpl-preview-type { font-size: .7rem; background: var(--border); border-radius: 3px; padding: 1px 4px; color: var(--text-muted); flex-shrink: 0; font-family: monospace; }
.tpl-pi-daily .tpl-preview-type { background: #dcfce7; color: #166534; }
.tpl-pi-weekly .tpl-preview-type { background: #dbeafe; color: #1d4ed8; }
.tpl-preview-opt { font-size: .7rem; color: var(--text-muted); margin-left: auto; background: var(--border); padding: 1px 4px; border-radius: 3px; flex-shrink: 0; }
.tpl-preview-more { font-size: .75rem; color: var(--text-muted); padding: 3px 0; font-style: italic; }
.template-card-footer { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.btn-danger-ghost { color: #dc2626; }
.btn-danger-ghost:hover { background: #fef2f2; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); border: none;
  font-weight: 600; font-size: .875rem; cursor: pointer; transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-block { width: 100%; }

/* In dark context */
#view-operator .btn-primary { background: var(--brand); color: white; }
#view-operator .btn-ghost { color: #94a3b8; border-color: rgba(255,255,255,.2); }
#view-operator .btn-ghost:hover { color: white; background: rgba(255,255,255,.1); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 500; padding: 16px;
}
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal--wide { max-width: 780px; }
.modal-body { overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 20px; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 600; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: white; padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: .875rem; box-shadow: var(--shadow-lg); max-width: 320px;
  animation: slideIn .2s ease-out;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding: 72px 16px 24px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .page-header { margin-bottom: 16px; }
}

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .filter-row { flex-direction: column; }
  .filter-input { min-width: unset; }
}

/* ── Template builder ────────────────────────────────────── */
.tpl-builder-section { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tpl-builder-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; font-weight: 600; font-size: .9rem; }
.tpl-builder-daily { background: #f0fdf4; color: #166534; border-bottom: 1px solid #bbf7d0; }
.tpl-builder-weekly { background: #eff6ff; color: #1d4ed8; border-bottom: 1px solid #bfdbfe; }
.tpl-q-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 48px; }
.tpl-empty-hint { color: var(--text-muted); font-size: .8rem; text-align: center; padding: 12px 0; margin: 0; }
.tpl-q-row { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.tpl-q-row .tpl-q-text { flex: 1; border: none; background: transparent; font-size: .875rem; outline: none; }
.tpl-q-row .tpl-q-text:focus { background: var(--surface); border-radius: 4px; padding: 2px 4px; }
.tpl-q-row .tpl-q-type { font-size: .8rem; border: 1px solid var(--border); border-radius: 4px; padding: 3px 6px; background: var(--surface); color: var(--text); }
.tpl-q-req-label { display: flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.tpl-q-del { padding: 2px 8px; color: var(--text-muted); flex-shrink: 0; }
.freq-badge { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: .75rem; font-weight: 500; }
.freq-daily { background: #dcfce7; color: #166534; }
.freq-weekly { background: #dbeafe; color: #1d4ed8; }

/* ── Check sheet frequency sections ──────────────────────── */
.cs-freq-header { padding: 10px 14px; font-weight: 600; font-size: .875rem; border-radius: var(--radius); margin: 16px 0 8px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px; }
.cs-freq-daily { background: #f0fdf4; color: #166534; }
.cs-freq-weekly { background: #eff6ff; color: #1d4ed8; }
.cs-freq-weekly-urgent { background: #fefce8; color: #854d0e; border: 1px solid #fde68a; }
.cs-freq-note { font-size: .78rem; font-weight: 400; opacity: .85; }
.cs-freq-note-urgent { font-weight: 600; opacity: 1; }
.cs-weekly-complete { display: flex; align-items: flex-start; gap: 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: var(--radius); padding: 14px; margin: 16px 0 8px; }
.cs-weekly-complete-icon { width: 32px; height: 32px; border-radius: 50%; background: #16a34a; color: white; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.cs-weekly-complete-date { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.cs-weekly-complete-items { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.cs-weekly-complete-items span { font-size: .8rem; color: var(--text-muted); }

/* ── Dashboard compliance ────────────────────────────────── */
.compliance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.compliance-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.compliance-title { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.compliance-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1; }
.compliance-of { font-size: 1rem; font-weight: 400; color: var(--text-muted); }
.compliance-sub { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.compliance-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.compliance-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.compliance-fill-daily { background: #16a34a; }
.compliance-fill-weekly { background: #1d4ed8; }
.compliance-op-row { display: flex; justify-content: space-between; font-size: .85rem; padding: 4px 0; border-bottom: 1px solid var(--border); }
.compliance-op-row:last-child { border-bottom: none; }
.compliance-op-count { font-weight: 600; color: var(--brand); }
.compliance-end-of-week { background: #fef3c7; border: 1px solid #fde68a; border-radius: var(--radius); padding: 10px 14px; font-size: .875rem; color: #92400e; margin-top: 12px; }

/* ── Compliance page ─────────────────────────────────────── */
.comp-filter-card { margin-bottom: 16px; }
.comp-filter-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.period-btn-group { display: flex; gap: 4px; flex-wrap: wrap; }
.period-btn { padding: 6px 14px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); font-size: .8rem; cursor: pointer; color: var(--text-muted); transition: all .15s; }
.period-btn:hover { border-color: var(--brand); color: var(--brand); }
.period-btn.active { background: var(--brand); color: white; border-color: var(--brand); }
.comp-range-label { font-size: .78rem; color: var(--text-muted); font-family: monospace; }
.comp-custom-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.comp-view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.comp-view-btn { padding: 5px 14px; font-size: .8rem; border: none; background: transparent; cursor: pointer; color: var(--text-muted); }
.comp-view-btn.active { background: var(--brand); color: white; }
.comp-pill { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .8rem; font-weight: 600; }
.comp-pill-green { background: #dcfce7; color: #166534; }
.comp-pill-amber { background: #fef3c7; color: #92400e; }
.comp-pill-red   { background: #fee2e2; color: #991b1b; }
.comp-empty { color: var(--text-muted); font-size: .875rem; padding: 16px 0; text-align: center; }
