/* ==========================================================================
   AXIS Group — app styles
   Light beige, warm, minimal. Logical properties throughout so the same
   stylesheet serves LTR and RTL without a mirrored copy.
   ========================================================================== */

/* --- self-hosted fonts (no CDN calls) --- */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('../fonts/plex-arabic-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('../fonts/plex-arabic-600.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  src: url('../fonts/plex-arabic-700.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg:        #F6F1E8;
  --card:      #FFFDF8;
  --text:      #2B2620;
  --muted:     #8A8073;
  --accent:    #8A6F4D;
  --accent-dk: #71593B;
  --green:     #3E7C4F;
  --red:       #B3492F;
  --amber:     #C08A2D;
  --line:      #E7DECF;
  --shadow:    0 1px 2px rgba(43, 38, 32, .04), 0 6px 18px rgba(43, 38, 32, .06);
  --radius:    18px;
  --radius-sm: 12px;
  --tap:       44px;
  --maxw:      760px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
html[lang="ar"] body {
  font-family: 'IBM Plex Sans Arabic', 'Inter', system-ui, 'Segoe UI', sans-serif;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }
button, input, select, textarea { font: inherit; color: inherit; }

/* --- layout ---------------------------------------------------------- */

.appbar {
  position: sticky; inset-block-start: 0; z-index: 30;
  background: rgba(246, 241, 232, .92);
  backdrop-filter: blur(8px);
  border-block-end: 1px solid var(--line);
  padding-block-start: env(safe-area-inset-top);
}
.appbar-in {
  display: flex; align-items: center; gap: .6rem;
  max-width: var(--maxw); margin-inline: auto;
  padding: .55rem .9rem;
}
.appbar-title {
  font-size: 1rem; font-weight: 600; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1 1 auto;
}
.appbar-actions { display: flex; align-items: center; gap: .4rem; margin-inline-start: auto; }
.brand { display: flex; align-items: center; }
.brand-word { font-weight: 700; letter-spacing: .18em; font-size: 1.05rem; color: var(--accent); }
.brand-logo { max-height: 26px; width: auto; }
.login-brand { display: flex; justify-content: center; margin-block-end: .5rem; }
.login-brand .brand-word { font-size: 1.7rem; }
.login-brand .brand-logo { max-height: 52px; }

.iconbtn, .langtoggle {
  min-width: var(--tap); min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 0; background: none; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--accent);
}
.langtoggle.inline { min-height: auto; text-decoration: underline; }
.iconbtn svg { width: 22px; height: 22px; }
html[dir="rtl"] .back svg { transform: scaleX(-1); }

.shell { display: block; max-width: var(--maxw); margin-inline: auto; }
.main { padding-block-end: calc(78px + env(safe-area-inset-bottom)); }
.main-bare { padding: 0; }
.page { padding: .9rem; display: flex; flex-direction: column; gap: .9rem; }
.page.narrow { max-width: 560px; margin-inline: auto; width: 100%; }

.sidenav { display: none; }

/* Desktop: sidebar instead of the bottom tab bar. */
@media (min-width: 900px) {
  :root { --maxw: 1040px; }
  .shell { display: grid; grid-template-columns: 220px 1fr; gap: 1.2rem; align-items: start; }
  .sidenav {
    display: flex; flex-direction: column; gap: .2rem;
    position: sticky; inset-block-start: 70px;
    padding: 1rem .5rem;
  }
  .sidenav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .7rem .8rem; border-radius: var(--radius-sm);
    color: var(--muted); font-weight: 600; font-size: .95rem;
  }
  .sidenav-item svg { width: 20px; height: 20px; }
  .sidenav-item:hover { background: var(--card); color: var(--text); }
  .sidenav-item.is-active { background: var(--accent); color: #fff; }
  .tabbar { display: none; }
  .main { padding-block-end: 2rem; }
  .fab { inset-block-end: 1.5rem; }
}

/* --- bottom tab bar --------------------------------------------------- */
.tabbar {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(255, 253, 248, .96);
  backdrop-filter: blur(8px);
  border-block-start: 1px solid var(--line);
  padding-block-end: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: .45rem .2rem .5rem;
  color: var(--muted); font-size: .68rem; font-weight: 600;
}
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--accent); }

/* --- cards & typography ---------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-title.no-margin { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.center { text-align: center; }
.block  { display: block; }
.grow   { flex: 1 1 auto; min-width: 0; }
.mt     { margin-block-start: .8rem; }
.mt-xs  { margin-block-start: .4rem; }
.mb-xs  { margin-block-end: .4rem; }
.row    { display: flex; align-items: flex-start; }
.row.center-y { align-items: center; }
.row.gap { gap: .6rem; }
.row.gap-xs { gap: .25rem; }
.row.wrap { flex-wrap: wrap; }
.row.space-between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.amount-big { font-size: 1.25rem; font-weight: 700; }
.offscreen { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }
.is-inactive { opacity: .6; }
.chev { color: var(--muted); font-size: 1.2rem; }
.link { color: var(--accent); text-decoration: underline; }
.note { color: var(--amber); font-size: .82rem; margin: .3rem 0 0; }
.arrow { color: var(--muted); }
html[dir="rtl"] .arrow { transform: scaleX(-1); display: inline-block; }

/* --- forms ------------------------------------------------------------ */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="tel"], input[type="search"], input[type="email"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .6rem .75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 111, 77, .14); }
input[type="file"] { padding: .5rem; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius-sm); width: 100%; }
.check { display: flex; align-items: center; gap: .55rem; min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 auto; }
.check.big { font-weight: 600; }
.checkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .1rem .6rem; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.fieldset legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding-inline: .3rem; }
.adminbox { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: .6rem .8rem; }
.split summary { font-weight: 600; cursor: pointer; display: flex; gap: .5rem; align-items: baseline; }
details > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; }

