:root {
  --red: #D81A21; --red-dark: #A8141A; --red-soft: #FDECEC;
  --amber: #E89A0C; --amber-soft: #FFF4DE;
  --green: #1E7F4F; --green-soft: #E4F4EA;
  --blue: #1F5FA8; --blue-soft: #E6EFFA;
  --ink: #1F1B1A; --ink-2: #4A4543; --muted: #7A7471;
  --line: #E7E2DE; --line-2: #F1EDEA;
  --bg: #F7F5F2; --card: #FFFFFF;
  --side: #221A18; --side-2: #2F2421; --side-ink: #EDE6E2;
  --radius: 10px; --shadow: 0 1px 2px rgba(30,20,15,.06), 0 2px 8px rgba(30,20,15,.04);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; } .right { text-align: right; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand .logo { display: flex; align-items: center; }
.brand .logo img { width: 190px; height: auto; display: block; }
.brand .word { font-weight: 800; letter-spacing: .08em; font-size: 15px; color: #fff; }
.brand .word span { display: block; font-size: 10px; letter-spacing: .18em; color: var(--amber); font-weight: 600; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); opacity: .82; font-weight: 500; }
.nav a:hover { background: var(--side-2); opacity: 1; }
.nav a.on { background: var(--red); opacity: 1; color: #fff; }
.nav .count { background: rgba(255,255,255,.16); border-radius: 20px; padding: 0 8px; font-size: 12px; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }
.side .me { margin-top: auto; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side .me b { display: block; color: #fff; }
.side .me button { background: none; border: 0; color: var(--amber); padding: 0; cursor: pointer; font-size: 12px; margin-right: 12px; }
.main { padding: 24px 28px 60px; min-width: 0; }
.topbar { display: none; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: block; }
.tile .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.tile .l { color: var(--muted); font-size: 12px; font-weight: 500; }
.tile.red .n { color: var(--red); } .tile.amber .n { color: var(--amber); } .tile.green .n { color: var(--green); } .tile.blue .n { color: var(--blue); }
a.tile:hover { border-color: var(--ink-2); }

/* buttons & inputs */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid rgba(216,26,33,.25); border-color: var(--red); }
textarea { width: 100%; min-height: 70px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
label.f input, label.f select, label.f textarea { font-weight: 400; font-size: 14px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; align-items: end; }
.form .wide { grid-column: 1 / -1; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #FBFAF8; position: sticky; top: 0; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #FBF8F6; }
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); max-height: 70vh; }

/* chips */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.s-open { background: #EFECE9; color: var(--ink-2); }
.s-client { background: var(--amber-soft); color: #8A5A00; }
.s-review { background: var(--blue-soft); color: var(--blue); }
.s-rework { background: var(--red-soft); color: var(--red); }
.s-done { background: var(--green-soft); color: var(--green); }
.s-pending { background: #EFECE9; color: var(--ink-2); }
.due { font-weight: 600; white-space: nowrap; }
.due.late { color: var(--red); } .due.soon { color: #A86A00; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #F1ECE8; color: var(--ink-2); margin-right: 4px; }
.tag.chk { background: var(--blue-soft); color: var(--blue); }
.code { font-weight: 700; font-size: 12px; background: #F3EFEC; padding: 1px 6px; border-radius: 4px; }
.prog { height: 6px; background: var(--line-2); border-radius: 6px; overflow: hidden; min-width: 60px; }
.prog > i { display: block; height: 100%; background: var(--green); border-radius: 6px; }

/* job list */
.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 4px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: #FBF8F6; }
.item .t { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.item .side-r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

/* checklist */
.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line-2); }
.step:last-child { border-bottom: 0; }
.step .box { width: 22px; height: 22px; border: 2px solid #C9C1BC; border-radius: 6px; display: grid; place-items: center; cursor: pointer; background: #fff; color: #fff; font-size: 14px; }
.step.done .box { background: var(--green); border-color: var(--green); }
.step.na .box { background: #BDB5B0; border-color: #BDB5B0; }
.step.locked .box { cursor: not-allowed; opacity: .55; }
.step.done .st, .step.na .st { color: var(--muted); }
.step.na .st { text-decoration: line-through; }
.step .by { font-size: 11px; color: var(--muted); }
.step input[type=text] { width: 180px; padding: 4px 8px; font-size: 13px; }
.step.chk { background: linear-gradient(90deg, var(--blue-soft), transparent 40%); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 13px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.events { font-size: 13px; }
.events .ev { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.events .ev:last-child { border-bottom: 0; }
.ev.return { color: var(--red); }

/* bars */
.bars .b { display: grid; grid-template-columns: 170px 1fr 90px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.bar { height: 12px; background: var(--line-2); border-radius: 6px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .d { background: var(--green); } .bar .r { background: var(--blue); } .bar .o { background: var(--red); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20,12,10,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(560px, 100%); max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .art { background: radial-gradient(circle at 20% 110%, #5a2a16 0, transparent 50%), radial-gradient(circle at 90% -10%, #7a2a18 0, transparent 45%), var(--side); color: #F3ECE8; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login .art h1 { font-size: 34px; color: #fff; line-height: 1.15; max-width: 480px; }
.login .art ul { padding-left: 18px; color: #E6DCD7; }
.login .art li { margin: 6px 0; }
.login .art li::marker { color: var(--amber); }
.login .panel { display: grid; place-items: center; padding: 24px; }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login .logo-card { display: inline-flex; align-self: flex-start; }
.login .logo-card img { width: 300px; max-width: 100%; height: auto; }
.err-msg { color: var(--red); font-size: 13px; min-height: 18px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px; gap: 2px; }
  .side .brand, .side .me, .nav .sep { display: none; }
  .nav { display: contents; }
  .nav a.mobile-only { display: flex !important; }
  .nav a { flex: none; padding: 8px 10px; font-size: 13px; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
  .topbar img { height: 26px; }
  .main { padding: 16px 16px 60px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login .art { padding: 28px; }
  .login .art h1 { font-size: 24px; }
  .bars .b { grid-template-columns: 110px 1fr 70px; }
  .step { grid-template-columns: 28px 1fr; }
  .step > :last-child { grid-column: 2; }
}

.svc select { width: 96px; padding: 4px 6px; font-size: 12px; }
#af select { max-width: 150px; }

.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 40px; }
.pw-wrap .eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; display: grid; place-items: center; border-radius: 6px; }
.pw-wrap .eye:hover { color: var(--ink); background: var(--line-2); }

.svc { flex-wrap: nowrap; }

/* charts */
.viz h2 { margin-bottom: 2px; }
.viz .legend { margin: 10px 0 6px; flex-wrap: wrap; }
.stk { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.stk-row { display: grid; gap: 10px; align-items: center; min-height: 30px; }
.stk-lab { border: 0; background: none; text-align: left; padding: 2px 0; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.stk-lab span { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.stk-lab:hover { color: var(--red); }
.stk-track { height: 18px; }
.stk-bar { display: flex; gap: 2px; height: 18px; min-width: 0; }
.stk-seg { border: 0; padding: 0; min-width: 3px; height: 100%; cursor: pointer; border-radius: 0; }
.stk-seg.end { border-radius: 0 4px 4px 0; }
.stk-seg:hover, .stk-seg:focus-visible { filter: brightness(1.12); outline: 2px solid var(--ink); outline-offset: 1px; }
.stk-val { text-align: right; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.stk-val .flag { display: block; font-size: 11px; color: var(--red); font-weight: 600; }
.cols { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 6px; height: 190px; margin-top: 12px; align-items: end; }
.col { border: 0; background: none; padding: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: pointer; gap: 3px; min-width: 0; }
.col-bar { width: min(24px, 70%); border-radius: 4px 4px 0 0; display: block; min-height: 0; }
.col:hover .col-bar, .col:focus-visible .col-bar { filter: brightness(1.12); outline: 2px solid var(--ink); outline-offset: 1px; }
.col-v { font-size: 12px; font-weight: 700; }
.col-l { font-size: 11px; color: var(--ink-2); text-align: center; line-height: 1.2; border-top: 1px solid #c3c2b7; width: 100%; padding-top: 4px; }
.col-l span { color: var(--muted); }
.viz-tip { position: fixed; z-index: 70; background: #fff; border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.15); border-radius: 8px; padding: 8px 10px; font-size: 12px; pointer-events: none; display: none; max-width: 260px; }
.viz-tip b { font-size: 15px; }
button.tile { text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.tile:hover { border-color: var(--ink-2); }
.drawer-bg { position: fixed; inset: 0; background: rgba(20,12,10,.35); z-index: 55; display: flex; justify-content: flex-end; }
.drawer { width: min(560px, 100%); height: 100%; background: #fff; box-shadow: -10px 0 40px rgba(0,0,0,.2); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.drawer-body { overflow: auto; flex: 1; }
.drawer-foot:empty { display: none; }
@media (max-width: 900px) { .cols { grid-template-columns: repeat(8, minmax(0, 1fr)); height: auto; } .col { height: 150px; } .stk-row { grid-template-columns: 110px 1fr 50px !important; } }

.grid > .card, .grid > div > .card:first-child, .grid > details.card { margin-top: 0; }
