/* Harmax ERP — Shared Styles
   Imported by all pages. Page-specific overrides remain inline.
   Last updated: 2026-03-28 */

/* ══════════════════════════════════════════════════════════════════ */
/* CSS VARIABLES                                                      */
/* ══════════════════════════════════════════════════════════════════ */

:root {
  --navy:  #1F3864;
  --blue:  #2E75B6;
  --green: #1e7e34;
  --amber: #ED7D31;
  --red:   #C00000;
  --purple: #7030A0;
  --orange: #C55A11;
  --gray:  #6c757d;
  --lt:    #f4f6f9;
  --white: #ffffff;
  --lt-blue: #BDD7EE;
  --lt-green: #E2EFDA;
  --lt-gray: #F2F2F2;
  --border: #D0D7E2;
  --text:  #1a1a2e;
  --muted: #6b7280;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ══════════════════════════════════════════════════════════════════ */
/* RESET & BASE STYLES                                               */
/* ══════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--lt);
  color: #222;
  font-size: 14px;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════════════ */
/* LOGIN SCREEN                                                       */
/* ══════════════════════════════════════════════════════════════════ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
}

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-box h1 {
  font-size: 22px;
  color: var(--navy);
  margin-bottom: 4px;
}

.login-box p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--blue);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.btn-login:hover {
  background: #162b50;
}

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════ */
/* NAVIGATION BAR                                                     */
/* ══════════════════════════════════════════════════════════════════ */

nav {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 48px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  flex-wrap: nowrap;
}

nav .brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .5px;
  margin-right: 16px;
  white-space: nowrap;
  display: flex;
  align-items: center;
}

nav .dept-link {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: .3px;
}

nav .dept-link:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

nav .dept-link.active {
  background: var(--blue);
  color: #fff;
}

nav .spacer {
  flex: 1;
}

nav .user-info {
  font-size: 12px;
  color: rgba(255,255,255,.6);
}

nav .logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.75);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}

nav .logout-btn:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════════════ */
/* SUB-TAB BAR                                                        */
/* ══════════════════════════════════════════════════════════════════ */

.sub-tabs {
  background: #e8ecf1;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 38px;
  gap: 2px;
  position: sticky;
  top: 48px;
  z-index: 99;
  border-bottom: 1px solid #d0d7e2;
  flex-wrap: nowrap;
}

.sub-tabs a {
  color: #4a5568;
  text-decoration: none;
  padding: 6px 16px;
  border-radius: 4px 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}

.sub-tabs a:hover {
  background: rgba(0,0,0,.06);
  color: var(--navy);
}

.sub-tabs a.active {
  background: #fff;
  color: var(--navy);
  font-weight: 600;
  border: 1px solid #d0d7e2;
  border-bottom: 1px solid #fff;
  margin-bottom: -1px;
}

.sub-tabs .dept-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-right: 12px;
  opacity: .6;
}

/* ══════════════════════════════════════════════════════════════════ */
/* PAGE & LAYOUT                                                      */
/* ══════════════════════════════════════════════════════════════════ */

.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 10px 40px;
}

.main {
  flex: 1;
  padding: 20px 24px;
  overflow-x: auto;
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.page-subtitle, .page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  overflow: hidden;
}

.section {
  margin-bottom: 20px;
}