/* --- buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .6rem 1.05rem;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; cursor: pointer;
  background: none; text-align: center;
}
.btn-block { width: 100%; }
.btn-small { min-height: 38px; padding: .35rem .85rem; font-size: .85rem; }
.btn-tiny  { min-height: 32px; padding: .2rem .7rem; font-size: .78rem; border: 1px solid var(--line); background: #fff; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dk); }
.btn-success { background: var(--green); color: #fff; }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn-danger-ghost { background: var(--card); border-color: var(--line); color: var(--red); }
.btn-wa { background: #25D366; color: #08301a; }

.fab {
  position: fixed;
  inset-inline-end: 1rem;
  inset-block-end: calc(78px + env(safe-area-inset-bottom));
  z-index: 25;
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px rgba(138, 111, 77, .38);
}
.fab svg { width: 26px; height: 26px; }

/* --- pills, chips, badges -------------------------------------------- */
.pill {
  display: inline-flex; align-items: center;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.pill-grey   { background: #EFE9DE; color: var(--muted); }
.pill-amber  { background: #F7EBD3; color: #8a6318; }
.pill-green  { background: #DFEEE3; color: var(--green); }
.pill-red    { background: #F6DFD8; color: var(--red); }
.pill-bronze { background: #EDE2D2; color: var(--accent-dk); }
.cat-chip { background: #EFE9DE; color: var(--muted); border-radius: 999px; padding: .1rem .55rem; font-size: .74rem; }
.icon-inline svg { width: 15px; height: 15px; }

/* --- avatars ---------------------------------------------------------- */
.avatar {
  flex: 0 0 auto;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #EDE2D2; color: var(--accent-dk);
  font-size: .8rem; font-weight: 700; letter-spacing: .02em;
}
.avatar.xs { width: 24px; height: 24px; font-size: .62rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .7rem; }
.avatar.lg { width: 52px; height: 52px; font-size: 1rem; }
.company-logo { max-height: 22px; width: auto; }
.logo-preview { max-height: 52px; width: auto; border-radius: 8px; }

/* --- money ------------------------------------------------------------ */
.money { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.money.pos  { color: var(--green); }
.money.neg  { color: var(--red); }
.money.zero { color: var(--muted); }

/* --- lists ------------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; gap: .7rem; justify-content: space-between;
  min-height: var(--tap); padding: .55rem 0;
  border-block-end: 1px solid var(--line);
}
.list-row.column { flex-direction: column; align-items: flex-start; gap: .15rem; }
.list > li:last-child .list-row,
.list-row:last-child { border-block-end: 0; }

.balances { list-style: none; margin: .4rem 0 0; padding: 0; }
.balance-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem 0; border-block-end: 1px solid var(--line);
}
.balance-row:last-child { border-block-end: 0; }
.balance-name { flex: 1 1 auto; min-width: 0; }

.alert { display: block; border-inline-start: 4px solid var(--amber); }
.alert-red { border-inline-start-color: var(--red); }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }

/* --- expenses list ---------------------------------------------------- */
.exp-row {
  display: flex; align-items: center; gap: .8rem; justify-content: space-between;
  padding: .6rem 0; border-block-end: 1px solid var(--line);
  min-height: var(--tap);
}
.list > li:last-child .exp-row { border-block-end: 0; }
.exp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.exp-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.filters { display: flex; flex-direction: column; gap: .6rem; }
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox svg { position: absolute; inset-inline-start: .7rem; width: 18px; height: 18px; color: var(--muted); }
.searchbox input { padding-inline-start: 2.3rem; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  width: auto; min-height: 38px; padding-block: .3rem; padding-inline: .7rem 2rem;
  border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font-size: .82rem; max-width: 100%;
}
.custom-range { align-items: flex-end; }
.totalsbar {
  position: sticky; inset-block-start: 56px; z-index: 10;
  background: var(--accent); color: #fff;
  border-radius: var(--radius-sm);
  padding: .55rem .9rem;
  font-size: .88rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* --- tables ----------------------------------------------------------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 380px; }
.table th, .table td { padding: .55rem .5rem; border-block-end: 1px solid var(--line); text-align: start; }
.table thead th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot th { font-weight: 700; border-block-end: 0; }

/* --- payments --------------------------------------------------------- */
.paylist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.paycard { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .8rem; }

/* --- posts / receipts ------------------------------------------------- */
.post { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.postbody { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.postimg, .receipt { border-radius: var(--radius-sm); width: 100%; }
.receipt { max-height: 70vh; object-fit: contain; background: #fff; }

.deflist { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; margin: .7rem 0 0; }
.deflist dt { color: var(--muted); font-size: .84rem; }
.deflist dd { margin: 0; overflow-wrap: anywhere; }

.copybtn {
  border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm);
  padding: .2rem .6rem; cursor: pointer; min-height: 32px;
}

/* --- flash ------------------------------------------------------------ */
.flash {
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  font-size: .9rem;
  margin: .9rem .9rem 0;
}
.page .flash, .card .flash { margin: 0; }
.flash-info    { background: #EFE9DE; color: var(--text); }
.flash-success { background: #DFEEE3; color: var(--green); }
.flash-warning { background: #F7EBD3; color: #8a6318; }
.flash-error   { background: #F6DFD8; color: var(--red); }

/* --- login ------------------------------------------------------------ */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.login-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: .9rem; padding: 1.6rem 1.3rem; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .sidenav-item { transition: background-color .15s ease, color .15s ease; }
}
