/* NovaPro Solutions LLC — brand palette only:
   orange #FE7003 | charcoal #414345 | light gray #F4F5F6 | white | medium gray #8A8D90 */
:root {
  --orange: #FE7003;
  --orange-dark: #d95f02;
  --charcoal: #414345;
  --bg: #F4F5F6;
  --white: #ffffff;
  --gray: #8A8D90;
  --border: #dfe2e4;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--charcoal);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

h1, h2, h3 { color: var(--charcoal); margin: 0 0 12px; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }
a { color: var(--orange); }

label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 5px; color: var(--charcoal); }

input[type="text"], input[type="email"], input[type="tel"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--charcoal);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: 0;
  border-color: var(--orange);
}
textarea { min-height: 74px; resize: vertical; }

.muted { color: var(--gray); }
.small { font-size: 13px; }
.error-text { color: #b3261e; font-weight: 600; margin-top: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  background: var(--white);
  color: var(--charcoal);
}
.btn:hover { filter: brightness(0.97); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { border-color: var(--border); color: var(--charcoal); }
.btn-danger { background: var(--charcoal); color: #fff; }
.btn-ghost { background: transparent; color: var(--gray); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn + .btn { margin-left: 8px; }

/* ---------- Login ---------- */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(65, 67, 69, 0.12);
  padding: 36px 34px 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-logo { width: 100%; max-width: 300px; height: auto; }
.login-subtitle { color: var(--gray); font-weight: 600; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; margin: 6px 0 18px; }
#login-form { text-align: left; }
.remember-row { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--gray); margin-top: 14px; cursor: pointer; }
.remember-row input { width: auto; accent-color: var(--orange); }

/* ---------- App shell ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--charcoal);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { padding: 6px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.sidebar-logo { width: 100%; height: auto; display: block; background: #fff; border-radius: 8px; padding: 8px; }
#main-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; flex: 1; }
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  color: #cfd2d4;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; }
.sidebar-logout { color: #cfd2d4; text-align: left; padding: 10px 12px; }
.sidebar-logout:hover { color: #fff; }

#main { flex: 1; min-width: 0; padding: 26px 30px 40px; }
#view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
#view-header h1 { margin: 0; }

/* ---------- Cards / dashboard ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(65, 67, 69, 0.08);
}
.stat-card .stat-label { font-size: 13px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--charcoal); margin-top: 4px; }
.stat-card .stat-value.orange { color: var(--orange); }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(65, 67, 69, 0.08);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.card h2 { margin-bottom: 4px; }
.card .card-sub { color: var(--gray); font-size: 13px; margin-bottom: 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray); background: var(--bg); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin: 2px 2px 2px 0; }
.empty-row td { text-align: center; color: var(--gray); padding: 26px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
  border: 1px solid var(--gray);
  color: var(--gray);
  background: var(--white);
}
.badge-draft { border-color: var(--gray); color: var(--gray); }
.badge-sent { border-color: var(--orange); color: var(--orange); }
.badge-paid, .badge-accepted { background: var(--orange); border-color: var(--orange); color: #fff; }
.badge-void, .badge-declined { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }
.badge-overdue { background: var(--charcoal); border-color: var(--charcoal); color: #fff; }

/* ---------- Filters ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.filter-bar input[type="text"], .filter-bar select { width: auto; flex: 1; min-width: 180px; }
.filter-bar select { flex: 0 0 170px; }

/* ---------- Forms / editor ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.totals-box {
  margin-left: auto;
  width: 320px;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  background: var(--bg);
}
.totals-row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-row.grand { font-size: 18px; font-weight: 700; border-top: 2px solid var(--charcoal); margin-top: 8px; padding-top: 10px; }
.totals-row.grand span:last-child { color: var(--orange); }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.editor-actions .spacer { flex: 1; }
.tax-input { display: flex; align-items: center; gap: 8px; }
.tax-input input { width: 90px; }
.inline-add {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
}
.inline-add h3 { margin-bottom: 4px; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.danger-zone { border: 2px solid var(--charcoal); }
.danger-zone h2 { color: var(--charcoal); }

/* ---------- Document preview / print ---------- */
#preview-modal {
  position: fixed;
  inset: 0;
  background: rgba(65, 67, 69, 0.75);
  overflow-y: auto;
  z-index: 100;
}
.modal-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--charcoal);
  color: #fff;
  padding: 12px 20px;
}
.modal-title { font-weight: 700; font-size: 15px; }
#preview-body { padding: 28px 16px 48px; display: flex; justify-content: center; }

.doc-page {
  width: 800px;
  max-width: 100%;
  background: #fff;
  color: var(--charcoal);
  padding: 48px 52px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 20px; border-bottom: 3px solid var(--orange); }
.doc-logo { height: 74px; width: auto; max-width: 320px; object-fit: contain; }
.doc-company { text-align: right; font-size: 13px; color: var(--charcoal); line-height: 1.6; }
.doc-company strong { font-size: 15px; }
.doc-title-row { display: flex; justify-content: space-between; align-items: flex-end; margin: 26px 0 6px; }
.doc-title { font-size: 32px; font-weight: 800; letter-spacing: 2px; color: var(--charcoal); margin: 0; }
.doc-title.orange { color: var(--orange); }
.doc-meta { text-align: right; font-size: 13px; line-height: 1.7; }
.doc-meta strong { color: var(--charcoal); }
.doc-billto { margin: 18px 0 22px; }
.doc-billto h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gray); }
.doc-billto .billto-name { font-size: 16px; font-weight: 700; }
.doc-items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.doc-items th { background: var(--charcoal); color: #fff; }
.doc-items td, .doc-items th { padding: 9px 12px; }
.doc-totals { margin-left: auto; width: 280px; margin-top: 10px; }
.doc-totals .totals-row { padding: 3px 0; }
.doc-notes { margin-top: 22px; font-size: 13px; }
.doc-notes h4 { margin: 0 0 4px; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--gray); }
.doc-footer { margin-top: 34px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--gray); text-align: center; }
.doc-footer .thanks { font-size: 14px; font-weight: 700; color: var(--orange); margin-bottom: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 12px;
    gap: 8px;
  }
  .sidebar-brand { padding: 0; border-bottom: none; width: 150px; }
  .sidebar-logo { padding: 4px; }
  #main-nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; flex: 1; }
  .nav-item { padding: 8px 10px; font-size: 14px; }
  .sidebar-logout { padding: 8px 10px; }
  #main { padding: 18px 14px 30px; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-page { padding: 28px 22px; }
  .doc-header { flex-direction: column; }
  .doc-company { text-align: left; }
  .doc-title-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .doc-meta { text-align: left; }
}

/* ---------- Print: only the document prints ---------- */
@media print {
  body { background: #fff; }
  #login-screen, #app, .modal-bar { display: none !important; }
  #preview-modal {
    position: static;
    display: block !important;
    background: none;
    overflow: visible;
  }
  #preview-body { padding: 0; display: block; }
  .doc-page { box-shadow: none; width: 100%; max-width: none; padding: 0; }
  @page { size: letter; margin: 18mm; }
}