/* ══════════════════════════════════════════════════════════════════ */
/* BUTTONS                                                            */
/* ══════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover {
  background: #162b50;
}

.btn-blue {
  background: var(--blue);
  color: #fff;
}

.btn-blue:hover {
  background: #1a5fa0;
}

.btn-green {
  background: var(--green);
  color: #fff;
}

.btn-green:hover {
  background: #155a27;
}

.btn-red {
  background: var(--red);
  color: #fff;
}

.btn-red:hover {
  background: #900000;
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-success:hover {
  background: #155c28;
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #990000;
}

.btn-ghost {
  background: #fff;
  color: var(--navy);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--lt-gray);
}

.btn-amber {
  background: var(--amber);
  color: #fff;
}

.btn-amber:hover {
  background: #c5660e;
}

.btn-sm {
  padding: 4px 6px;
  font-size: 11px;
}

.btn-add {
  padding: 9px 18px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-add:hover {
  background: #162b50;
}

/* ══════════════════════════════════════════════════════════════════ */
/* TOOLBAR & FILTERS                                                  */
/* ══════════════════════════════════════════════════════════════════ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group input,
.filter-group select,
.toolbar input[type=text],
.toolbar select {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.filter-group input:focus,
.filter-group select:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--blue);
}

.filter-group input {
  width: 220px;
}

.toolbar input[type=text] {
  padding: 8px 12px;
  width: 240px;
}

.toolbar select {
  padding: 8px 10px;
}

.filter-btn {
  padding: 8px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.12s;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.filter-btn.active {
  background: #fff3e0;
  border-color: var(--amber);
  color: var(--amber);
}

.filter-btn .badge {
  background: var(--amber);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 5px;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.search-wrap input:focus {
  border-color: var(--blue);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.filter-select {
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  outline: none;
  cursor: pointer;
}

.filter-select:focus {
  border-color: var(--blue);
}

.results-info {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════════════ */
/* TABLE STYLES                                                       */
/* ══════════════════════════════════════════════════════════════════ */

.table-wrap {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--navy);
  color: #fff;
}

