/* Fonts are served from /static/fonts so the system works without internet. */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(fonts/plex-arabic-arabic-400.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(fonts/plex-arabic-arabic-500.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(fonts/plex-arabic-arabic-600.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(fonts/plex-arabic-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(fonts/plex-arabic-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(fonts/plex-arabic-latin-500.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(fonts/plex-arabic-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(fonts/plex-arabic-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Alexandria'; font-weight: 600; font-display: swap; src: url(fonts/alexandria-arabic-600.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 700; font-display: swap; src: url(fonts/alexandria-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 600; font-display: swap; src: url(fonts/alexandria-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Alexandria'; font-weight: 700; font-display: swap; src: url(fonts/alexandria-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --ink: #0F2A4A;
  --ink-2: #2A4361;
  --steel: #5B6B7D;
  --steel-2: #8796A6;
  --paper: #EDF0F3;
  --sheet: #FFFFFF;
  --sheet-2: #F7F9FB;
  --rule: #DCE2E8;
  --rule-strong: #BCC7D2;
  --signal: #E3742B;
  --signal-text: #A3480F;
  --signal-soft: #FCEAD9;
  --ok: #22704A;
  --ok-soft: #DDF0E4;
  --bad: #B3261E;
  --bad-soft: #F8E1DF;
  --info: #1F4E86;
  --info-soft: #E2EBF6;
  --focus: #2F6FB5;
  --font: 'Plex Arabic', 'Segoe UI', Tahoma, sans-serif;
  --display: 'Alexandria', 'Plex Arabic', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: 0 0 8px; }
small { font-size: 12.5px; }
.muted { color: var(--steel); }
.n, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
/* A whole cell or value in LTR still lines up with the rest of the RTL column. */
td.ltr, dd.ltr { display: revert; text-align: right; }
.nowrap { white-space: nowrap; }
.right { text-align: left; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Shell ------------------------------------------------------------------ */

.shell {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  background: var(--ink);
  color: #C8D3E0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 18px 0 14px;
}

.brand {
  display: block;
  padding: 0 20px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  text-decoration: none !important;
}
.brand-name {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  color: #fff;
  letter-spacing: 0;
}
.brand-co { display: block; font-size: 12.5px; color: #8EA3BB; }

.side ul { list-style: none; margin: 0; padding: 0; }
.side li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 20px;
  color: #D5DEE8;
  font-size: 14.5px;
  border-inline-start: 3px solid transparent;
  text-decoration: none;
}
.side li a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side li a.on {
  background: rgba(255, 255, 255, .08);
  border-inline-start-color: var(--signal);
  color: #fff;
  font-weight: 500;
}
.nav-group {
  padding: 16px 20px 4px;
  font-size: 12px;
  color: #7F93AA;
}
.side .count {
  background: var(--signal);
  color: #fff;
  border-radius: 10px;
  font-size: 11.5px;
  padding: 0 7px;
  line-height: 1.6;
}
.side-bottom {
  margin-top: auto !important;
  padding-top: 14px !important;
  border-top: 1px solid rgba(255, 255, 255, .08) !important;
}
.who {
  padding: 12px 20px 0;
  display: grid;
  gap: 1px;
  font-size: 13.5px;
  color: #fff;
}
.who small { color: #8EA3BB; }
.who .link-btn { color: #9FC2EA; font-size: 13px; }

.main {
  padding: 26px 34px 64px;
  max-width: 1320px;
  width: 100%;
}
.main.wide { max-width: none; }

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.top h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 25px;
  color: var(--ink);
}
.top .sub { color: var(--steel); margin: 2px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu-btn { display: none; }
.top-end { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--sheet);
  color: var(--ink-2);
}
.bell:hover, .bell.on { border-color: var(--ink-2); color: var(--ink); }
.bell svg { width: 20px; height: 20px; fill: currentColor; }
.bell .count {
  position: absolute;
  top: -7px;
  inset-inline-end: -7px;
  min-width: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--signal);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  text-align: center;
}

/* Blocks and layout ---------------------------------------------------- */

.block {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-bottom: 20px;
}
.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--rule);
}
.block-head h2 { font-size: 16px; font-weight: 600; }
.block-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pad { padding: 16px 18px; }
.block > .table-wrap:last-child table { border-radius: 0 0 8px 8px; }

.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.cols-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Tables ------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.grid th {
  text-align: start;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--steel);
  background: var(--sheet-2);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
}
table.grid td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: #FAFBFC; }
table.grid tfoot td {
  font-weight: 600;
  border-top: 1px solid var(--rule-strong);
  background: var(--sheet-2);
  padding: 9px 12px;
}
table.grid .sub-row td { background: var(--sheet-2); font-size: 13px; color: var(--steel); }
table.grid tr.dim td { color: var(--steel-2); }
table.grid tr.warn td { background: #FFF8EF; }
table.grid td.actions-cell { white-space: nowrap; text-align: end; }
table.compact td, table.compact th { padding: 6px 10px; }
table.grid input[type=text], table.grid input[type=time], table.grid input[type=number], table.grid select {
  height: 32px;
  font-size: 13.5px;
  min-width: 0;
}

/* Forms ------------------------------------------------------------------- */

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px 18px;
}
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.req { color: var(--signal-text); font-weight: 600; }
.hint { color: var(--steel); }

input[type=text], input[type=number], input[type=date], input[type=time], input[type=month],
input[type=tel], input[type=password], input[type=email], input[type=search], input[type=url],
select, textarea {
  height: 38px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  padding: 0 10px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: #fff;
  width: 100%;
  min-width: 0;
}
textarea { height: auto; padding: 8px 10px; line-height: 1.65; resize: vertical; }
input[type=number], input[type=tel], input[type=date], input[type=time], input[type=month] { font-variant-numeric: tabular-nums; }
input[type=tel] { direction: ltr; text-align: right; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input[type=file] { font: inherit; font-size: 13.5px; max-width: 100%; }

.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { margin-top: 5px; }
.check small { display: block; color: var(--steel); }
.check.wide, .check-row.wide { grid-column: 1 / -1; }
.check-row { display: flex; align-items: flex-start; gap: 6px; }
.check-row details.help { margin-top: 3px; }

/* The ? next to fields and buttons ------------------------------------------ */

.label-row { display: flex; align-items: center; gap: 6px; }
details.help { position: relative; display: inline-block; vertical-align: middle; font-size: 13.5px; }
details.help > summary {
  list-style: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid var(--rule-strong);
  background: #fff;
  color: var(--steel);
  font: 700 11.5px/17px var(--font);
  text-align: center;
  cursor: pointer;
  user-select: none;
}
details.help > summary::-webkit-details-marker { display: none; }
details.help > summary:hover { border-color: var(--ink-2); color: var(--ink); }
details.help[open] > summary { background: var(--ink); border-color: var(--ink); color: #fff; }
details.help .help-body {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: -10px;
  z-index: 40;
  width: min(300px, calc(100vw - 32px));
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 42, 74, .14);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.75;
  white-space: normal;
  text-align: start;
}
h2 details.help { margin-inline-start: 6px; }
.form-actions details.help { align-self: center; }
body.no-help details.help { display: none; }

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
form.inline { display: inline; }
.inline-fields { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields .field { min-width: 140px; }
.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filters .field { min-width: 150px; }
.filters input[type=search] { min-width: 230px; }

/* Buttons ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn:hover { border-color: var(--ink-2); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #18406B; border-color: #18406B; }
.btn-signal { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn-signal:hover { background: #CC6420; border-color: #CC6420; }
.btn-danger { color: var(--bad); border-color: #E3B3AE; }
.btn-danger:hover { border-color: var(--bad); }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-wa { color: #136F45; border-color: #A9D8BF; }
.btn[disabled] { opacity: .5; cursor: default; }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--focus);
  cursor: pointer;
  font: inherit;
  font-size: inherit;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }

/* Tags, flashes, empty states --------------------------------------------- */

.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.75;
  white-space: nowrap;
  vertical-align: baseline;
}
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--signal-soft); color: var(--signal-text); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-muted { background: #EBEFF3; color: var(--steel); }
.tag-ink { background: var(--ink); color: #fff; }

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid;
}
.flash-ok { background: var(--ok-soft); border-color: #B5DCC5; color: #1A5A39; }
.flash-bad { background: var(--bad-soft); border-color: #EBBDB8; color: #8A1C16; }
.flash-info { background: var(--info-soft); border-color: #C2D4EB; color: var(--info); }

.note {
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--sheet-2);
  border: 1px dashed var(--rule-strong);
  color: var(--ink-2);
  font-size: 14px;
}
.note.warn { background: #FFF8EF; border-color: #F2C79F; color: #7A3A0E; }
.note.demo { background: #FFF8EF; border: 1px solid #F2C79F; color: #7A3A0E; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--steel);
}
.empty p { margin-bottom: 12px; }

.period-nav {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.period-nav strong { min-width: 120px; text-align: center; font-weight: 600; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 14px; color: var(--steel); }

/* Key value lists ---------------------------------------------------------- */

dl.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px;
  margin: 0;
}
dl.kv dt { color: var(--steel); font-size: 13.5px; }
dl.kv dd { margin: 0; }

/* Today page --------------------------------------------------------------- */

.today-date {
  font-family: var(--display);
  font-size: 15px;
  color: var(--steel);
}
.branch-lines { margin: 0; padding: 0; list-style: none; }
.branch-lines li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--rule);
}
.branch-lines li:last-child { border-bottom: 0; }
.branch-lines b { font-weight: 600; }
.meter {
  height: 6px;
  border-radius: 3px;
  background: #E7EBEF;
  overflow: hidden;
  margin-top: 6px;
  display: flex;
}
.meter span { display: block; height: 100%; }
.meter .m-ok { background: #3E9A6A; }
.meter .m-late { background: var(--signal); }
.meter .m-abs { background: #D26A62; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
}
.todo li:last-child { border-bottom: 0; }
.todo .what { min-width: 0; }
.todo .when { color: var(--steel); font-size: 13px; white-space: nowrap; }
.todo li.hot .what::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  margin-inline-end: 8px;
  vertical-align: middle;
}

.figures {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--rule);
}
.figures > div {
  flex: 1 1 140px;
  padding: 12px 18px;
  border-inline-end: 1px solid var(--rule);
}
.figures > div:last-child { border-inline-end: 0; }
.figures b {
  display: block;
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.figures span { color: var(--steel); font-size: 13px; }

/* Time card: the month grid ------------------------------------------------ */

.timecard-wrap { overflow-x: auto; padding: 4px 0 8px; }
table.timecard {
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
table.timecard th {
  font-weight: 500;
  color: var(--steel);
  font-size: 10.5px;
  line-height: 1.25;
  padding: 2px 0 4px;
  min-width: 25px;
}
table.timecard th.we { color: var(--steel-2); }
table.timecard th.today-col { color: var(--signal-text); font-weight: 700; }
table.timecard .emp {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--sheet);
  text-align: start;
  min-width: 132px;
  max-width: 168px;
  padding: 3px 10px 3px 8px;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.timecard .emp small { color: var(--steel); display: block; font-size: 11px; }
table.timecard .branch-row td {
  padding: 12px 12px 4px;
  font-weight: 600;
  color: var(--ink-2);
  font-size: 12.5px;
  position: sticky;
  right: 0;
  background: var(--sheet);
}
table.timecard td.d {
  width: 25px;
  height: 28px;
  text-align: center;
  border-radius: 4px;
  color: #3D2A12;
  font-size: 10.5px;
  padding: 0;
}
table.timecard td.d a { color: inherit; display: block; line-height: 28px; text-decoration: none; }
table.timecard td.tot, table.timecard th.tot { padding: 0 6px; white-space: nowrap; font-size: 12px; color: var(--ink-2); text-align: center; }
table.timecard .tot.last { border-inline-end: 1px solid var(--rule); padding-inline-end: 10px; }
.d.ok { background: #D7EEDF; }
.d.cnt { background: #FFF0BF; }
.d.q { background: #FFD9AC; }
.d.h { background: #FDB777; }
.d.f { background: #EE874C; color: #fff !important; }
.d.abs { background: #EFB7B2; color: #6D1410 !important; font-weight: 600; }
.d.off { background: repeating-linear-gradient(135deg, #EEF1F4 0 3px, #E2E7EC 3px 6px); }
.d.hol { background: #D9E5F4; }
.d.lv { background: #E5DEF4; }
.d.unp { background: #E9D2CE; }
.d.one { box-shadow: inset 0 0 0 2px #C9852F; }
.d.noin { background: #FFF0BF; color: #8A5A12 !important; font-weight: 600; }
.d.nd, .d.fut, .d.out { background: #F4F6F8; color: #B3BDC8 !important; }
.d.pend { background: #EEF2F6; color: var(--steel) !important; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--steel); padding: 10px 18px 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* Day list on employee page */
.daylist td { white-space: nowrap; }

details.block > summary { cursor: pointer; list-style: none; }
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary::after { content: 'افتح'; font-size: 13px; color: var(--focus); }
details.block[open] > summary::after { content: 'اقفل'; }
details.block:not([open]) > summary { border-bottom: 0; }

/* Timeline (customer and project history) --------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding: 10px 18px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
}
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--steel); font-size: 12.5px; }
.timeline .body { white-space: pre-wrap; }
.timeline .by { color: var(--steel); font-size: 12.5px; }

/* Files -------------------------------------------------------------------- */

ul.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
ul.files li { display: flex; gap: 12px; align-items: center; }
ul.files .thumb { width: 72px; height: 54px; flex: none; border-radius: 4px; overflow: hidden; background: #E9EDF1; display: block; }
ul.files .thumb img, ul.files video.thumb { width: 72px; height: 54px; object-fit: cover; }
ul.files li > div { flex: 1; min-width: 0; display: grid; }
.upload-form { margin-top: 12px; }
.upload-form input[type=text] { max-width: 220px; }

/* Stage strip for projects -------------------------------------------------- */

.stages { display: flex; gap: 3px; flex-wrap: wrap; margin: 4px 0 14px; }
.stages span {
  flex: 1 1 90px;
  font-size: 12px;
  padding: 6px 8px;
  background: #E9EDF1;
  color: var(--steel);
  text-align: center;
  border-radius: 3px;
}
.stages span.done { background: #CFE3D6; color: #1D5B3B; }
/* only a few steps: one row, even on a phone */
.stages.few { flex-wrap: nowrap; }
.stages.few span { flex: 1 1 0; min-width: 0; padding-inline: 4px; }
.stages span.now { background: var(--ink); color: #fff; font-weight: 500; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(128px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.board-col { background: #E6EAEE; border-radius: 8px; padding: 8px; min-height: 120px; }
@media (max-width: 760px) {
  /* On a phone a long sideways board is useless: stack the stages, skip the empty ones. */
  .board { grid-auto-flow: row; grid-auto-columns: auto; overflow: visible; }
  .board-col { min-height: 0; }
  .board-col.empty { display: none; }
}
.board-col h3 { font-size: 13.5px; font-weight: 600; margin: 0 2px 8px; display: flex; justify-content: space-between; gap: 8px; }
.board-card .tag { white-space: normal; }
.board-card {
  display: block;
  background: var(--sheet);
  border-radius: 6px;
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none !important;
  font-size: 13.5px;
}
.board-card:hover { border-color: var(--rule-strong); }
.board-card small { display: block; color: var(--steel); }
.board-card.late { border-inline-start: 3px solid var(--signal); }

/* Payslip ------------------------------------------------------------------ */

.slip { max-width: 720px; }
.slip table.grid td:last-child, .slip table.grid th:last-child { text-align: left; }
.slip .net td { font-size: 17px; font-weight: 700; background: var(--sheet-2); }

/* Permission matrix ------------------------------------------------------- */

.matrix select { min-width: 120px; }

/* Bare pages (login, setup) ------------------------------------------------ */

body.bare {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 20px;
}
.bare-box {
  width: 100%;
  max-width: 420px;
  background: var(--sheet);
  border-radius: 10px;
  padding: 28px 28px 24px;
}
.bare-box.wide { max-width: 560px; }
.bare-brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  color: var(--ink);
  margin-bottom: 4px;
}
.bare-box h1 { font-size: 17px; font-weight: 600; margin-bottom: 18px; color: var(--steel); }
.bare-box .field { margin-bottom: 14px; }
.bare-box .btn-primary { width: 100%; height: 42px; font-size: 15px; }
.demo-logins { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 13.5px; color: var(--steel); }
.demo-logins p { margin: 0 0 10px; }
.demo-logins .btn { width: auto; height: auto; font-size: 13.5px; }

/* Phone check result on new customer form */
.phone-check { font-size: 13.5px; min-height: 20px; }
.phone-check.taken { color: var(--bad); font-weight: 500; }
.phone-check.free { color: var(--ok); }

/* Small screens ------------------------------------------------------------ */

@media (max-width: 1100px) {
  .cols-main { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .cols-3 { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed;
    inset: 0 0 0 auto;
    width: 260px;
    z-index: 20;
    transform: translateX(100%);
    transition: transform .2s ease;
  }
  .side.open { transform: none; box-shadow: -8px 0 30px rgba(0, 0, 0, .25); }
  .menu-btn {
    display: inline-flex;
    align-items: center;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--rule-strong);
    border-radius: 6px;
    background: var(--sheet);
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    order: -1;
  }
  .main { padding: 16px 16px 48px; }
  .top { align-items: center; }
  .top .titles { flex: 1 1 60%; }
  .top-end { display: contents; }
  .top .bell { order: 1; }
  .top .actions { order: 2; flex-basis: 100%; }
  .top h1 { font-size: 21px; }
  .cols { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .fields.two { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .branch-lines li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .filters input[type=search] { min-width: 0; }
  .figures > div { flex-basis: 45%; }
}

/* On a phone, lists marked .cards show each row as a small card: the first
   cell on its own line, the rest flowing after it with their column name. */
@media (max-width: 640px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tfoot { display: block; }
  table.cards tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
  table.cards tbody tr:last-child { border-bottom: 0; }
  table.cards tfoot tr { border-top: 1px solid var(--rule-strong); border-bottom: 0; background: var(--sheet-2); font-weight: 600; }
  table.cards td, table.cards tfoot td { display: block; padding: 0; border: 0; background: none !important; white-space: normal; }
  table.cards tbody td:first-child { flex-basis: 100%; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--steel); font-size: 12px; font-weight: 400; margin-inline-end: 5px; }
  table.cards tr.warn { background: #FFF8EF; }
  table.cards tr.sub-row { background: var(--sheet-2); padding: 7px 14px; font-size: 13px; }
  table.cards td.actions-cell { text-align: start; }
  /* A month of days: the day and its status on one line, the times under them. */
  table.daylist.cards tbody td:first-child { flex-basis: auto; font-weight: 500; }
  table.daylist.cards td.st { order: 1; margin-inline-start: auto; }
  table.daylist.cards tr::after { content: ''; order: 1; flex-basis: 100%; height: 0; }
  table.daylist.cards td:not(:first-child):not(.st) { order: 2; }
  /* Staff list: the name heads the card, the code sits with the rest. */
  #emp-table.cards tbody td:first-child { flex-basis: auto; order: 1; }
  #emp-table.cards tbody td:nth-child(2) { flex-basis: 100%; order: 0; }
  #emp-table.cards tbody td:nth-child(n+3) { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

@media print {
  body { background: #fff; font-size: 13px; }
  .side, .menu-btn, .actions, .no-print, .flash, form.inline, details.help, .bell { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .block { border: 0; }
  table.grid th { background: #fff; }
}

/* Arabic file picker over the native input --------------------------------- */

.file-pick { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; max-width: 100%; }
.file-pick input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-pick:focus-within .btn { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-pick .file-names { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-pick.has-files .file-names { color: var(--ink); }

.minus { color: var(--bad); }
.plus { color: var(--ok); }

/* Printed papers: receipts ---------------------------------------------------- */

body.paper { background: #E9EDF1; padding: 24px 16px; }
.paper-tools { max-width: 760px; margin: 0 auto 12px; display: flex; gap: 8px; }
.receipt {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 32px 36px;
}
.receipt header { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.receipt h1 { font-family: var(--display); font-size: 24px; }
.receipt h2 { font-size: 18px; }
.receipt .receipt-no { text-align: left; }
.receipt .receipt-no p { margin: 0; }
.receipt .kv { grid-template-columns: 150px 1fr; row-gap: 10px; }
.receipt .big { font-size: 20px; }
.receipt footer { display: flex; justify-content: space-between; gap: 40px; margin-top: 46px; }
.receipt footer div { flex: 1; }
.receipt .line { display: block; border-bottom: 1px solid var(--ink-2); height: 34px; }
@media print {
  body.paper { background: #fff; padding: 0; }
  .receipt { border: 0; padding: 0; }
}

pre.message {
  font-family: var(--font);
  white-space: pre-wrap;
  background: #E7F3E9;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0 16px;
  line-height: 1.7;
  font-size: 14.5px;
}

/* Notifications ---------------------------------------------------------- */

.notes-list { list-style: none; margin: 0; padding: 0; }
.notes-list li { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.notes-list li:last-child { border-bottom: 0; }
.notes-list li.new { background: var(--info-soft); }
.notes-list li.new a { font-weight: 600; }
.notes-list a { color: var(--ink); text-decoration: none; white-space: pre-line; line-height: 1.7; }
.notes-list a:hover { text-decoration: underline; }
.todo li.dim .what, .todo li.dim .when { color: var(--steel); }

/* Folded parts of a page ---------------------------------------------------- */

details.more > summary { cursor: pointer; color: var(--info); font-weight: 500; padding: 4px 0; }
details.more[open] > summary { margin-bottom: 10px; }
hr.rule { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }

/* Calendar ---------------------------------------------------------------- */

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 12px; }
.cal-head { text-align: center; font-size: 12px; color: var(--steel); padding-bottom: 2px; }
.cal-cell {
  min-height: 58px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
  padding: 5px 6px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.cal-cell.pad-cell { border-color: transparent; }
.cal-cell b { font-weight: 600; font-size: 14px; }
.cal-cell small { color: var(--steel); font-size: 11.5px; }
.cal-cell.busy { background: #F7F9FB; }
.cal-cell.today { border-color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--ink-2); }
.cal-cell.sel { background: var(--ink); border-color: var(--ink); color: #fff; }
.cal-cell.sel small { color: #C9D6E3; }
.cal-cell:hover:not(.sel):not(.pad-cell) { border-color: var(--rule-strong); }
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-info { background: var(--info); }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--signal); }
.dot-muted { background: var(--steel); }
.dot-bad { background: var(--bad); }
.cal-cell.sel .dot { box-shadow: 0 0 0 1.5px #fff; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0 14px 14px; font-size: 12.5px; color: var(--steel); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Company policies ---------------------------------------------------------- */

ul.policy { margin: 0; padding: 12px 18px 14px 18px; padding-inline-start: 34px; line-height: 1.9; }
ul.policy li { margin-bottom: 4px; }
@media print {
  .policies .block { break-inside: avoid; margin-bottom: 10px; }
}

details.inline-more { display: inline-block; margin-inline-start: 8px; }
details.inline-more > summary { display: inline; font-size: 13px; padding: 0; }
details.inline-more[open] > summary { margin: 0 0 0 6px; }
