
/* ── base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}
h1 { margin: 0 0 20px; color: #2c3e50; font-size: 1.7rem; }
h2 { margin: 0 0 12px; color: #2c3e50; font-size: 1.25rem; }
h3 { margin: 0 0 10px; color: #2c3e50; }
p  { margin: 0 0 10px; }
a  { color: #2c7be5; }

.muted { color: #6c757d; }
.small { font-size: .85rem; }
.center { text-align: center; }
.section { margin-top: 24px; }
.mt-2 { margin-top: 12px; }
.mt-4 { margin-top: 24px; }

.arabic-text, [dir="rtl"] { direction: rtl; text-align: right; }

/* ── layout ───────────────────────────────────────────────────────────── */
.container {
  max-width: 520px;
  margin: 50px auto;
  padding: 30px;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,.06);
  text-align: center;
}
.container-wide { max-width: 1100px; }
.card {
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  padding: 20px;
  margin-top: 20px;
  text-align: left;
}
.card.empty { text-align: center; color: #6c757d; }
.card.danger-zone { border-color: #f1aeb5; background: #fff5f5; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row form, .actions form { margin: 0; }

/* ── alerts ───────────────────────────────────────────────────────────── */
.alert { padding: 10px 12px; border-radius: 6px; margin: 0 0 18px; text-align: left; }
.alert.error   { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; }
.alert.success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }

/* ── forms ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 15px; text-align: left; }
label { display: block; margin-bottom: 5px; font-weight: 600; font-size: .92rem; }
.req { color: #dc3545; }

input, select, textarea {
  width: 100%;
  padding: 10px;
  font: inherit;
  color: #222;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec5fe; border-color: #6ea8fe; }
textarea { resize: vertical; }

input.locked, input[readonly], select[disabled] { background: #f4f6f8; color: #6b7280; cursor: not-allowed; }
.hint { font-size: .8rem; color: #6c757d; margin-top: 4px; }
.lock-note { font-size: .75rem; color: #b0771f; margin-top: 4px; }

.fieldset { border: 1px solid #e3e8ef; border-radius: 8px; padding: 14px 16px 4px; margin: 0 0 20px; }
.fieldset legend { padding: 0 8px; font-weight: 700; font-size: .95rem; color: #2c3e50; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-bar input, .filter-bar select { flex: 1 1 200px; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 11px 18px;
  border: none;
  border-radius: 6px;
  background: #3498db;
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #2980b9; }
.btn-primary { background: #28a745; }
.btn-primary:hover { background: #1e7e34; }
.btn-ghost { background: #eef2f7; color: #2c3e50; }
.btn-ghost:hover { background: #dde5ee; }
.btn-muted { background: #6c757d; }
.btn-muted:hover { background: #5c636a; }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #b02a37; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

/* ── tables ───────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e3e8ef; border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f5; text-align: left; font-size: .95rem; }
.data-table th { background: #f8f9fa; text-transform: uppercase; font-size: .75rem; letter-spacing: .04em; color: #6c757d; }
.data-table tbody tr:hover td { background: #f8fafc; }
.emp-link { color: #2c3e50; text-decoration: none; }
.emp-link:hover { color: #3498db; }

/* ── badges ───────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-neutral { background: #eef2f7; color: #475569; }
.badge-warn    { background: #fff3cd; color: #856404; }
.badge-danger  { background: #f8d7da; color: #842029; }

/* ── companies ────────────────────────────────────────────────────────── */
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; margin: 20px 0; }
.company-card {
  display: block;
  padding: 16px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: box-shadow .2s ease, transform .2s ease;
}
.company-card:hover { box-shadow: 0 5px 15px rgba(0,0,0,.1); transform: translateY(-3px); }
.company-code {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #f8f9fa;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .85em;
  color: #6c757d;
}

