body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
header {
  background-color: #2c3e50;
  color: #fff;
  padding: 12px 20px;
}
header h1 {
  margin: 0;
  font-size: 1.5rem;
}
nav {
  margin-top: 8px;
}
nav a {
  color: #ecf0f1;
  margin-right: 16px;
  text-decoration: none;
}
nav a:hover {
  text-decoration: underline;
}
main {
  padding: 20px;
}

/* FORM CSS */

/* =========================
   Invoice Create Page
   Targets existing markup in invoice_form.html
   ========================= */

/* Page heading */
h1 {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 700;
  }
  
  /* Form container */
  form[novalidate] {
    width: 100%;
    max-width: none;
  }
  
  /* Fieldsets look like cards */
  fieldset {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin: 0 0 16px;
    background: #fff;
  }
  
  legend {
    padding: 0 8px;
    font-weight: 700;
    color: #111827;
  }
  
  /* Make default <p> blocks behave more like form rows */
  fieldset > p,
  #cust-existing p,
  #cust-new p {
    margin: 0 0 12px;
  }
  
  /* Labels + inputs (works even with <br> layout) */
  label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
  }
  
  input,
  select,
  textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
  }
  
  input:focus,
  select:focus,
  textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  }
  
  /* Customer radio group (staff only) */
  input[type="radio"] {
    width: auto;
    margin-right: 6px;
  }
  fieldset strong {
    color: #111827;
  }
  
  /* Django errors */
  .errorlist {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    color: #b91c1c;
    font-size: 12px;
  }
  
  /* Items container + item rows (you already use .item-row) */
  #items-container {
    margin-top: 8px;
  }
  
  .item-row {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    margin: 10px 0;
  }
  
  /* Your item form uses f.as_p; style those paragraphs */
  .item-row p {
    margin: 0 0 10px;
  }
  .item-row p:last-child {
    margin-bottom: 0;
  }
  
  /* Remove checkbox label styling */
  .item-row label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-top: 4px;
  }
  
  /* Add-item button (id already in template) */
  #add-item {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #2563eb;
    background: #fff;
    color: #2563eb;
    font-weight: 700;
    cursor: pointer;
  }
  
  #add-item:hover {
    background: rgba(37, 99, 235, 0.06);
  }
  
  /* Totals block (targets your existing IDs) */
  #live-subtotal,
  #live-tax,
  #live-total {
    font-variant-numeric: tabular-nums;
  }
  
  fieldset:last-of-type > div[style*="border-top"] {
    /* Your totals wrapper currently uses inline border-top/padding.
       This makes it look cleaner without needing markup changes. */
    border-top: 1px solid #e5e7eb !important;
    margin-top: 14px !important;
    padding-top: 12px !important;
  }
  
  fieldset:last-of-type > div[style*="border-top"] > div {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    color: #111827;
  }
  
  fieldset:last-of-type > div[style*="border-top"] > div:last-child {
    font-size: 16px;
  }
  
  /* Bottom action row (Save/Cancel area) */
  form > div[style*="margin-top:12px;"] {
    display: flex;
    gap: 12px;
    align-items: center;
  }
  
  /* Primary submit button */
  button[type="submit"] {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #2563eb;
    background: #2563eb;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
  }
  
  button[type="submit"]:hover {
    filter: brightness(0.95);
  }
  
  /* Cancel link */
  form a[href="/"] {
    padding: 10px 8px;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
  }
  
  form a[href="/"]:hover {
    text-decoration: underline;
  }
  
  /* Responsive: your inline 2-col grid will wrap naturally,
     but ensure inputs don’t overflow narrow screens */
  @media (max-width: 720px) {
    fieldset {
      padding: 14px;
    }
  }
  

  /* Footer */

  /* Footer area under items: button left, totals right (stacks on mobile) */
