:root {
  --navy: #131b3d;
  --navy-2: #1c2650;
  --gold: #ad8134;
  --gold-light: #c9a35c;
  --cream: #f2ede1;
  --card: #ffffff;
  --green: #1f6b45;
  --green-bg: #e7f3ec;
  --red: #a5342f;
  --red-bg: #fbeceb;
  --teal: #7fa89b;
  --text: #1f2430;
  --text-muted: #6b7280;
  --border: #e7e1d4;
  --radius: 16px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Tahoma', 'Segoe UI', system-ui, sans-serif;
  background: var(--cream);
  color: var(--text);
  direction: rtl;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px 40px; }

/* ===== Header ===== */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 18px 20px;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 48px; height: 48px;
  background: var(--gold);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.brand-text h1 { font-size: 19px; margin: 0; font-weight: 700; }
.brand-text p { font-size: 12.5px; margin: 2px 0 0; color: #c3c8dd; }

.session-info { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #dfe2f0; }
.role-pill {
  background: var(--gold);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
}
.logout-btn {
  background: transparent;
  border: 1px solid #4a5378;
  color: #dfe2f0;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
}
.logout-btn:hover { background: #232d5a; }

/* ===== Nav tabs ===== */
.tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.tabs-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
  padding: 0 16px;
  overflow-x: auto;
}
.tab {
  padding: 16px 14px;
  font-weight: 700;
  font-size: 14.5px;
  color: #6b7280;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab:hover { color: var(--navy); }

/* ===== Cards ===== */
.grid { display: grid; gap: 18px; margin-top: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.stat-card { text-align: center; }
.stat-label { font-size: 14px; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }
.stat-value { font-size: 32px; font-weight: 800; }
.stat-value.gold { color: var(--gold); }
.stat-value.green { color: var(--green); }
.stat-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

.section-title {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.section-title h2 { font-size: 17px; margin: 0; }
.section-title a { color: var(--gold); font-size: 13.5px; font-weight: 700; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: var(--red); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; color: #374151; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--cream);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--gold);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.radio-group { display: flex; gap: 10px; }
.radio-option {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  background: var(--cream);
}
.radio-option input { display: none; }
.radio-option.selected { background: var(--navy); color: #fff; border-color: var(--navy); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; font-weight: 600; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 700; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-cash { background: var(--green-bg); color: var(--green); }
.badge-mada { background: #e8ecf7; color: var(--navy); }
.badge-in { background: var(--green-bg); color: var(--green); }
.badge-out { background: var(--red-bg); color: var(--red); }

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

/* ===== Invoice item rows (dynamic form) ===== */
.item-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 10px; }
.item-row .field { margin-bottom: 0; }
.item-row .item-select { flex: 3; }
.item-row .item-qty { flex: 1; }
.item-row .remove-row { flex-shrink: 0; }
.total-box {
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex; justify-content: space-between; align-items: center;
  margin: 18px 0;
}
.total-box .label { font-size: 14px; color: #c3c8dd; }
.total-box .amount { font-size: 26px; font-weight: 800; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 36px 30px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-card .brand-icon { margin: 0 auto 16px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card p { color: var(--text-muted); font-size: 13.5px; margin: 0 0 26px; }
.login-card .field { text-align: right; }

/* ===== Print invoice ===== */
.invoice-paper {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 30px; max-width: 560px; margin: 24px auto;
}
.invoice-head { display: flex; justify-content: space-between; border-bottom: 2px dashed var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.invoice-head h2 { margin: 0; font-size: 20px; }
.invoice-meta { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }
.print-actions { text-align: center; margin-top: 20px; display: flex; gap: 10px; justify-content: center; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .invoice-paper { border: none; margin: 0; max-width: 100%; }
}

.helper-text { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.mt-24 { margin-top: 24px; }
