/* IRIS ERP — back-office styles. Brand: Iris Cyan #16B8C6 on a light,
   document-like surface; the public site keeps the dark cinematic look. */

:root {
  --iris: #16B8C6;
  --iris-deep: #0A7C8A;
  --ink: #0C1116;
  --slate: #243039;
  --steel: #6B7A88;
  --mist: #9AA7B2;
  --line: #E3E8EC;
  --bg: #F6F8F9;
  --panel: #FFFFFF;
  --green: #1F9D63;
  --amber: #B8791F;
  --coral: #D2574B;
  --blue: #2B6CB0;
  --purple: #6B4FBB;
  --teal: #128C8C;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--iris-deep); }

/* ---------- brand ---------- */
.brand span {
  display: inline-block;
  border: 2px solid currentColor;
  border-radius: 5px;
  padding: 4px 12px;
  font-weight: 600;
  letter-spacing: .3em;
  text-indent: .3em;
  font-size: 14px;
}
.brand { text-decoration: none; color: var(--ink); }
.brand-lg span { font-size: 18px; padding: 6px 16px; }

/* ---------- app chrome ---------- */
.appbar {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.appnav { display: flex; gap: 20px; flex: 1; }
.appnav a {
  color: var(--steel);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}
.appnav a:hover { color: var(--ink); border-bottom-color: var(--iris); }

.appuser { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.who em { color: var(--mist); font-style: normal; font-size: 11px; }
.ghost {
  color: var(--steel);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
}
.ghost:hover { border-color: var(--iris); color: var(--ink); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }

.appfoot {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 40px;
  color: var(--mist);
  font-size: 12px;
}

h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 38px 0 12px; }
.muted { color: var(--steel); }
.fineprint { color: var(--mist); font-size: 12px; }

/* ---------- priority banner ---------- */
.priority {
  margin: 24px 0 8px;
  background: linear-gradient(180deg, #FFF9F1, #FFFFFF);
  border: 1px solid #F2D9B8;
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  padding: 18px 20px;
}
.priority-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--amber);
  font-weight: 600;
}
.priority h2 { margin: 6px 0 4px; font-size: 18px; }
.priority p { margin: 0; color: var(--steel); }

/* ---------- stat cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin: 24px 0 8px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--iris);
  border-radius: 12px;
  padding: 16px 18px;
}
/* Long money values ("320 142,000 TND") used to wrap onto a second line,
   which made neighbouring cards different heights. Keep them on one line. */
.card-n {
  font-size: 20px;
  font-weight: 600;
  color: var(--iris-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.card-l {
  font-size: 11px;
  color: var(--steel);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 2px;
}
.card-green  { border-top-color: var(--green);  } .card-green  .card-n { color: var(--green); }
.card-amber  { border-top-color: var(--amber);  } .card-amber  .card-n { color: var(--amber); }
.card-coral  { border-top-color: var(--coral);  } .card-coral  .card-n { color: var(--coral); }
.card-blue   { border-top-color: var(--blue);   } .card-blue   .card-n { color: var(--blue); }
.card-purple { border-top-color: var(--purple); } .card-purple .card-n { color: var(--purple); }
.card-teal   { border-top-color: var(--teal);   } .card-teal   .card-n { color: var(--teal); }

/* ---------- tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.table th {
  color: var(--steel);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: #FAFCFC;
}
.table tr:last-child td { border-bottom: none; }

/* Amounts must be right-aligned to be comparable at a glance. `.num` alone
   lost to `.table td` on specificity, so every figure in the app rendered
   left-aligned; qualify the selector so it wins. */
.num,
.table th.num,
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: #EAF7F8;
  color: var(--iris-deep);
}
.pill-green  { background: #E7F5ED; color: var(--green); }
.pill-amber  { background: #FCF3E4; color: var(--amber); }
.pill-coral  { background: #FBECEA; color: var(--coral); }
.pill-blue   { background: #E8F0FA; color: var(--blue); }
.pill-steel  { background: #EEF1F3; color: var(--steel); }

/* ---------- bars ---------- */
.bars { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.bar-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.bar-label { width: 160px; font-size: 13px; color: var(--steel); }
.bar-track { flex: 1; height: 8px; background: #EDF1F3; border-radius: 999px; overflow: hidden; }
.bar-inline { display: inline-block; width: 120px; vertical-align: middle; }
.bar-fill { display: block; height: 100%; background: var(--iris); border-radius: 999px; }
.bar-n { width: 28px; text-align: right; font-size: 13px; color: var(--steel); }

/* ---------- forms ---------- */
label { display: block; margin: 0 0 14px; }
label > span { display: block; font-size: 13px; color: var(--steel); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}
input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px rgba(22, 184, 198, .18);
}
.btn {
  display: inline-block;
  background: var(--iris);
  color: #06343A;
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { opacity: .9; }
.form-narrow { max-width: 380px; margin-top: 20px; }

/* ---------- flash ---------- */
.flash {
  border-radius: 8px;
  padding: 11px 14px;
  margin: 0 0 16px;
  font-size: 14px;
  border: 1px solid;
}
.flash-error   { background: #FBECEA; border-color: #F0C8C3; color: #8E332A; }
.flash-success { background: #E7F5ED; border-color: #BFE3CE; color: #14663F; }

/* ---------- login ---------- */
.login-body {
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border-radius: 16px;
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.login-card h1 { font-size: 20px; margin: 22px 0 2px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-card .fineprint { margin-top: 18px; text-align: center; }

@media (max-width: 640px) {
  .appbar { gap: 14px; padding: 0 14px; }
  .appnav { gap: 12px; }
  .who { display: none; }
  .wrap { padding: 22px 14px 48px; }
  .bar-label { width: 110px; }
}

/* ---------- hardening-related UI ---------- */
.notice {
  background: #FFF8E8;
  border: 1px solid #F0DFBC;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  color: #7A5A17;
  margin: 18px 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.total-row td { background: #FAFCFC; border-top: 2px solid var(--line); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--steel); }
.btn-danger { background: var(--coral); color: #fff; }
.inline-actions { display: flex; gap: 6px; }
.ghost-warn { border-color: #E7C07A; color: #97701F; background: #FFF7E9; }

.code-input {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 20px;
  letter-spacing: .35em;
  text-align: center;
}
.secret {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 16px;
  background: #F3F6F7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 4px;
  word-break: break-all;
  user-select: all;
}
.steps { padding-left: 18px; max-width: 560px; }
.steps li { margin-bottom: 22px; }
.form-inline { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.form-inline label { margin: 0; }
.codes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.codes code {
  background: #F3F6F7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 15px;
  letter-spacing: .12em;
  text-align: center;
  user-select: all;
}

/* ---------- kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
.kcol { background: #EFF3F5; border-radius: 12px; padding: 10px; }
.kcol-head {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 8px 10px; display: flex; justify-content: space-between; color: var(--steel);
}
.kcol-todo  { border-bottom: 2px solid var(--steel); }
.kcol-doing { border-bottom: 2px solid var(--blue); color: var(--blue); }
.kcol-done  { border-bottom: 2px solid var(--green); color: var(--green); }
.kcount { background: #fff; border-radius: 999px; padding: 0 7px; }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; margin-top: 9px;
}
.kcard-top { display: flex; gap: 7px; align-items: flex-start; }
.ktitle { font-size: 14px; line-height: 1.35; }
.prio { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; }
.prio-high { background: var(--coral); }
.prio-medium { background: var(--amber); }
.prio-low { background: var(--mist); }
.kmeta { display: flex; gap: 10px; margin-top: 7px; font-size: 11px; color: var(--mist); }
.ksubs { list-style: none; padding: 0; margin: 9px 0 2px; }
.ksubs li { margin: 2px 0; }
.ksub-form { display: inline; }
.ksub-toggle {
  background: none; border: none; padding: 0; cursor: pointer; font-size: 12.5px;
  color: var(--steel); text-align: left;
}
.ksub-toggle.is-done, .is-done { text-decoration: line-through; color: var(--mist); }
.kactions { display: flex; gap: 5px; align-items: center; margin-top: 9px; flex-wrap: wrap; }
.kactions form { display: inline; }
.kbtn {
  background: #F2F5F7; border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 8px; cursor: pointer; font-size: 13px; color: var(--steel);
}
.kbtn:hover { border-color: var(--iris); color: var(--ink); }
.kbtn-del:hover { border-color: var(--coral); color: var(--coral); }
.kadd { margin-top: 11px; padding-top: 10px; border-top: 1px dashed #D6DEE2; }
.kadd-row { display: flex; gap: 6px; margin: 6px 0; }
.kinput {
  width: 100%; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px;
}
.kselect { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; background: #fff; }
.ksub-add { flex: 1; min-width: 90px; }

/* ---------- project cards ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 20px; }
.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px 16px; text-decoration: none; color: var(--ink); display: block;
}
.pcard:hover { border-color: var(--iris); }
.pcard-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pcard-meta { display: flex; gap: 10px; font-size: 12px; color: var(--mist); margin: 9px 0; }
.pcard-progress { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.pill-purple { background: #EFEAFB; color: var(--purple); }
.progress-wide { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; max-width: 520px; }

/* ---------- shared form bits ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px;
  font-size: 13px; text-decoration: none; color: var(--steel); background: #fff;
}
.chip.is-on { border-color: var(--iris); color: var(--iris-deep); background: #EAF7F8; }
.chip-n { color: var(--mist); font-size: 11px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.row-actions form { display: inline; }
select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; background: #fff; width: 100%; }
.num-input { text-align: right; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.table input[type=text] { padding: 6px 9px; font-size: 13px; }

@media (max-width: 760px) {
  .kanban { grid-template-columns: 1fr; }
}

/* ---------- navigation ---------- */
/* 11 modules do not fit on one line. On wide screens the bar wraps to two
   rows; on phones it becomes a single swipeable strip so the sticky header
   stays ~60px instead of eating a quarter of the screen (it reached 215px). */
.appbar { height: auto; min-height: 60px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.appnav { flex-wrap: wrap; gap: 4px 16px; }
.appnav a { white-space: nowrap; }
.appuser { flex: none; }

@media (max-width: 1180px) {
  .appnav { gap: 4px 12px; }
  .appnav a { font-size: 13px; }
}

@media (max-width: 860px) {
  .appbar {
    flex-wrap: nowrap;
    gap: 12px;
    padding: 0 14px;
    height: 56px;
    min-height: 56px;
  }
  .appnav {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 16px;
    /* hide the scrollbar but keep the swipe */
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .appnav::-webkit-scrollbar { display: none; }
  .appnav a { font-size: 13.5px; padding: 4px 0; }
  .brand span { padding: 3px 9px; font-size: 12px; letter-spacing: .22em; }
  .appuser { gap: 8px; }
  .ghost { padding: 4px 8px; font-size: 12px; }
}

/* ---------- wide tables ---------- */
/* An amount must never break across two lines. */
.num, .table td.num, .table th.num { white-space: nowrap; }

/* The payroll table has 8 columns and needs ~790px. Below that it used to
   push the whole PAGE into horizontal scroll and get clipped at the edge;
   now the table itself scrolls. min-width keeps narrow tables full-width. */
@media (max-width: 1000px) {
  .table {
    display: block;
    overflow-x: auto;
    min-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .table th, .table td { white-space: nowrap; }
  /* The description column may wrap: it is the one that can be long. */
  .lines-table td:first-child, .lines-table th:first-child { white-space: normal; }
}

@media (max-width: 760px) {
  .wrap { padding: 20px 14px 48px; }
}

/* ---------- totals table ---------- */
/* Row labels were rendered with the column-header style (tiny uppercase),
   which read as a header rather than a label. */
.table th[scope="row"], .totals-table th {
  text-transform: none;
  font-size: 14px;
  letter-spacing: 0;
  color: var(--ink);
  font-weight: 400;
  background: transparent;
}
.totals-table th { width: 55%; }

/* ---------- invoice line editor ---------- */
/* The description needs the room; quantity and price do not. */
.lines-table th:first-child, .lines-table td:first-child { width: 46%; }
.lines-table th:nth-child(2), .lines-table td:nth-child(2) { width: 14%; }
.lines-table th:nth-child(3), .lines-table td:nth-child(3) { width: 22%; }
.lines-table th:nth-child(4), .lines-table td:nth-child(4) { width: 18%; }
.lines-table input { width: 100%; }

/* ---------- kanban: collapse the forms ---------- */
/* The add-task form sat permanently open in all three columns and the
   subtask field stretched across every card, so the board read as a stack
   of forms rather than tasks. Both are now opt-in, using <details> so it
   still works with JavaScript disabled. */
.kadd { margin-top: 11px; padding-top: 10px; border-top: 1px dashed #D6DEE2; }
.kadd > summary {
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--steel);
  padding: 5px 8px;
  border: 1px dashed #C8D3D8;
  border-radius: 7px;
  text-align: center;
}
.kadd > summary::-webkit-details-marker { display: none; }
.kadd > summary:hover { border-color: var(--iris); color: var(--iris-deep); }
.kadd[open] > summary { margin-bottom: 9px; border-style: solid; }
.kadd form > * { margin-top: 6px; }

.ksub-add { flex: none; min-width: 0; }
.ksub-add > summary {
  list-style: none;
  cursor: pointer;
  background: #F2F5F7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 9px;
  font-size: 13px;
  color: var(--steel);
  line-height: 1.5;
}
.ksub-add > summary::-webkit-details-marker { display: none; }
.ksub-add > summary:hover { border-color: var(--iris); color: var(--ink); }
.ksub-add[open] { flex: 1 1 100%; margin-top: 6px; }
.ksub-add[open] > summary { display: none; }

/* A soft fade at the end of the scrollable nav hints that more modules
   are reachable by swiping — otherwise the strip looks truncated. */
@media (max-width: 860px) {
  .appnav {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
}

/* ---------- task management ---------- */
.row-late td { background: #FFF7F6; }
.late { color: var(--coral); font-weight: 500; }
.soon { color: var(--amber); }

.kedit > summary,
.ksub-del {
  list-style: none;
  cursor: pointer;
  background: #F2F5F7;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--steel);
  line-height: 1.6;
}
.kedit > summary::-webkit-details-marker { display: none; }
.kedit > summary:hover { border-color: var(--iris); color: var(--ink); }
.kedit[open] { flex: 1 1 100%; margin-top: 6px; }
.kedit[open] > summary { display: none; }
.kedit form > * { margin-top: 6px; }

.ksub-del { padding: 0 6px; border: none; background: none; color: var(--mist); }
.ksub-del:hover { color: var(--coral); }
.ksubs li { display: flex; align-items: baseline; gap: 4px; }

/* Counter cards hold short numbers, not money: they can be narrower, so five
   of them fit on one row instead of leaving a lone card on a second line. */
.cards-compact { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

/* A status pill must never break across two lines ("En cours"). */
.pill { white-space: nowrap; }