.items-footer {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
  
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
  }
  
  /* Totals block spacing */
  .totals {
    max-width: 360px;
    margin-left: auto;
  
    display: grid;
    gap: 10px;
  
    /* Prevent the “bunched” look */
    line-height: 1.35;
  }
  
  .totals-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 18px;
  }
  
  .totals-row span {
    color: #374151;
  }
  
  .totals-row strong {
    font-variant-numeric: tabular-nums;
  }
  
  .totals-total {
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px dashed #e5e7eb;
    font-size: 16px;
  }
  
  /* Make Add Item look aligned with totals */
  #add-item {
    margin-top: 2px;
  }
  
  /* Mobile: stack button above totals, keep totals full-width but not cramped */
  @media (max-width: 720px) {
    .items-footer {
      flex-direction: column;
      align-items: stretch;
    }
  
    .totals {
      max-width: none;
      margin-left: 0;
      padding-top: 10px;
    }
  }
  
  /* Invoice Detail */


  .invoice-container {
    font-family: system-ui, Arial, sans-serif;
    width: 100%;
    margin: 24px auto;
    background: #fff;
    padding: 24px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    box-sizing: border-box;
  }

  .invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
  }

  .invoice-header h1 {
    margin: 0;
    font-size: 1.8rem;
  }

  .invoice-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    min-width: 280px;
  }

  .invoice-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    font-size: 14px;
    line-height: 1.2;
    user-select: none;
  }

  .btn-primary {
    background: #2c3e50;
    color: #fff;
    border-color: #2c3e50;
  }

  .btn-primary:hover {
    background: #1a242f;
    border-color: #1a242f;
  }

  .btn-secondary {
    background: #fff;
    color: #2c3e50;
    border-color: #2c3e50;
  }

  .btn-secondary:hover {
    background: rgba(44, 62, 80, 0.06);
  }

  .invoice-meta {
    text-align: right;
    font-size: 0.95rem;
    color: #555;
  }

  .invoice-meta p {
    margin: 0 0 6px;
  }

  .invoice-meta strong {
    display: inline-block;
    min-width: 80px;
    color: #111;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
  }

  th, td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
  }

  th {
    background-color: #f8f8f8;
  }

  tfoot td {
    font-weight: 600;
  }

  .totals-row td {
    background: #fafafa;
  }

  .notes {
    margin-top: 20px;
    font-style: italic;
    color: #555;
  }

  /* Totals card aligned bottom-right under table */
  .totals-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
  }

  .totals-card {
    width: 320px;
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 14px;
  }

  .totals-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 6px 0;
    color: #111827;
  }

  .totals-row span {
    color: #374151;
  }

  .totals-row strong {
    font-variant-numeric: tabular-nums;
  }

  .totals-total {
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px dashed #e5e7eb;
    font-size: 16px;
  }


  /* Mobile */
  @media (max-width: 720px) {
    .invoice-header {
      flex-direction: column;
      align-items: flex-start;
    }
    .invoice-header-right {
      align-items: flex-start;
      min-width: unset;
      width: 100%;
    }
    .invoice-meta {
      text-align: left;
    }
    .invoice-actions {
      width: 100%;
    }
    th:nth-child(2), td:nth-child(2),
    th:nth-child(3), td:nth-child(3),
    th:nth-child(4), td:nth-child(4) {
      white-space: nowrap;
    }
  }


  /* =========================
   iOS / Apple-like form skin
   ========================= */

:root{
  --ios-bg: #f2f2f7;
  --ios-card: #ffffff;
  --ios-sep: rgba(60,60,67,0.18);
  --ios-text: #111827;
  --ios-sub: rgba(60,60,67,0.72);
  --ios-blue: #007aff;
  --ios-shadow: 0 1px 0 rgba(0,0,0,0.04);
}

.ios-page{
  background: var(--ios-bg);
  min-height: calc(100vh - 60px);
  padding: 18px 14px 88px; /* bottom padding for sticky bar */
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, Arial, sans-serif;
}

.ios-header{
  max-width: 920px;
  margin: 0 auto 14px;
  text-align: center;
}

.ios-title{
  font-size: 28px;
  line-height: 1.2;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}

.ios-subtitle{
  margin: 0;
  color: var(--ios-sub);
  font-size: 14px;
  text-align: center;
}

