* { box-sizing: border-box; min-width: 0; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background: #f4f6f5;
  color: #1c1c1c;
  direction: rtl;
}

/* ---------------- login ---------------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #0a5 0%, #063 100%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 6px 0 0; font-size: 22px; }
.login-card .subtitle { color: #666; margin: 2px 0 20px; }
.login-card form { text-align: right; }
.login-card label { display: block; font-size: 13px; color: #555; margin: 12px 0 4px; }
.login-card input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
}
.login-card button {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: #0a5;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.error-box {
  background: #fdecea;
  color: #b3261e;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  margin-bottom: 6px;
}

/* ---------------- app shell ---------------- */
.topbar {
  background: #0a5;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .logout { color: #eafff2; text-decoration: none; font-size: 14px; }

.container { padding: 12px; max-width: 900px; margin: 0 auto; }

.search-card, .result-card {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.field-row { margin-bottom: 14px; }
.field-row:last-child { margin-bottom: 0; }
.field-row label { display: block; font-size: 13px; color: #555; margin-bottom: 6px; }
.field-row input, .field-row select {
  width: 100%;
  padding: 11px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: #1c1c1c;
}

.btn-row { display: flex; gap: 10px; }
.primary-btn, .secondary-btn {
  flex: 1;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn { background: #0a5; color: #fff; }
.secondary-btn { background: #eef4f1; color: #0a5; border: 1px solid #bfe3d2; }
.primary-btn:disabled, .secondary-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.status-msg {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: #eef4f1;
  color: #0a5;
}
.status-msg.status-error {
  background: #fdecea;
  color: #b3261e;
}

/* ---------------- نتيجة/معاينة الفاتورة ---------------- */
.invoice-head { margin-bottom: 14px; }
.invoice-head-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed #eee;
}
.ihl { color: #666; font-weight: 600; }
.ihv { color: #1c1c1c; margin-inline-end: 12px; }
.invoice-note {
  margin-top: 8px;
  font-size: 12px;
  color: #777;
  font-style: italic;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid #eee;
  border-radius: 10px;
}
#linesTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
#linesTable th, #linesTable td {
  padding: 8px 6px;
  text-align: center;
  border-bottom: 1px solid #f0f0f0;
}
#linesTable th {
  background: #0a5c3a;
  color: #fff;
  position: sticky;
  top: 0;
}
#linesTable td.cell-right { text-align: right; white-space: normal; }
#linesTable tbody tr:nth-child(even) { background: #fafafa; }

.invoice-footer {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  font-size: 14px;
  padding-top: 12px;
  border-top: 1px solid #eee;
}
.invoice-footer .ihl { display: inline-block; min-width: 90px; }

@media (max-width: 480px) {
  .btn-row { flex-direction: column; }
  .invoice-footer { grid-template-columns: 1fr; }
}
