/* ═══════════════════════════════════════════════════════════════════════
   SALAM · EMPLOYEE FINANCE SCREEN
   ───────────────────────────────────────────────────────────────────────
   Used almost entirely on a phone, in a branch, often one-handed — so
   targets are generous and inputs sit at 16px, below which iOS zooms the
   whole page on focus.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --fe-bg:      #0B2620;
  --fe-surface: #10352C;
  --fe-raise:   #16453A;
  --fe-line:    #1C4A3E;
  --fe-accent:  #3DD68C;
  --fe-gold:    #E9B949;
  --fe-danger:  #EF4444;
  --fe-text:    #EAF2EE;
  --fe-soft:    #C8DDD5;
  --fe-muted:   #8FB3A8;
  --fe-faint:   #6F9A8E;
}

/* ─── Quick-action button on the home screen ────────────────────────── */

#openFinanceBtn { position: relative; }

/* unread notices — on the home button and on the tab */
.fe-badge {
  position: absolute;
  top: 4px;
  left: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--fe-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.fe-badge.in-tab {
  position: static;
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}

/* ─── Tabs ──────────────────────────────────────────────────────────── */

.fe-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.fe-tabs button {
  padding: 12px 8px;
  border-radius: 12px;
  border: 1px solid var(--fe-line);
  background: transparent;
  color: var(--fe-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.fe-tabs button.active {
  background: var(--fe-raise);
  border-color: var(--fe-accent);
  color: var(--fe-accent);
}

.fe-pane { display: none; }
.fe-pane.active { display: block; }

/* ─── Section headings ──────────────────────────────────────────────── */

.fe-sec {
  font-size: 13px;
  font-weight: 800;
  color: var(--fe-text);
  margin: 20px 0 9px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fe-sec::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--fe-accent);
}

.fe-hint {
  font-size: 12px;
  color: var(--fe-faint);
  line-height: 1.75;
  margin: 6px 0 0;
}

.fe-empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--fe-muted);
  font-size: 13.5px;
  line-height: 1.9;
}

.fe-locked {
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fe-line);
  color: var(--fe-muted);
  font-size: 12.5px;
  line-height: 1.8;
  text-align: center;
}

/* ─── Fields ────────────────────────────────────────────────────────── */

.fe-field { margin-bottom: 14px; }

.fe-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fe-soft);
  margin-bottom: 7px;
}

.fe-field input,
.fe-field select,
.fe-field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fe-line);
  color: var(--fe-text);
  font-family: inherit;
  font-size: 16px;          /* below 16px iOS zooms the page on focus */
  transition: border-color 0.18s ease;
}

.fe-field input:focus,
.fe-field select:focus,
.fe-field textarea:focus {
  outline: none;
  border-color: var(--fe-accent);
}

.fe-field input::placeholder { color: var(--fe-faint); }

.fe-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── File pickers ──────────────────────────────────────────────────── */

.fe-file {
  display: block;
  padding: 18px 14px;
  border-radius: 13px;
  border: 2px dashed var(--fe-line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--fe-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.fe-file:hover { border-color: var(--fe-accent); color: var(--fe-soft); }
.fe-file input[type="file"] { display: none; }

.fe-file.has-file {
  border-style: solid;
  border-color: var(--fe-accent);
  color: var(--fe-accent);
  background: rgba(61, 214, 140, 0.07);
}

.fe-thumb { margin-top: 10px; }
.fe-thumb img { max-width: 100%; border-radius: 10px; display: block; }

/* ─── Receipt list ──────────────────────────────────────────────────── */
/* A day's card sales are rarely one slip, so the field holds a list the
   employee can add to and prune before sending. */

.fe-rcpt-list { margin-top: 10px; }

.fe-rcpt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 7px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fe-line);
}

.fe-rcpt-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 8px;
  overflow: hidden;
  background: var(--fe-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fe-rcpt-thumb img { width: 100%; height: 100%; object-fit: cover; }

.fe-rcpt-pdf {
  font-size: 10px;
  font-weight: 800;
  color: var(--fe-accent);
  letter-spacing: 0.5px;
}

.fe-rcpt-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--fe-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
}

.fe-rcpt-x {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: transparent;
  color: #FCA5A5;
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

/* ─── Live calculation strip ────────────────────────────────────────── */

.fe-calc {
  padding: 14px 16px;
  border-radius: 13px;
  background: var(--fe-surface);
  border: 1px solid var(--fe-line);
  margin: 16px 0;
}

.fe-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  color: var(--fe-muted);
}

.fe-calc-row b {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--fe-text);
  direction: ltr;
}

.fe-calc-row.total {
  border-top: 1px solid var(--fe-line);
  margin-top: 6px;
  padding-top: 11px;
}

.fe-calc-row.total b { font-size: 17px; }

.fe-ok   { color: var(--fe-accent) !important; }
.fe-bad  { color: var(--fe-danger) !important; }
.fe-warn { color: var(--fe-gold) !important; }