.ios-form{
  max-width: 920px;
  margin: 0 auto;
}

.ios-section{
  margin: 14px 0 18px;
}

.ios-section-title{
  font-size: 13px;
  font-weight: 700;
  color: var(--ios-sub);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 0 0 10px 6px;
}

.ios-card{
  background: var(--ios-card);
  border-radius: 14px;
  box-shadow: var(--ios-shadow);
  border: 1px solid rgba(0,0,0,0.06);
  overflow: hidden;
}

.ios-row{
  padding: 12px 14px;
}

.ios-row + .ios-row{
  border-top: 1px solid var(--ios-sep);
}

.ios-row-label{
  font-size: 13px;
  font-weight: 700;
  color: var(--ios-text);
  margin-bottom: 6px;
}

.ios-row-help{
  font-size: 12px;
  font-weight: 500;
  color: var(--ios-sub);
  margin-top: 4px;
}

.ios-row-control{
  display: block;
}

.ios-row-stack .ios-row-control input,
.ios-row-stack .ios-row-control select,
.ios-row-stack .ios-row-control textarea{
  background: rgba(118,118,128,0.08);
  border: 1px solid rgba(60,60,67,0.10);
  border-radius: 12px;
  padding: 12px 12px;
}

.ios-row-stack .ios-row-control textarea{
  min-height: 92px;
  resize: vertical;
}

.ios-row-split{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  border-top: 1px solid var(--ios-sep);
}

.ios-row-split .ios-split{
  padding: 12px 14px;
}

.ios-row-split .ios-split + .ios-split{
  border-left: 1px solid var(--ios-sep);
}

.ios-divider{
  height: 10px;
  background: var(--ios-bg);
  border-top: 1px solid var(--ios-sep);
  border-bottom: 1px solid var(--ios-sep);
}

/* Inputs baseline */
.ios-form input,
.ios-form select,
.ios-form textarea{
  width: 100%;
  box-sizing: border-box;
  font-size: 15px;
  border-radius: 12px;
  outline: none;
}

.ios-form input:focus,
.ios-form select:focus,
.ios-form textarea:focus{
  border-color: rgba(0,122,255,0.45);
  box-shadow: 0 0 0 4px rgba(0,122,255,0.12);
}

/* Error list */
.ios-form .errorlist{
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: #b91c1c;
  font-size: 12px;
}

/* Checkbox row */
.ios-check{
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  color: var(--ios-text);
}
.ios-check input{
  width: 18px;
  height: 18px;
  accent-color: var(--ios-blue);
}

/* Items */
.ios-items{
  padding: 6px 0;
}

.ios-item{
  padding: 0;
}
.ios-item-top{
  padding: 0;
}
.ios-item-divider{
  height: 1px;
  background: var(--ios-sep);
  margin: 0 14px;
}

/* Add + Totals */
.ios-actions-row{
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-top: 1px solid var(--ios-sep);
  background: rgba(242,242,247,0.35);
}

.ios-totals{
  min-width: 260px;
  display: grid;
  gap: 8px;
}

.ios-total-row{
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--ios-text);
  font-size: 14px;
}
.ios-total-row span{
  color: var(--ios-sub);
}
.ios-total-row strong{
  font-variant-numeric: tabular-nums;
}

.ios-total-row-emph{
  padding-top: 10px;
  border-top: 1px dashed var(--ios-sep);
}
.ios-total-row-emph span{
  color: var(--ios-text);
  font-weight: 700;
}
.ios-total-row-emph strong{
  font-size: 16px;
}

/* Buttons */
.ios-btn{
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
}

.ios-btn-primary{
  background: var(--ios-blue);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.ios-btn-primary:hover{
  filter: brightness(0.98);
}

.ios-btn-ghost{
  background: rgba(118,118,128,0.10);
  color: var(--ios-blue);
}

.ios-link{
  color: var(--ios-blue);
  text-decoration: none;
  font-weight: 700;
  padding: 10px 8px;
}

/* Sticky bottom bar */
.ios-bottom-bar{
  position: sticky;
  bottom: 0;
  margin-top: 18px;
  padding: 12px 0 env(safe-area-inset-bottom);
  background: rgba(242,242,247,0.82);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--ios-sep);
}

