/* ── Reset & Variables ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --surface2:  #222222;
  --surface3:  #2a2a2a;
  --border:    #333333;
  --text:      #f0f0f0;
  --muted:     #888888;
  --accent:    #e8853a;
  --accent2:   #d4762e;
  --green:     #22c55e;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --blue:      #3b82f6;
  --inc:       #ef4444;
  --done:      #22c55e;
  --radius:    10px;
  --font-head: 'Georgia', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-h:  56px;
  --nav-h:     64px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Layout ─────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.header-left  { display:flex; align-items:center; gap:10px; }
.header-right { display:flex; align-items:center; gap:10px; }

.header-logo  { height:32px; }

.header-titles { display:flex; flex-direction:column; }
.header-app-name { font-family:var(--font-head); font-size:14px; font-weight:700; color:var(--text); line-height:1.2; }
.header-date     { font-size:11px; color:var(--muted); }

.header-user-info { display:flex; flex-direction:column; align-items:flex-end; }
.header-user-name { font-size:13px; font-weight:600; color:var(--text); line-height:1.2; }
.header-user-role { font-size:10px; text-transform:uppercase; letter-spacing:.5px; }
.role-admin       { color:var(--accent); }
.role-manager     { color:var(--blue); }
.role-technician  { color:var(--muted); }

.btn-logout {
  width:34px; height:34px; border-radius:8px;
  border:1px solid var(--border);
  background:var(--surface2);
  color:var(--muted);
  display:flex; align-items:center; justify-content:center;
  text-decoration:none;
  transition:color .15s, border-color .15s;
}
.btn-logout:hover { color:var(--red); border-color:var(--red); }

.app-main {
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  min-height: calc(100vh - var(--header-h) - var(--nav-h));
  padding: 16px 16px 100px;
  overflow-y: auto;
}

/* ── Bottom Navigation ──────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .4px;
  transition: color .15s;
  padding: 8px 4px;
}
.nav-item svg { transition: stroke .15s; }
.nav-item.active { color: var(--accent); }
.nav-item:hover  { color: var(--text); }

/* ── Common Components ──────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-title {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card:last-child { margin-bottom: 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-pending   { background:rgba(245,158,11,.15); color:var(--amber); border:1px solid rgba(245,158,11,.3); }
.badge-approved  { background:rgba(34,197,94,.15);  color:var(--green); border:1px solid rgba(34,197,94,.3); }
.badge-rejected  { background:rgba(239,68,68,.15);  color:var(--red);   border:1px solid rgba(239,68,68,.3); }
.badge-ordered   { background:rgba(59,130,246,.15); color:var(--blue);  border:1px solid rgba(59,130,246,.3); }
.badge-delivered { background:rgba(34,197,94,.15);  color:var(--green); border:1px solid rgba(34,197,94,.3); }
.badge-urgent    { background:rgba(239,68,68,.15);  color:var(--red);   border:1px solid rgba(239,68,68,.3); }
.badge-open      { background:rgba(59,130,246,.15); color:var(--blue);  border:1px solid rgba(59,130,246,.3); }
.badge-in-progress { background:rgba(245,158,11,.15); color:var(--amber); border:1px solid rgba(245,158,11,.3); }
.badge-done      { background:rgba(34,197,94,.15);  color:var(--green); border:1px solid rgba(34,197,94,.3); }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 11px 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn-primary:hover { opacity: .9; }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-outline:hover { background: rgba(232,133,58,.1); }

.btn-ghost {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: color .15s;
}
.btn-ghost:hover { color: var(--text); }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.btn-sm:hover        { color:var(--text); border-color:var(--text); }
.btn-sm.primary      { background:var(--accent); color:#fff; border-color:var(--accent); }
.btn-sm.primary:hover{ opacity:.9; }
.btn-sm.danger       { color:var(--red); border-color:rgba(239,68,68,.3); }
.btn-sm.danger:hover { background:rgba(239,68,68,.1); border-color:var(--red); }
.btn-sm.success      { color:var(--green); border-color:rgba(34,197,94,.3); }
.btn-sm.success:hover{ background:rgba(34,197,94,.1); border-color:var(--green); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display:flex; gap:12px; }
.form-row .form-group { flex:1; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: 0;
}
.modal-box {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  padding: 24px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 4px;
}
.modal-title {
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
}

/* Empty & Loading states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}
.empty-state svg { opacity: .3; }
.empty-state p   { font-size: 14px; }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  z-index: 300;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); white-space:normal; max-width:300px; text-align:center; }

/* ── Checklist module ───────────────────────────────────────────────────────── */
.zone-section { margin-bottom: 20px; }
.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}
.zone-name  { font-family:var(--font-head); font-size:14px; font-weight:700; }
.zone-progress { font-size:12px; color:var(--muted); }
.zone-chevron { color:var(--muted); transition:transform .2s; }
.zone-section.open .zone-chevron { transform:rotate(180deg); }
.zone-tasks { display:none; }
.zone-section.open .zone-tasks { display:block; }

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s;
}
.task-item:hover { border-color: #444; }
.task-item.status-done { border-color: rgba(34,197,94,.3); }
.task-item.status-inc  { border-color: rgba(239,68,68,.3); }
.task-item.has-oor     { border-color: rgba(245,158,11,.4); }

.task-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
}
.task-check {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
  color: var(--muted);
  transition: all .15s;
}
.status-done .task-check { background:var(--green);  border-color:var(--green);  color:#fff; }
.status-inc  .task-check { background:var(--red);    border-color:var(--red);    color:#fff; }
.check-oor               { background:var(--amber) !important; border-color:var(--amber) !important; }

.task-info { flex:1; min-width:0; }
.task-name { font-size:14px; font-weight:500; }
.task-meta { font-size:11px; color:var(--muted); margin-top:2px; display:flex; gap:6px; flex-wrap:wrap; }
.task-by   { font-size:10px; color:var(--muted); margin-left:auto; }

.task-actions {
  display: none;
  padding: 10px 14px 12px;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-wrap: wrap;
}
.task-item.expanded .task-actions { display: flex; }

.btn-task-done, .btn-task-undo {
  flex: 1;
  min-width: 80px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
}
.btn-task-done { background:var(--green); color:#fff; }
.btn-task-done:hover { opacity:.85; }
.btn-task-undo { background:var(--surface3); color:var(--muted); border:1px solid var(--border); }
.btn-task-undo:hover { color:var(--text); }

.tag-bms  { background:rgba(59,130,246,.15); color:var(--blue);  padding:1px 6px; border-radius:4px; font-size:10px; font-weight:600; }
.tag-phys { background:rgba(34,197,94,.1);   color:var(--green); padding:1px 6px; border-radius:4px; font-size:10px; font-weight:600; }

.value-input-row { display:flex; gap:8px; align-items:center; width:100%; }
.value-input {
  flex:1; background:var(--surface); border:1px solid var(--border);
  border-radius:7px; padding:8px 10px;
  color:var(--text); font-size:14px; outline:none;
}
.value-input:focus { border-color:var(--accent); }
.value-unit { font-size:13px; color:var(--muted); white-space:nowrap; }

.oor-warning {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  border-radius:6px; padding:6px 10px;
  font-size:12px; color:var(--amber);
  width:100%;
}
.task-action-btns { display:flex; gap:8px; width:100%; }
.task-action-btns .btn-task-done { flex:1; }

.report-summary {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.summary-stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
}
.summary-stat .s-val { display:block; font-size:20px; font-weight:700; line-height:1; }
.summary-stat .s-lbl { display:block; font-size:10px; color:var(--muted); text-transform:uppercase; margin-top:3px; }

.generate-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  margin-top: 8px;
}
.generate-btn:hover { opacity: .9; }

/* ── Cereri module ──────────────────────────────────────────────────────────── */
.request-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.request-card-header { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; margin-bottom:6px; }
.request-title       { font-size:15px; font-weight:600; }
.request-meta        { font-size:12px; color:var(--muted); margin-top:4px; }
.request-desc        { font-size:13px; color:var(--muted); margin-top:6px; }
.request-actions     { display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; }

.filter-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}
.filter-tab.active { background:var(--accent); color:#fff; border-color:var(--accent); }

/* ── Staff picker (login modal for checklist) ───────────────────────────────── */
.staff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-height: 320px;
  overflow-y: auto;
}
.staff-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s;
  text-align: left;
}
.staff-btn:hover   { border-color: var(--accent); }
.staff-btn.selected{ border-color: var(--accent); background:rgba(232,133,58,.08); color:var(--accent); }
.staff-avatar {
  width:32px; height:32px; border-radius:50%;
  background:var(--accent); color:#fff;
  font-size:14px; font-weight:700;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}