/* Employee portal — same tokens as the prototype (dist/style.css).
   Fonts are system fonts: the portal's content security policy allows no external hosts. */
:root {
  --ink: #16302b;
  --ink-2: #465c56;
  --muted: #6f817a;
  --paper: #f3f5f1;
  --card: #ffffff;
  --line: #dde4df;
  --pine: #0f6b5c;
  --pine-soft: #e3f1ed;
  --deep: #12332d;
  --brass: #a8672b;
  --brass-soft: #f6ecdf;
  --serious: #ec835a;
  --critical: #b3372f;
  --r: 6px;
  --r-lg: 10px;
  --bar: 60px;
}

* { box-sizing: border-box; }
html { font-size: 15px; overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1rem/1.6 "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 1.25rem; font-weight: 700; margin: 0; }
h2 { font-size: 1.6rem; font-weight: 700; line-height: 1.3; margin: 0 0 14px; }
h3 { font-size: 1.07rem; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
[hidden] { display: none !important; }

button { cursor: pointer; border: 1px solid transparent; border-radius: var(--r); padding: 8px 16px; background: var(--pine); color: #fff; font-weight: 500; }
button:hover { background: #0c5a4d; }
button.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
button.secondary:hover { background: var(--paper); }
input, select, textarea { width: 100%; border: 1px solid #cdd7d1; border-radius: var(--r); background: var(--card); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pine); outline-offset: 0; border-color: var(--pine); }
textarea { min-height: 88px; resize: vertical; }
label { display: grid; gap: 5px; margin-bottom: 14px; font-size: .87rem; font-weight: 500; color: var(--ink-2); }
label input, label select, label textarea { font-weight: 400; color: var(--ink); }

header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: var(--bar); padding: 0 28px; background: var(--card); border-bottom: 1px solid var(--line); }
#identity { margin-left: auto; color: var(--muted); font-size: .87rem; }
#menu-toggle { display: none; padding: 4px 11px; font-size: 1.1rem; }
#logout { padding: 5px 12px; font-size: .87rem; white-space: nowrap; flex-shrink: 0; }
header h1 { white-space: nowrap; }

#login { max-width: 420px; margin: 9vh auto; background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--deep); border-radius: var(--r-lg); padding: 28px; }
#login p { color: var(--muted); }
#login button { width: 100%; margin-top: 4px; }

#workspace { display: flex; align-items: flex-start; }
aside { position: sticky; top: var(--bar); flex-shrink: 0; width: 256px; height: calc(100vh - var(--bar)); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2f564d transparent; background: var(--deep); color: #c9d8d2; padding: 14px 12px 24px; }
aside section { margin-bottom: 12px; }
aside h3 { margin: 0; padding: 6px 10px 2px; font-size: .78rem; font-weight: 500; color: #8fa9a0; }
aside button { display: block; width: 100%; text-align: right; background: transparent; border: 0; color: #dbe6e2; font-weight: 400; font-size: .9rem; padding: 6px 10px; }
aside button:hover { background: #1b443c; }
aside button:focus-visible { outline-color: #6fc3b3; }
aside button.active { background: #1f4d44; color: #fff; font-weight: 600; box-shadow: inset -3px 0 0 #e0b98a; }
#nav-backdrop { display: none; }
main { flex: 1; min-width: 0; max-width: 1200px; padding: 26px 28px 48px; }

.panel, article { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; margin: 0 0 14px; }
article h3 { margin-bottom: 12px; }
.note { background: var(--brass-soft); border: 1px solid #ead8bf; color: #6b4318; padding: 10px 14px; border-radius: var(--r); font-size: .87rem; margin-bottom: 14px; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tools input { flex: 1; min-width: 180px; max-width: 380px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; margin: 0 0 12px; }
.fields dt { font-size: .8rem; color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.meta { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; padding: 1px 10px; border-radius: 12px; background: #e9eeea; color: var(--ink-2); font-size: .8rem; font-weight: 500; }
.badge.pending, .badge.returned { background: var(--brass-soft); color: #7a4a17; }
.badge.approved { background: var(--pine-soft); color: #0b5547; }
.badge.rejected { background: #fbeceb; color: var(--critical); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
article .actions { justify-content: flex-start; }
article .actions button { padding: 5px 12px; font-size: .87rem; }
.small { font-size: .8rem; color: var(--muted); }
.panel.narrow { max-width: 460px; }
#temp-password { font-size: 1.1rem; font-weight: 600; letter-spacing: .5px; }

table { width: 100%; text-align: right; border-collapse: collapse; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); background: #f7f9f6; }
td, th { padding: 10px 12px; border-bottom: 1px solid #e9eeea; }
td p { margin: 0; }
td button { padding: 5px 12px; font-size: .87rem; }

dialog { border: 0; border-radius: 12px; width: 560px; max-width: 94vw; max-height: 90vh; overflow: auto; padding: 24px; color: var(--ink); box-shadow: 0 24px 80px rgba(18, 51, 45, .28); }
dialog::backdrop { background: rgba(18, 51, 45, .45); }
dialog h2 { font-size: 1.25rem; }
dialog .actions { margin-top: 18px; }
dialog article { padding: 12px 14px; margin-bottom: 8px; }
.error { background: #fbeceb; border: 1px solid #efc9c6; color: var(--critical); padding: 8px 12px; border-radius: var(--r); font-size: .9rem; }

#message { position: fixed; bottom: 18px; left: 22px; z-index: 60; margin: 0; background: var(--deep); color: #fff; padding: 12px 18px; border-radius: var(--r); }
#message:empty { display: none; }

/* Dashboard: the line of work orders */
.line { background: var(--deep); border-radius: var(--r-lg); padding: 6px; margin-bottom: 20px; }
.line ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; counter-reset: step; }
.line li { counter-increment: step; background: #1b443c; padding: 14px 14px 12px; min-width: 0; }
.line li:first-child { border-radius: 0 6px 6px 0; }
.line li:last-child { border-radius: 6px 0 0 6px; }
.line-step { display: block; width: 100%; text-align: right; background: none; border: 0; padding: 0; color: #fff; }
.line-step:hover { background: none; text-decoration: underline; }
.line-step:focus-visible { outline-color: #e0b98a; }
.line-step strong { display: block; font-size: 2.2rem; font-weight: 700; line-height: 1.1; }
.line-step span { display: block; font-size: .87rem; font-weight: 400; color: #c9d8d2; }
.line-step span::before { content: counter(step) ". "; color: #e0b98a; }
.line li.idle .line-step strong { color: #6f8f86; }
.line-jobs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; min-height: 26px; }
.chip { background: #2a5a50; color: #e7efec; border: 0; border-radius: 4px; padding: 1px 8px; font-size: .78rem; font-weight: 500; direction: ltr; }
button.chip:hover { background: #356b60; }
.chip.more { background: none; color: #a9beb7; }

/* Dashboard: figures and charts */
.figures { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 20px; overflow: hidden; }
.figures button { text-align: right; background: none; color: var(--ink); border: 0; border-radius: 0; border-left: 1px solid var(--line); padding: 14px 18px; }
.figures button:last-child { border-left: 0; }
.figures button:hover { background: var(--paper); }
.figures span { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); }
.figures strong { display: block; font-size: 1.45rem; font-weight: 700; }
.charts { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
.charts .panel { margin: 0 0 20px; min-width: 0; }
.chart h2 { margin-bottom: 0; }
.chart > .muted { margin-bottom: 16px; }
.cols { display: flex; align-items: flex-end; }
.col { flex: 1; min-width: 0; text-align: center; border-radius: 4px; }
.col-plot { height: 190px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border-bottom: 1px solid #c3cec8; }
.col-value { font-size: .82rem; font-weight: 600; color: var(--ink); line-height: 26px; }
.col-bar { width: min(100%, 24px); background: var(--pine); border-radius: 4px 4px 0 0; }
.col:hover .col-bar, .col:focus-visible .col-bar { background: #0a4f44; }
.col-label { display: block; font-size: .8rem; color: var(--muted); padding: 6px 2px 0; }
.hbar, .bullet { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 12px; padding: 5px 4px; border-radius: 4px; font-size: .9rem; }
.bullet { grid-template-columns: minmax(120px, 200px) 1fr minmax(120px, auto); }
.hbar-track, .bullet-track { position: relative; height: 14px; }
.hbar-fill, .bullet-fill { position: absolute; inset: 0 0 0 auto; background: var(--pine); border-radius: 4px 0 0 4px; }
.hbar:hover .hbar-fill, .hbar:focus-visible .hbar-fill, .bullet:hover .bullet-fill { background: #0a4f44; }
.hbar-value { font-weight: 600; min-width: 2ch; text-align: left; }
.bullet-label, .hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bullet.low .bullet-fill, .bullet.low:hover .bullet-fill { background: var(--serious); }
.bullet-min { position: absolute; top: -4px; bottom: -4px; right: 50%; width: 2px; background: var(--ink); }
.bullet-value { font-weight: 500; }
.flag { display: inline-block; margin-inline: 8px; color: var(--critical); font-size: .8rem; font-weight: 600; }
.chart-key { display: flex; align-items: center; gap: 8px; margin: 12px 4px 0; font-size: .8rem; color: var(--muted); }
.key-tick { width: 2px; height: 14px; background: var(--ink); }
.chart-table { margin-top: 14px; font-size: .87rem; }
.chart-table summary { cursor: pointer; color: var(--pine); width: fit-content; }
.chart-table table { margin-top: 8px; }
.attention { display: flex; flex-direction: column; }
.attention button { text-align: right; background: none; color: var(--ink); font-weight: 400; border: 0; border-bottom: 1px solid #e9eeea; border-radius: 0; padding: 10px 4px; }
.attention button:last-child { border-bottom: 0; }
.attention button:hover { background: var(--paper); }
.attention b { display: block; font-size: .8rem; font-weight: 600; color: var(--brass); margin: 0; }
.attention b.flag { color: var(--critical); }
.attention small { display: block; color: var(--muted); }
/* Portal-only dashboard details */
.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.heading h2 { margin: 0; }
.heading p { margin: 0; }
.muted { color: var(--muted); font-size: .87rem; }
.chart h3 { margin-bottom: 0; }
.charts .panel:last-child:nth-child(odd) { grid-column: 1 / -1; }
.figures button:disabled { opacity: 1; cursor: default; }
.figures button:disabled:hover { background: none; }
.code { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 4px; background: var(--pine-soft); color: #0b5547; font-size: .8rem; font-weight: 600; direction: ltr; vertical-align: 2px; }
#tip { position: fixed; z-index: 70; max-width: 280px; background: var(--deep); color: #fff; font-size: .85rem; padding: 6px 10px; border-radius: var(--r); pointer-events: none; }
@media (max-width: 1100px) {
  .line ol { grid-template-columns: repeat(3, 1fr); }
  .line li:first-child, .line li:last-child { border-radius: 0; }
  .figures { grid-template-columns: repeat(3, 1fr); }
  .figures button { border-bottom: 1px solid var(--line); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .line ol, .figures { grid-template-columns: repeat(2, 1fr); }
  .hbar { grid-template-columns: 90px 1fr auto; }
  .cols { gap: 6px; }
}

@media (max-width: 800px) {
  #menu-toggle { display: block; }
  header { padding: 0 14px; gap: 10px; }
  #identity { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  aside { position: fixed; top: var(--bar); right: 0; z-index: 30; transform: translateX(100%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .nav-open aside { transform: none; visibility: visible; }
  .nav-open #nav-backdrop { display: block; position: fixed; inset: var(--bar) 0 0 0; z-index: 25; background: rgba(18, 51, 45, .45); }
  main { padding: 18px 14px 40px; }
  h2 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  aside { transition: none; }
}