.ios-bottom-inner{
  max-width: 920px;
  margin: 0 auto;
  padding: 0 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* =========================================================
   MOBILE-ONLY STYLES (iOS / Safari Optimized)
   Does NOT affect desktop
   ========================================================= */
   @media (max-width: 768px) {

    /* Prevent iOS zoom-on-focus */
    input,
    textarea,
    select {
      font-size: 16px;
    }
  
    body {
      background: #f3f4f6;
    }
  
    /* Page padding */
    .ios-page {
      padding: 16px;
    }
  
    /* Header */
    .ios-header {
      text-align: center;
      margin-bottom: 20px;
    }
  
    .ios-title {
      font-size: 26px;
      font-weight: 800;
      margin-bottom: 6px;
    }
  
    .ios-subtitle {
      font-size: 15px;
      color: #555;
    }
  
    /* Cards become very blocky */
    .ios-card {
      border-radius: 16px;
      padding: 18px;
      margin-bottom: 20px;
      background: #ffffff;
      box-shadow: 0 6px 20px rgba(0,0,0,0.06);
    }
  
    /* Force vertical stacking everywhere */
    .ios-row,
    .ios-row-split {
      display: block;
    }
  
    .ios-split {
      width: 100%;
      margin-bottom: 16px;
    }
  
    /* BIG, BOLD LABELS */
    .ios-row-label {
      font-size: 14px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: #111;
      margin-bottom: 6px;
    }
  
    /* Help text under labels */
    .ios-row-help {
      font-size: 13px;
      font-weight: 500;
      color: #666;
      margin-top: 4px;
    }
  
    /* Inputs: full width, tall, touch friendly */
    .ios-row-control input,
    .ios-row-control textarea,
    .ios-row-control select {
      width: 100%;
      padding: 14px 14px;
      border-radius: 12px;
      border: 2px solid #e5e7eb;
      background: #fafafa;
      font-size: 16px;
      transition: border-color 0.15s ease, background 0.15s ease;
    }
  
    .ios-row-control input:focus,
    .ios-row-control textarea:focus,
    .ios-row-control select:focus {
      outline: none;
      border-color: #2563eb;
      background: #ffffff;
    }
  
    /* Textareas feel intentional */
    textarea {
      min-height: 90px;
      resize: vertical;
    }
  
    /* Section titles */
    .ios-section-title {
      font-size: 18px;
      font-weight: 800;
      margin-bottom: 10px;
      color: #111;
    }
  
    /* Items */
    .ios-item {
      padding: 14px 0;
    }
  
    .ios-item-divider {
      margin-top: 16px;
      border-top: 1px solid #e5e7eb;
    }
  
    /* Totals card */
    .ios-totals {
      margin-top: 20px;
    }
  
    .ios-total-row {
      display: flex;
      justify-content: space-between;
      font-size: 15px;
      margin-bottom: 6px;
    }
  
    .ios-total-row-emph {
      font-size: 18px;
      font-weight: 800;
      margin-top: 10px;
    }
  
    /* Buttons: big and tappable */
    .ios-btn {
      display: block;
      width: 100%;
      padding: 16px;
      border-radius: 14px;
      font-size: 16px;
      font-weight: 700;
    }
  
    .ios-btn-primary {
      background: #2563eb;
      color: #fff;
    }
  
    .ios-btn-ghost {
      background: #f1f5f9;
      color: #111;
    }
  
    /* Sticky bottom bar for thumb reach */
    .ios-bottom-bar {
      position: sticky;
      bottom: 0;
      background: #ffffff;
      padding: 14px;
      border-top: 1px solid #e5e7eb;
      margin: -16px;
      margin-top: 24px;
    }
  
    .ios-bottom-inner {
      display: flex;
      flex-direction: column;
      gap: 10px;
    }
  
    .ios-link {
      text-align: center;
      font-size: 14px;
      color: #555;
    }
  }
  
  