/* ========================================
   Form Pages
   ======================================== */
.narrow-page {
  margin: 0 auto;
  max-width: 820px;
  animation: fadeSlideUp 400ms var(--ease-out) both;
}

.back-link {
  color: var(--muted);
  display: inline-flex;
  font-weight: 700;
  font-size: 13px;
  gap: 8px;
  margin-bottom: 28px;
  transition: color var(--transition);
}
.back-link:hover {
  color: var(--ink-secondary);
}

.back-link::before {
  content: "←";
  font-size: 15px;
}

.page-title {
  margin-bottom: 28px;
}

/* --- Form Layout --- */
.invoice-form {
  display: grid;
  gap: 20px;
}

.form-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px 30px;
  transition: box-shadow var(--transition);
}
.form-card:focus-within {
  box-shadow: var(--shadow);
  border-color: var(--line-gold);
}

.form-card h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--ink-secondary);
}

.card-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-heading h2 {
  margin-bottom: 0;
}

/* --- Form Grids --- */
.form-grid {
  display: grid;
  gap: 18px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.span-two {
  grid-column: span 2;
}

/* --- Labels & Inputs --- */
label {
  color: var(--ink-secondary);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
}

.required {
  color: var(--red);
}

.label-text {
  white-space: nowrap;
}

datalist {
  display: none;
}

input,
textarea,
select {
  background: #fffcf9;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  min-height: 46px;
  outline: none;
  padding: 0 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

textarea {
  min-height: 90px;
  padding: 12px 14px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

input:read-only {
  background: var(--wash);
  color: var(--muted);
  cursor: default;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a7e72' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* --- Items List --- */
.items-list {
  display: grid;
  gap: 12px;
}

.item-row {
  align-items: end;
  background: var(--wash-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(160px, 1.5fr) 80px 100px 130px 130px 40px;
  padding: 16px;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeSlideUp 300ms var(--ease-out) both;
}
.item-row:hover {
  border-color: var(--line-gold);
}
.item-row:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.item-row label {
  font-size: 11px;
  gap: 5px;
}

.item-row input {
  min-height: 40px;
  font-size: 13px;
  padding: 0 10px;
}

.item-row input[readonly] {
  background: var(--wash);
  color: var(--ink-secondary);
  cursor: default;
}

.remove-item {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 16px;
  font-weight: 700;
  height: 40px;
  justify-content: center;
  margin-bottom: 0;
  transition: all var(--transition);
  width: 40px;
}
.remove-item:hover {
  background: var(--red-soft);
  border-color: #e8b4b2;
  color: var(--red);
}

.subtotal-field {
  color: var(--gold-dark);
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
  min-height: 24px;
  text-align: right;
  grid-column: 1 / -1;
  padding-right: 52px;
}

/* --- Form Total --- */
.input-with-icon {
  position: relative;
}
.input-with-icon .input-icon {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  font-weight: 700;
  height: 100%;
  padding: 0 0 0 14px;
  pointer-events: none;
  position: absolute;
  top: 0;
}
.input-with-icon input {
  padding-left: 36px;
}

.form-total {
  align-items: center;
  background: linear-gradient(135deg, #faf6ef 0%, #fdf8f2 100%);
  border: 1.5px solid var(--line-gold);
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 22px;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-total::before {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: var(--radius);
  background: var(--gold-gradient);
  opacity: 0.08;
  pointer-events: none;
}

.form-total .total-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.form-total .total-label span:first-child {
  color: var(--ink-secondary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.form-total .total-label .item-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.form-total .total-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.form-total .total-value .total-amount {
  font-family: "Cormorant Garamond", serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--gold-dark);
  line-height: 1;
  letter-spacing: 0.01em;
}
.form-total .total-value .total-label-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* --- Detail Nav Buttons --- */
.detail-nav {
  align-items: center;
  display: flex;
  gap: 6px;
}
.nav-btn {
  align-items: center;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-size: 16px;
  height: 36px;
  justify-content: center;
  transition: all 200ms var(--ease-out);
  width: 36px;
}
.nav-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(194, 143, 43, 0.05);
  box-shadow: 0 4px 12px rgba(194, 143, 43, 0.12);
  transform: translateY(-1px);
}
.nav-btn:active:not(:disabled) {
  transform: scale(0.93);
}
.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ========================================
   Detail Page
   ======================================== */
.detail-page {
  margin: 0 auto;
  max-width: 1140px;
  animation: fadeSlideUp 400ms var(--ease-out) both;
}

.detail-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.detail-title {
  align-items: end;
  display: flex;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 28px;
}

.detail-title h1 {
  font-size: clamp(28px, 3vw, 40px);
}

.detail-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

