:root {
  --ink: #0E1B19;
  --muted: #51635F;
  --line: #D9E2DF;
  --bg: #F3F6F5;
  --card: #ffffff;
  --brand: #0B6B57;
  --brand-ink: #ffffff;
  --ok-bg: #e2f3ea; --ok: #14653f;
  --warn-bg: #FDF0D3; --warn: #6B4800;
  --danger-bg: #FBE3E1; --danger: #8E241D;
  --info-bg: #e4edf8; --info: #1f4f8a;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

a { color: var(--brand); }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .25rem; }
.muted { color: var(--muted); margin: 0 0 .75rem; }
small.muted { display: block; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1rem;
  padding: .6rem 1rem;
  background: #0B1A18; color: #EAF2F0;
  position: sticky; top: 0; z-index: 5;
}
.brand { display: inline-flex; align-items: center; gap: .4rem; font-weight: 700; font-size: 1.25rem; text-decoration: none; color: #EAF2F0; }
.nav { display: flex; gap: .15rem; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; order: 3; }
.nav a { padding: .35rem .8rem; border-radius: 999px; text-decoration: none; color: #C9D8D4; white-space: nowrap; min-height: 36px; }
.nav a[aria-current="page"] { background: #12302B; color: #fff; font-weight: 600; }
.logout { margin-inline-start: auto; }
.logout .link { color: #C9D8D4; }
@media (min-width: 760px) { .nav { flex: 1 1 auto; order: 0; } }

.page { max-width: 960px; margin: 0 auto; padding: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.narrow { max-width: 460px; margin-inline: auto; margin-top: 1.5rem; }
.empty { text-align: center; }

.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }

.btn {
  display: inline-block; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink);
  padding: .65rem 1.25rem; border-radius: 10px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  min-height: 44px;
}
.btn.small { padding: .35rem .9rem; min-height: 36px; font-size: .9rem; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--brand); }
.link { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: .5rem; margin-top: .5rem; }
:focus-visible { outline: 3px solid #f0a500; outline-offset: 2px; }

form > div { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=url], input[type=number], input[type=date], input[type=file], select {
  width: 100%; padding: .6rem .75rem; min-height: 44px;
  border: 1px solid #b9c3cc; border-radius: 10px;
  font: inherit; background: #fff; color: var(--ink);
}
input[type=checkbox] { width: 1.2rem; height: 1.2rem; vertical-align: middle; }
.helptext { display: block; color: var(--muted); font-size: .9rem; }
.errorlist { list-style: none; margin: 0 0 .5rem; padding: .5rem .75rem; background: var(--danger-bg); color: var(--danger); border-radius: 8px; }
.copy { font-size: .85rem; margin-bottom: .5rem; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.msg, .alert { padding: .75rem 1rem; border-radius: 10px; margin: 0 0 .5rem; background: var(--info-bg); color: var(--info); }
.msg-success { background: var(--ok-bg); color: var(--ok); }
.msg-error, .alert.danger { background: var(--danger-bg); color: var(--danger); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert h2 { margin: 0 0 .25rem; }
.alert ul { margin: 0; padding-inline-start: 1.25rem; }
.alert a { color: inherit; font-weight: 600; }

.today { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; }
.stat .num { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat small { color: var(--muted); }

.units, .list { list-style: none; margin: 0 0 1rem; padding: 0; }
.unit {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem 1rem; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: .5rem; text-decoration: none; color: var(--ink);
}
.unit-name { font-weight: 700; }
.unit .muted { grid-column: 1; margin: 0; }
.unit .tag { grid-column: 2; grid-row: 1 / span 2; }
.list li { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .muted { margin: 0; }

.tag { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-renew, .tag-pending { background: var(--warn-bg); color: var(--warn); }
.tag-missing { background: var(--danger-bg); color: var(--danger); }

.month-nav { display: flex; justify-content: space-between; margin-bottom: .75rem; }
.cal-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.cal { border-collapse: collapse; width: max-content; min-width: 100%; }
.cal th, .cal td { border: 1px solid var(--line); text-align: center; }
.cal thead th { font-weight: 600; font-size: .85rem; padding: .25rem; min-width: 36px; }
.cal .dow { display: block; font-size: .65rem; color: var(--muted); font-weight: 400; }
/* position: relative يبقي نص قارئ الشاشة داخل حاوية التمرير فلا تتمدد الصفحة أفقيا. */
.cal td { height: 40px; min-width: 36px; font-weight: 700; position: relative; }
.cal .unit-col { position: sticky; inset-inline-start: 0; background: var(--card); text-align: start; padding: .25rem .75rem; min-width: 110px; max-width: 150px; z-index: 1; font-size: .9rem; }
.cal .is-today { box-shadow: inset 0 0 0 2px #f0a500; }

.s-airbnb { background: #f6b7b0; }
.s-booking { background: #a9c6ef; }
.s-gathern { background: #a8dcc0; }
.s-manual { background: #d9c8ef; }
.s-other { background: #cfd6dc; }
.s-agoda { background: #e6c6ea; }
.s-expedia { background: #f5e3a3; }
.s-vrbo { background: #b9cdf2; }
.s-trip { background: #bfe3ee; }
.s-blocked { background: repeating-linear-gradient(45deg, #d5dade, #d5dade 4px, #f1f3f5 4px, #f1f3f5 8px); }
.s-conflict { background: var(--danger); color: #fff; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem 1rem; padding: 0; margin: .75rem 0; font-size: .85rem; }
.legend i { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px; margin-inline-end: .35rem; vertical-align: middle; text-align: center; font-style: normal; font-weight: 700; line-height: 1.1rem; font-size: .75rem; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 520px) {
  .page { padding: .75rem; }
  .unit { grid-template-columns: 1fr; }
  .unit .tag { grid-column: 1; grid-row: auto; justify-self: start; margin-top: .25rem; }
}

/* صفحات التشغيل */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpis .stat .num { font-size: 1.6rem; }
.stat a { color: inherit; }
.cell-link { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; line-height: 40px; }
.table-wrap { position: relative; overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
table.data { border-collapse: collapse; width: 100%; min-width: 620px; }
table.data th, table.data td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
table.data thead th { font-size: .85rem; color: var(--muted); font-weight: 600; }
table.data tfoot td { font-weight: 700; border-bottom: 0; background: var(--bg); }
.num-cell { font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form > div { margin: 0; }
.inline-form input[type=number] { width: 7.5rem; min-height: 36px; padding: .3rem .5rem; }
.inline-form select { min-height: 36px; padding: .3rem .5rem; width: auto; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.timer { font-weight: 700; font-variant-numeric: tabular-nums; }
.list li > .grow { flex: 1 1 12rem; }
textarea { width: 100%; padding: .6rem .75rem; border: 1px solid #b9c3cc; border-radius: 10px; font: inherit; }

/* الاستقبال والأسعار */
select { font: inherit; padding: .4rem .6rem; border: 1px solid var(--line, #D5DEDB); border-radius: 8px; background: #fff; min-height: 40px; }
.tag-pending { background: #EEF2F1; color: #3E4F4B; }

/* الفاتورة */
.invoice-page { background: #F3F6F5; padding: 16px; }
.invoice-bar { max-width: 760px; margin: 0 auto 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.invoice-page .alert, .invoice-page .messages { max-width: 760px; margin-inline: auto; }
.invoice { max-width: 760px; margin: 0 auto; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 1px 3px rgba(11, 26, 24, .08); }
.invoice-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid #0B1A18; padding-bottom: 16px; }
.invoice-head h1 { margin: 0 0 8px; font-size: 1.5rem; }
.invoice-head p, .invoice-parties p { margin: 2px 0; }
.invoice-qr svg { width: 132px; height: 132px; display: block; }
.invoice-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 20px 0; }
.invoice-parties h2 { font-size: .85rem; color: #5B6B67; margin: 0 0 6px; font-weight: 600; }
.invoice-lines { width: 100%; }
.invoice-lines tfoot th { text-align: start; font-weight: 500; }
.invoice-total th, .invoice-total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid #0B1A18; }
.invoice-paid { margin-top: 16px; color: #5B6B67; }
@media print {
  .no-print { display: none !important; }
  .invoice-page { background: #fff; padding: 0; }
  .invoice { box-shadow: none; border-radius: 0; padding: 0; max-width: none; }
}
table.invoice-lines { min-width: 0; width: 100%; table-layout: fixed; }
table.invoice-lines th:last-child, table.invoice-lines td:last-child { width: 34%; text-align: end; }
table.invoice-lines td, table.invoice-lines th { overflow-wrap: anywhere; }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters input, .filters select { flex: 1 1 9rem; min-width: 0; }
.inline-form select { padding: .15rem .3rem; font-size: .85rem; }
.date-wrap { display: flex; gap: .5rem; align-items: center; }
.date-wrap input { flex: 1 1 auto; min-width: 0; }
.date-clear { flex: 0 0 auto; background: transparent; border: 1px solid var(--line, #c9d3d0); border-radius: 999px;
  padding: .35rem .9rem; font: inherit; font-size: .9rem; color: inherit; cursor: pointer; }
.date-clear[hidden] { display: none; }
input:user-invalid { border-color: var(--danger); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
