:root {
  --bg: #f4f6fa; --panel: #fff; --text: #1b2433; --muted: #637087; --line: #dde3ee; --primary: #2563eb; --primary-d: #1d4ed8;
  --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --chip: #eef2f9; --grid: #e8edf5; --hatch: #c7cfdd;
  --p-low: #64748b; --p-med: #2563eb; --p-high: #d97706; --p-crit: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1623; --panel: #18212f; --text: #e6ebf4; --muted: #93a0b6; --line: #2a3548; --chip: #223048; --grid: #212c3f; --hatch: #3a4760; --primary: #4f8cff; --primary-d: #6aa0ff; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 14px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .right { text-align: right; } .nowrap { white-space: nowrap; }

/* Layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 14px; display: flex; gap: 8px; align-items: center; }
.brand i { width: 24px; height: 24px; background: var(--primary); border-radius: 6px; display: inline-block; }
.side nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.side nav a:hover { background: var(--chip); text-decoration: none; }
.side nav a.active { background: var(--primary); color: #fff; }
.side .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: relative; }
.content { padding: 22px; min-width: 0; }
.bell { position: relative; cursor: pointer; background: none; border: 0; font-size: 18px; color: var(--text); }
.bell b { position: absolute; top: -6px; right: -8px; background: var(--bad); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 5px; }
.notif { position: absolute; right: 16px; top: 46px; width: min(380px, 94vw); max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0003; z-index: 40; }
.notif div { padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; } .notif div.unread { background: var(--chip); } .notif small { color: var(--muted); display: block; }

/* Components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } .g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat { cursor: pointer; } .stat:hover { border-color: var(--primary); }
.stat .n { font-size: 28px; font-weight: 700; } .stat.bad .n { color: var(--bad); } .stat.warn .n { color: var(--warn); }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-block; }
button:hover:not(:disabled), .btn:hover { border-color: var(--primary); text-decoration: none; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } button.primary:hover { background: var(--primary-d); }
button.danger { color: var(--bad); border-color: var(--bad); } button.sm { padding: 3px 8px; font-size: 12px; }
button.on { background: var(--primary); color: #fff; border-color: var(--primary); } button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; }
textarea { min-height: 90px; resize: vertical; } input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; } label.chk { display: flex; gap: 6px; align-items: center; font-weight: 400; color: var(--text); } label.chk input { width: auto; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; } .form .full { grid-column: 1 / -1; } .req::after { content: " *"; color: var(--bad); }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; } .bar .sp { flex: 1; }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; } th.sort { cursor: pointer; } tr.click { cursor: pointer; } tr.click:hover td { background: var(--chip); }
.tw { overflow-x: auto; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 12px; background: var(--chip); white-space: nowrap; }
.s-Submitted { background: #e0e7ff; color: #3730a3; } .s-Triage { background: #fef3c7; color: #92400e; } .s-Pending { background: #ffedd5; color: #9a3412; }
.s-Approved { background: #dcfce7; color: #166534; } .s-Scheduled { background: #cffafe; color: #155e75; } .s-In { background: #dbeafe; color: #1e40af; }
.s-On { background: #f3f4f6; color: #374151; } .s-Completed { background: #bbf7d0; color: #14532d; } .s-Closed { background: #e5e7eb; color: #374151; }
.s-Rejected, .s-Cancelled { background: #fee2e2; color: #991b1b; }
.p-Low { color: var(--p-low); } .p-Medium { color: var(--p-med); } .p-High { color: var(--p-high); font-weight: 600; } .p-Critical { color: var(--p-crit); font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 18px; } .kv dt { font-size: 12px; color: var(--muted); } .kv dd { margin: 0; }
.tl { list-style: none; padding: 0; margin: 0; } .tl li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.cmt { padding: 8px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; } .cmt small { color: var(--muted); display: block; }
.hbar { display: flex; align-items: center; gap: 8px; margin: 5px 0; } .hbar .l { width: 120px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .t { flex: 1; background: var(--chip); border-radius: 6px; height: 14px; overflow: hidden; } .hbar .t i { display: block; height: 100%; background: var(--primary); }
.hbar .v { width: 70px; font-size: 12px; color: var(--muted); text-align: right; }
.err { color: var(--bad); margin-top: 8px; } .warnbox { background: #fef3c7; color: #92400e; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }

/* Modal / toasts / login */
.overlay { position: fixed; inset: 0; background: #0008; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; overflow: auto; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(640px, 100%); box-shadow: 0 20px 60px #0006; } .modal.wide { width: min(860px, 100%); }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
#toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px #0005; max-width: 380px; } .toast.bad { background: var(--bad); }
.login { max-width: 360px; margin: 12vh auto; }

/* Gantt */
.gwrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); max-height: 74vh; }
.ginner { position: relative; min-width: max-content; }
.grow { display: flex; border-bottom: 1px solid var(--line); }
.gname { position: sticky; left: 0; z-index: 5; width: 230px; flex: none; background: var(--panel); border-right: 1px solid var(--line); padding: 6px 10px; font-size: 13px; overflow: hidden; }
.gname small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gtrack { position: relative; flex: none; }
.ghead { position: sticky; top: 0; z-index: 8; background: var(--panel); } .ghead .gname { z-index: 9; font-weight: 600; }
.gcell { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--grid); font-size: 11px; color: var(--muted); padding: 5px 4px; overflow: hidden; white-space: nowrap; }
.gcell.we { background: var(--grid); }
.gbar { position: absolute; height: 20px; border-radius: 5px; color: #fff; font-size: 11px; padding: 2px 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; background: var(--p-med); z-index: 2; min-width: 4px; }
.gbar:hover { text-decoration: none; filter: brightness(1.12); outline: 2px solid var(--text); }
.gbar.p-Low { background: var(--p-low); } .gbar.p-Medium { background: var(--p-med); } .gbar.p-High { background: var(--p-high); } .gbar.p-Critical { background: var(--p-crit); }
.gbar.done { opacity: .55; }
.gunav { position: absolute; top: 0; bottom: 0; z-index: 1; background: repeating-linear-gradient(45deg, var(--hatch) 0 4px, transparent 4px 9px); border-left: 1px solid var(--hatch); border-right: 1px solid var(--hatch); opacity: .8; }
.gcap { position: absolute; height: 17px; bottom: 1px; font-size: 10px; text-align: center; line-height: 17px; border-radius: 3px; overflow: hidden; color: #fff; }
.u-zero { background: var(--chip); color: var(--muted); } .u-ok { background: #16a34a; } .u-warn { background: #d97706; } .u-over { background: #dc2626; } .u-low { background: #65a30d; }
.gtoday { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 4; pointer-events: none; opacity: .7; }
.gdue { position: absolute; width: 12px; height: 12px; transform: rotate(45deg); background: var(--bad); z-index: 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin: 8px 0; } .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; } .side .sec { display: none; } .content { padding: 14px; } .gname { width: 150px; }
}