thead th {
  background: var(--navy);
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

thead th:hover {
  background: #2a4a80;
}

thead th .sort-icon {
  margin-left: 4px;
  opacity: .5;
  font-size: 10px;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover {
  background: #f0f5ff;
  cursor: pointer;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody td {
  padding: 10px 12px;
  vertical-align: middle;
  overflow: hidden;
}

.no-data,
.no-jobs {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-style: italic;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 10px;
}

.pn-cell {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
}

.desc-cell {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cost-cell {
  font-weight: 700;
  white-space: nowrap;
}

.cost-zero {
  color: var(--amber);
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════════ */
/* BADGE STYLES                                                       */
/* ══════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Status badges */
.badge-Draft,
.badge-draft {
  background: #e9ecef;
  color: #555;
}

.badge-Sent,
.badge-sent {
  background: #cfe2ff;
  color: #0046ad;
}

.badge-Accepted,
.badge-accepted {
  background: #d1e7dd;
  color: #0f5132;
}

.badge-Rejected,
.badge-rejected {
  background: #f8d7da;
  color: #842029;
}

.badge-Expired,
.badge-expired {
  background: #fff3cd;
  color: #664d03;
}

.badge-Converted,
.badge-converted {
  background: #e0d4f5;
  color: #4a1d96;
}

/* Job status badges */
.badge-on-track {
  background: #d4edda;
  color: #155724;
}

.badge-at-risk {
  background: #fff3cd;
  color: #856404;
}

.badge-delayed {
  background: #f8d7da;
  color: #721c24;
}

.badge-complete {
  background: #cce5ff;
  color: #004085;
}

.badge-on-hold {
  background: #e2e3e5;
  color: #383d41;
}

/* Priority badges */
.badge-high {
  background: #f8d7da;
  color: #721c24;
}

.badge-medium {
  background: #fff3cd;
  color: #856404;
}

.badge-low {
  background: #d4edda;
  color: #155724;
}

/* Status pill badges */
.status-badge,
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.s-on_track,
.s-on_track {
  background: #d4edda;
  color: #155724;
}

.status-badge.s-at_risk,
.s-at_risk {
  background: #fff3cd;
  color: #856404;
}

.status-badge.s-delayed,
.s-delayed {
  background: #f8d7da;
  color: #721c24;
}

.status-badge.s-complete,
.s-complete {
  background: #e2e3e5;
  color: #383d41;
}

.status-badge.s-on_hold,
.s-on_hold {
  background: #cce5ff;
  color: #004085;
}

.s-needed {
  background: #f5f5f5;
  color: #6c757d;
}

.s-ordered {
  background: #e3f2fd;
  color: #2E75B6;
}

.s-received {
  background: #e8f5e9;
  color: #1e7e34;
}

.s-installed {
  background: #f3e5f5;
  color: #7030A0;
}

/* Priority badges */
.prio {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.prio-High {
  background: #ffe0e0;
  color: #9c0006;
}

.prio-Medium {
  background: #ffe8cc;
  color: #7f3f00;
}

.prio-Low {
  background: #ffffc7;
  color: #7f7f00;
}

/* Phase badges */
.badge-phase,
.phase-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  margin-top: 4px;
}

.ph-pre-production {
  background: #e8f0fe;
  color: #1a56db;
}

.ph-design {
  background: #fef3c7;
  color: #92400e;
}

.ph-production {
  background: #dcfce7;
  color: #166534;
}

.ph-ready-to-ship {
  background: #d1fae5;
  color: #065f46;
}

.ph-delivery {
  background: #fde68a;
  color: #78350f;
}

.ph-installation {
  background: #ddd6fe;
  color: #4c1d95;
}

.ph-warranty {
  background: #bfdbfe;
  color: #1e40af;
}

.ph-closed {
  background: #e5e7eb;
  color: #374151;
}

.ph-none {
  background: #f3f4f6;
  color: #6b7280;
}

/* Specialty badges */
.needs-badge {
  display: inline-block;
  background: #fff3e0;
  color: var(--amber);
  border: 1px solid #ffe0b2;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  white-space: nowrap;
}

.mfg-badge {
  display: inline-block;
  background: #e8f0fb;
  color: var(--blue);
  border: 1px solid #c5d8f5;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  white-space: nowrap;
}

.vendor-pill {
  display: inline-block;
  background: #e8f0fb;
  color: var(--blue);
  border-radius: 4px;
  font-size: 11px;
  padding: 2px 7px;
  margin: 1px;
  white-space: nowrap;
}

.badge-active {
  background: #e8f5e9;
  color: var(--green);
}

.badge-inactive {
  background: #ffebee;
  color: var(--red);
}

/* ══════════════════════════════════════════════════════════════════ */
/* MODAL STYLES                                                       */
/* ══════════════════════════════════════════════════════════════════ */

.modal-overlay,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-overlay.open,
.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 980px;
  box-shadow: 0 12px 48px rgba(0,0,0,.25);
  overflow: hidden;
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 2px solid var(--border);
  background: var(--navy);
  color: #fff;
  border-radius: 12px 12px 0 0;
}

.modal-header h2,
.modal-header h3 {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.8;
}

.modal-close:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
  opacity: 1;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8f9fa;
  border-radius: 0 0 12px 12px;
}

/* ══════════════════════════════════════════════════════════════════ */
/* FORM FIELD STYLES                                                  */
/* ══════════════════════════════════════════════════════════════════ */

label.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

input.field,
select.field,
textarea.field {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

input.field:focus,
select.field:focus,
textarea.field:focus {
  border-color: var(--blue);
}

textarea.field {
  resize: vertical;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 2px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

.field .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Form grids */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.form-row.single {
  grid-template-columns: 1fr;
}

.form-row.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.form-full {
  grid-column: 1/-1;
}

.form-section {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  padding: 10px 0 6px;
  border-bottom: 2px solid var(--lt-blue);
  margin-bottom: 12px;
  margin-top: 6px;
}

.section-hdr {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 16px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════════════════════════════ */
/* TOAST NOTIFICATIONS                                                */
/* ══════════════════════════════════════════════════════════════════ */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #222;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: 320px;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast.success {
  background: var(--green);
}

#toast.error,
#toast.err {
  background: var(--red);
}

#toast.ok {
  background: var(--green);
}

/* ══════════════════════════════════════════════════════════════════ */
/* SPINNERS & LOADING                                                 */
/* ══════════════════════════════════════════════════════════════════ */

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #ddd;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
  display: block;
}

.spinner-wrap {
  text-align: center;
  padding: 40px;
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ══════════════════════════════════════════════════════════════════ */
/* TAB STYLES                                                         */
/* ══════════════════════════════════════════════════════════════════ */

.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}

.tab-btn:hover {
  color: var(--navy);
}

.tab-btn.active {
  color: var(--navy);
  border-bottom-color: var(--blue);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ══════════════════════════════════════════════════════════════════ */
/* RESPONSIVE MEDIA QUERIES                                           */
/* ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .form-grid2,
  .form-grid3 {
    grid-template-columns: 1fr;
  }
}