/* ─── Verdicts ──────────────────────────────────────────────────────── */

.fe-verdict {
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.75;
  text-align: center;
  margin-top: 10px;
}

.fe-verdict.good {
  background: rgba(61, 214, 140, 0.13);
  border: 1px solid rgba(61, 214, 140, 0.35);
  color: var(--fe-accent);
}

.fe-verdict.warn {
  background: rgba(233, 185, 73, 0.13);
  border: 1px solid rgba(233, 185, 73, 0.35);
  color: var(--fe-gold);
}

.fe-verdict.bad {
  background: rgba(239, 68, 68, 0.13);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
}

/* ─── Buttons ───────────────────────────────────────────────────────── */

.fe-btn {
  width: 100%;
  padding: 15px;
  border-radius: 13px;
  border: none;
  background: linear-gradient(135deg, var(--fe-accent), #2E9E78);
  color: #05221B;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.18s ease;
}

.fe-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.fe-btn.ghost {
  background: transparent;
  border: 1px solid var(--fe-line);
  color: var(--fe-muted);
}

.fe-btn.ghost:hover { color: var(--fe-soft); border-color: var(--fe-accent); }

/* ─── Message bar ───────────────────────────────────────────────────── */
/* Errors and confirmations land here rather than in a toast, which fires
   behind the open sheet where nobody sees it. */

.fe-errbar {
  display: none;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.7;
  text-align: center;
}

.fe-errbar.show { display: block; }

.fe-errbar.ok {
  background: rgba(61, 214, 140, 0.14);
  border-color: rgba(61, 214, 140, 0.45);
  color: var(--fe-accent);
  padding: 16px 14px;
  font-size: 14px;
}

/* ─── History rows ──────────────────────────────────────────────────── */

.fe-row {
  padding: 14px;
  border-radius: 13px;
  background: var(--fe-surface);
  border: 1px solid var(--fe-line);
  margin-bottom: 11px;
}

.fe-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.fe-row-date { font-size: 13.5px; font-weight: 700; color: var(--fe-text); }

.fe-row-nums { display: flex; flex-wrap: wrap; gap: 6px; }

.fe-chip {
  padding: 4px 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fe-soft);
  font-size: 11.5px;
  font-weight: 600;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  direction: ltr;
}

.fe-chip.ok   { background: rgba(61, 214, 140, 0.15); color: var(--fe-accent); }
.fe-chip.bad  { background: rgba(239, 68, 68, 0.15);  color: #FCA5A5; }
.fe-chip.gold { background: rgba(233, 185, 73, 0.15); color: var(--fe-gold); }

.fe-state {
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fe-muted);
}

.fe-state.open     { background: rgba(61, 214, 140, 0.15); color: var(--fe-accent); }
.fe-state.unlocked { background: rgba(233, 185, 73, 0.15); color: var(--fe-gold); }
.fe-state.locked   { background: rgba(255, 255, 255, 0.06); color: var(--fe-faint); }
.fe-state.sealed   { background: rgba(239, 68, 68, 0.12);  color: #FCA5A5; }

/* ─── Replying to a ruling ──────────────────────────────────────────── */
/* The employee could be told a shortfall was kept on him and had no way
   to answer except a phone call, which leaves no trace. */

/* ─── سجلّي · a day opens to show what he typed ──────────────────────── */
/* The head is a button so it is reachable by keyboard and reads as
   tappable; the detail is hidden, not removed, so nothing reflows. */

.fe-day { padding: 0; overflow: hidden; }

.fe-day-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 15px;
  background: transparent;
  border: 0;
  color: inherit;
  font-family: inherit;
  text-align: right;
  cursor: pointer;
}

.fe-day-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-inline-start: auto;
}

.fe-day-caret {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-bottom: 4px;
  border-right: 2px solid var(--fe-muted);
  border-bottom: 2px solid var(--fe-muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.fe-day-head.open .fe-day-caret { transform: rotate(-135deg); }
.fe-day-head.open { background: rgba(255, 255, 255, 0.03); }

.fe-day-body {
  padding: 4px 15px 14px;
  border-top: 1px solid var(--fe-line);
}

.fe-day-body .fe-calc-row:first-child { border-top: 0; }


/* ─── مراسلاتي · the thread list ─────────────────────────────────────── */

.fe-thread {
  display: block;
  width: 100%;
  text-align: right;
  font-family: inherit;
  cursor: pointer;
  color: inherit;
}

.fe-thread.unseen { border-color: var(--fe-gold); }

.fe-thread-last {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--fe-soft);
  overflow-wrap: anywhere;
}

.fe-thread-last b { color: var(--fe-muted); font-weight: 700; }

.fe-thread-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.fe-thread-bar .fe-btn { width: auto; padding: 9px 16px; font-size: 13px; }


/* ─── مراسلاتي · the conversation ────────────────────────────────────── */
/* His own messages sit on the right of an RTL column, the supervisor's
   on the left, so a long thread is readable at a glance. */

.fe-thread-note {
  margin-bottom: 12px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--fe-line);
  border-inline-start: 3px solid var(--fe-gold);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  line-height: 1.85;
  color: var(--fe-soft);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.fe-thread-note b { color: var(--fe-muted); font-weight: 700; }

.fe-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 4px 2px;
  -webkit-overflow-scrolling: touch;
}

