/* ماء القرية — palette drawn from irrigation and water */
:root {
  --ink:        #10242E;
  --water:      #0E6E72;
  --water-dark: #0A5559;
  --water-soft: #DCEAEA;
  --surface:    #F7F9F8;
  --card:       #FFFFFF;
  --line:       #D5E0DF;
  --muted:      #5B6E74;
  --paid:       #15803D;
  --paid-soft:  #E3F2E8;
  --unpaid:     #B3261E;
  --unpaid-soft:#F9E5E3;
  --warn-soft:  #FCF3DC;
  --warn-ink:   #7A5A12;
}

@font-face {
  font-family: 'Cairo';
  src: url('/assets/fonts/cairo-700.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('/assets/fonts/plex-arabic-400.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('/assets/fonts/plex-arabic-500.woff2') format('woff2');
  font-weight: 500; font-display: swap;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', 'Noto Sans Arabic', Tahoma, Arial, sans-serif;
  line-height: 1.6;
}
h1, h2, h3 { font-family: 'Cairo', 'IBM Plex Sans Arabic', Tahoma, sans-serif; line-height: 1.3; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }

.container { max-width: 900px; margin-inline: auto; padding-inline: 1rem; padding-block-end: 3rem; }

/* nav */
.nav { background: var(--water); color: #fff; }
.nav-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem;
             padding-block: .6rem; padding-block-end: .6rem; }
.brand { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; flex-wrap: wrap; gap: .1rem; align-items: center; margin-inline-start: auto; }
.nav-links a, .nav-links .btn-link {
  color: #fff; text-decoration: none; padding: .55rem .6rem; border-radius: 6px;
  font-size: .95rem; min-height: 44px; display: inline-flex; align-items: center;
}
.nav-links a:hover, .nav-links .btn-link:hover { background: var(--water-dark); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        padding: 1rem; margin-block: 1rem; }
.page-title { margin-block: 1.25rem .5rem; }
.muted { color: var(--muted); font-size: .95rem; }
.note { background: var(--water-soft); border-radius: 8px; padding: .6rem .8rem; font-size: .95rem; }
.empty { text-align: center; color: var(--muted); padding-block: 2.5rem; }

/* hero — the one number every resident opens the app to see */
.hero-card { background: var(--water); color: #fff; border-radius: 12px;
             padding: 1.5rem 1rem; margin-block: 1rem; text-align: center;
             display: flex; flex-direction: column; gap: .25rem; }
.hero-label { font-size: 1rem; opacity: .9; }
.hero-amount { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 2.5rem;
               direction: ltr; unicode-bidi: embed; }
.hero-zero { color: #C9F0D6; }
.hero-sub { opacity: .9; }

/* meter strip — signature element */
.meter-strip { display: flex; align-items: stretch; gap: .5rem; margin-block: .5rem;
               direction: ltr; /* meter digits read LTR like the physical meter */ }
.meter-end { display: flex; flex-direction: column; align-items: center; gap: .1rem;
             background: var(--water-soft); border-radius: 8px; padding: .5rem .75rem; }
.meter-label { font-size: .75rem; color: var(--muted); }
.meter-value { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 1.2rem; }
.meter-span { flex: 1; display: flex; align-items: center; justify-content: center;
              border-block-end: 2px solid var(--water); position: relative; min-width: 60px; }
.meter-consumption { background: var(--card); padding-inline: .4rem; font-weight: 500;
                     color: var(--water); transform: translateY(50%); }

/* badges — icon + text, never colour alone */
.badge { display: inline-block; border-radius: 999px; padding: .1rem .6rem;
         font-size: .85rem; white-space: nowrap; }
.badge-paid    { background: var(--paid-soft);   color: var(--paid); }
.badge-paid::before    { content: '✓ '; }
.badge-unpaid  { background: var(--unpaid-soft); color: var(--unpaid); }
.badge-unpaid::before  { content: '• '; }
.badge-overdue { background: var(--unpaid);      color: #fff; }
.badge-overdue::before { content: '! '; }

/* invoice list */
.invoice-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.invoice-card { display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem;
                background: var(--card); border: 1px solid var(--line); border-radius: 10px;
                padding: .8rem 1rem; text-decoration: none; color: inherit; }
.invoice-card:hover { border-color: var(--water); }
.invoice-month { font-weight: 500; }
.invoice-amount { font-family: 'Cairo', sans-serif; font-weight: 700; text-align: end; }
.invoice-due { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }

/* forms */
label { display: block; margin-block-end: .75rem; font-weight: 500; }
input, select {
  display: block; width: 100%; margin-block-start: .25rem;
  padding: .6rem .7rem; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
  min-height: 44px;
}
input:focus, select:focus, button:focus, a:focus {
  outline: 3px solid var(--water); outline-offset: 1px;
}
.form-grid { max-width: 420px; }
.field-error, .form-error { color: var(--unpaid); font-weight: 500; }
.check-label { display: flex; align-items: center; gap: .5rem; }
.check-label input { width: auto; min-height: auto; margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; min-height: 44px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  font-size: 1rem; font-family: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--water); }
.btn-primary { background: var(--water); border-color: var(--water); color: #fff; }
.btn-primary:hover { background: var(--water-dark); }
.btn-whatsapp { background: #128C4A; border-color: #128C4A; color: #fff; }
.btn-block { display: flex; width: 100%; }
.btn-small { padding: .3rem .7rem; min-height: 38px; font-size: .9rem; }
.btn-link { background: none; border: none; cursor: pointer; font: inherit;
            color: var(--water); text-decoration: underline; padding: .5rem; min-height: 44px; }
.btn-link.small { font-size: .85rem; min-height: 38px; }
.btn-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.inline-form { display: inline; }

/* auth */
.auth-card { max-width: 380px; margin-block-start: 3rem; margin-inline: auto;
             background: var(--card); border: 1px solid var(--line); border-radius: 12px;
             padding: 1.5rem; }

/* flash */
.flash { border-radius: 8px; padding: .7rem 1rem; margin-block: 1rem; font-weight: 500; }
.flash-success { background: var(--paid-soft); color: var(--paid); }
.flash-error   { background: var(--unpaid-soft); color: var(--unpaid); }
.flash-warning { background: var(--warn-soft); color: var(--warn-ink); }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th { background: var(--water-soft); text-align: start; font-weight: 500; }
.table th, .table td { border: 1px solid var(--line); padding: .5rem .6rem; vertical-align: middle; }
.row-inactive td { color: var(--muted); }
.row-error td { background: var(--unpaid-soft); }
.row-error-msg td { border-block-start: none; padding-block: .2rem; }
.actions-cell { white-space: nowrap; }
.actions-cell form { margin-inline-end: .3rem; }
.num-input { max-width: 8rem; text-align: end; }
.sent-mark { color: var(--paid); font-size: .9rem; white-space: nowrap; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
             padding: .9rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 1.3rem; }
.stat-sub, .stat-link { font-size: .85rem; }
.month-picker { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin-block: .75rem; }
.month-picker label { margin: 0; flex: 1 1 120px; }
.month-picker .check-label { flex-basis: auto; align-self: center; }

/* tabs */
.tabs { display: flex; gap: .25rem; border-block-end: 2px solid var(--line); margin-block: 1rem .75rem; }
.tab { padding: .5rem .9rem; min-height: 44px; display: inline-flex; align-items: center;
       text-decoration: none; color: var(--muted); border-radius: 8px 8px 0 0; }
.tab-active { color: var(--water); font-weight: 700; border-block-end: 3px solid var(--water); }

/* detail list */
.detail-list { margin: 0; }
.detail-list > div { display: flex; justify-content: space-between; gap: 1rem;
                     padding-block: .45rem; border-block-end: 1px solid var(--line); }
.detail-list > div:last-child { border-block-end: none; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: end; }
.detail-strong dt, .detail-strong dd { font-weight: 700; color: var(--ink); }

/* password display */
.pw-card { text-align: center; }
.pw-display { font-family: 'Cairo', monospace; font-size: 2rem; letter-spacing: .3rem;
              background: var(--water-soft); border-radius: 10px; padding: .6rem; user-select: all; }
.pw-card .btn-row { justify-content: center; }

.back-link { display: inline-block; margin-block-start: 1rem; color: var(--water); }
.error-page { text-align: center; padding-block: 3rem; }

@media (prefers-reduced-motion: no-preference) {
  main.container { animation: fade .15s ease-out; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
}
@media (max-width: 420px) {
  .nav-links a, .nav-links .btn-link { padding: .55rem .45rem; font-size: .88rem; }
  .hero-amount { font-size: 2rem; }
}