/* ── files ────────────────────────────────────────────────────────────── */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; }
.file-card { padding: 12px; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
.file-name { margin-bottom: 4px; font-weight: 700; word-break: break-word; }

/* ── notes ────────────────────────────────────────────────────────────── */
.notes { display: grid; gap: 12px; margin-top: 18px; }
.note-card {
  padding: 12px 14px;
  border: 1px solid #e3e8ef;
  border-left: 4px solid #cbd5e1;
  border-radius: 6px;
  background: #fcfdfe;
}
.note-card form { margin-top: 8px; }
.note-body { margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.inline-edit { margin-top: 8px; }
.inline-edit summary { cursor: pointer; color: #3498db; font-size: .9rem; }

.money { font-variant-numeric: tabular-nums; }



/* ── brand / settlement ───────────────────────────────────────────────── */
.is-hidden { display: none !important; }
.btn-brand { background: #FF5900; color: #fff; font-weight: 600; }
.btn-brand:hover { background: #d94c00; }
.btn-upload { background: #00AA11; }
.btn-upload:hover { background: #00CC11; }
.btn-calc { background: #2c3e50; }
.btn-calc:hover { background: #1b2733; }
.btn-xlsx { background: #1d7a46; } .btn-xlsx:hover { background: #146035; }
.btn-csv  { background: #7a5a1d; } .btn-csv:hover  { background: #5f4615; }
.btn-sm { padding: 6px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* ── fluid page: follows the window, small gutter only ────────────────── */
.container-full {
  max-width: none;
  width: calc(100% - 24px);
  margin: 20px auto;
  padding: 20px 24px;
}
/* ultrawide sanity: keep one huge screen of columns readable (raise/delete freely) */
/*@media (min-width: 2400px) { .container-full { width: 2400px; } }*/

.settlement-bar { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; }
.upload-box { flex: 1 1 420px; min-width: 320px; }
.calc-box { flex: 0 1 260px; min-width: 220px; }

.dropzone {
  padding: 18px; margin-bottom: 12px; text-align: center;
  border: 2px dashed #c6d2e0; border-radius: 10px; background: #fbfdff;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.drag { border-color: #FF5900; background: #fff4ec; }
.dz-title { margin-bottom: 2px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: .85rem; color: #475569; text-align: left; }
.file-list:empty { display: none; }

/* ── settlement tables ────────────────────────────────────────────────── */
.table-card { padding-bottom: 14px; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }

/* scroll inside the card so the header can stick (see note below) */
.table-card .table-wrap { max-height: 72vh; overflow: auto; border: 0; border-radius: 0; }

.settlement-table { width: 100%; min-width: 1750px; border-collapse: collapse; font-size: .88rem; }
.settlement-table th,
.settlement-table td { border: 1px solid #d7dee8; white-space: nowrap; padding: 7px 9px; }
.settlement-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #f1f4f8;
  /* collapsed borders don't travel with a sticky cell — inset shadows do */
  box-shadow: inset 0 -1px 0 #c3cfdd, inset -1px 0 0 #c3cfdd;
}
.settlement-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* the long Reason column is the one place wrapping is worth it */
#mgmt-decision td:first-child,
#mgmt-decision th:first-child { white-space: normal; min-width: 280px; max-width: 460px; }

.settlement-table tbody tr:nth-child(even) > td { background: #fbfcfe; }
.settlement-table tbody tr:hover > td { background: #f2f7fd; }
/* must follow the zebra/hover rules at equal specificity, or half the flags vanish */
.settlement-table tbody tr.row-alert > td,
.settlement-table tbody tr.row-alert:hover > td { background: #fff0e0; }

.settlement-table td.cell-input { padding: 2px 3px; }
.settlement-table input.amount {
  width: 118px; padding: 5px 7px; text-align: right;
  font: inherit; font-variant-numeric: tabular-nums;
  border: 1px solid #cbd5e1; border-radius: 4px; background: #fffdfb;
}
.settlement-table .cell-missing { border-color: #FF5900; background: #fff1e6; }
.settlement-table .net-company-cell { background: #f6fafd; }
.empty-row { padding: 12px 14px; margin: 0; }

/* Courier settlement brand button: top half #FFE41F, bottom half #11CC9A.
   `.btn.btn-settlement:hover` (0,2,0) beats `.btn:hover` (0,1,1). */
.btn-settlement {
  background: linear-gradient(180deg, #FFE41F 0 50%, #11CC9A 50% 100%);
  color: #17222b;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, .08);
}
.btn.btn-settlement:hover { background: linear-gradient(180deg, #ffe94f 0 50%, #22d9a8 50% 100%); }

/* per-row "move to Mgmt. Decision" action */
.settlement-table th.col-action,
.settlement-table td.col-action { text-align: center; width: 1%; white-space: nowrap; }
.btn-move { background: #8a94a6; padding: 5px 9px; line-height: 1.1; }
.btn-move:hover { background: #6b7280; }
.alert.warn { background: #fff3cd; border: 1px solid #ffe08a; color: #7a5c04; }
.alert.info { background: #e8f1ff; border: 1px solid #bfd9fe; color: #0d3b7a; }