.fe-bubble {
  max-width: 85%;
  padding: 11px 13px;
  border-radius: 14px;
  border: 1px solid var(--fe-line);
}

.fe-bubble.mine {
  align-self: flex-end;
  background: var(--fe-raise);
  border-color: rgba(61, 214, 140, 0.35);
}

.fe-bubble.theirs {
  align-self: flex-start;
  background: var(--fe-surface);
}

.fe-bubble-who {
  margin-bottom: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--fe-accent);
}

.fe-bubble-body {
  font-size: 14px;
  line-height: 1.85;
  color: var(--fe-text);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.fe-bubble-file {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--fe-accent);
  background: rgba(61, 214, 140, 0.1);
  color: var(--fe-accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

/* Full-screen so a screenshot of his sales is actually readable on a
   phone, and a tap anywhere closes it. */
.fe-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  overflow: auto;
}

.fe-lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
}

.fe-bubble-time {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--fe-faint);
}

.fe-compose { margin-top: 14px; }

.fe-compose textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 70px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fe-line);
  color: var(--fe-text);
  font-family: inherit;
  font-size: 16px;          /* 16px or iOS zooms the whole sheet */
  line-height: 1.75;
  resize: vertical;
}

.fe-compose textarea:focus { outline: none; border-color: var(--fe-accent); }
.fe-compose textarea::placeholder { color: var(--fe-faint); }
.fe-attach-pick {
  display: block;
  margin-top: 9px;
  padding: 11px 12px;
  border-radius: 11px;
  border: 1px dashed var(--fe-line);
  color: var(--fe-muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.fe-attach-pick:active { border-color: var(--fe-accent); color: var(--fe-soft); }
.fe-attach-pick input { display: none; }

.fe-attach-name {
  margin-top: 6px;
  font-size: 12px;
  color: var(--fe-accent);
  overflow-wrap: anywhere;
}

.fe-compose .fe-btn { margin-top: 9px; }

/* ─── Supervisor notices ─────────────────────────────────────────────── */
/* The body is shown whole, line breaks kept, never truncated. */

.fe-notice.unseen { border-color: var(--fe-gold); }

.fe-notice-body {
  font-size: 14px;
  color: var(--fe-text);
  line-height: 1.9;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* ─── Deposit cards ─────────────────────────────────────────────────── */

.fe-dep {
  padding: 16px;
  border-radius: 14px;
  background: var(--fe-surface);
  border: 1px solid var(--fe-line);
  margin-bottom: 13px;
}

.fe-dep.due { border-color: var(--fe-gold); }

.fe-dep-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--fe-soft);
  margin-bottom: 7px;
  direction: ltr;
  text-align: right;
}

.fe-dep-amount {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 30px;
  font-weight: 800;
  color: var(--fe-accent);
  direction: ltr;
  text-align: right;
  margin-bottom: 4px;
}

.fe-dep-label {
  font-size: 12px;
  color: var(--fe-faint);
  line-height: 1.7;
  margin-bottom: 11px;
}

/* ─── Accidental dismissal ──────────────────────────────────────────── */
/* Tapping the backdrop used to close the sheet and lose everything typed,
   so it now nudges and the X button does the closing. */

@keyframes feNudge {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

.fe-nudge { animation: feNudge 0.22s ease; }

/* ─── Phones ────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .fe-two { grid-template-columns: 1fr; gap: 0; }

  .fe-calc-row { font-size: 12.5px; }
  .fe-calc-row b { font-size: 13.5px; }
  .fe-calc-row.total b { font-size: 16px; }

  .fe-tabs { gap: 3px; }
  .fe-tabs button { padding: 11px 2px; font-size: 10.5px; letter-spacing: -0.2px; }

  .fe-day-head { padding: 13px 12px; gap: 7px; }
  .fe-day-body { padding: 4px 12px 13px; }

  .fe-chat { max-height: 38vh; }
  .fe-bubble { max-width: 92%; padding: 10px 12px; }
  .fe-bubble-body { font-size: 13.5px; }

  .fe-btn { padding: 15px; font-size: 15px; }
  .fe-file { padding: 17px 12px; }

  .fe-dep-amount { font-size: 26px; }
  .fe-row-nums { gap: 5px; }
  .fe-chip { font-size: 11px; padding: 3px 7px; }

  .fe-sec { margin: 16px 0 9px; }
}
