:root {
  --navy: #1e3a5f; --navy-dark: #162c49; --red: #c0392b;
  --bg: #f2f4f7; --card: #ffffff; --line: #dde3ea; --muted: #6b7a8c;
  --green: #1e7e34; --grid: #e7ecf2;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
       background: var(--bg); color: #1c2733; }
header { background: var(--navy); color: #fff; padding: 14px 24px;
         display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
header h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
header nav { display: flex; gap: 4px; flex-wrap: wrap; }
header nav a { color: #cdd9e8; text-decoration: none; font-size: 15px;
               padding: 6px 12px; border-radius: 6px; }
header nav a.active, header nav a:hover { background: var(--navy-dark); color: #fff; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 14px; color: #cdd9e8; }
.user-box a { color: #cdd9e8; text-decoration: none; border: 1px solid #3a5170; padding: 5px 12px; border-radius: 6px; }
main { max-width: 1200px; margin: 24px auto; padding: 0 16px; }
main.wide { max-width: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        padding: 20px 24px; margin-bottom: 20px; }
h2 { margin: 0 0 14px; font-size: 17px; color: var(--navy); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { font-size: 16px; padding: 9px 10px; border: 1px solid #b8c2cd;
        border-radius: 7px; width: 100%; background: #fff; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy); border-color: var(--navy); }
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 720px) { .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
.btn { display: inline-block; background: var(--navy); color: #fff; border: none;
       font-size: 16px; font-weight: 600; padding: 11px 22px; border-radius: 8px;
       cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy-dark); }
.btn.secondary { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn.danger { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
.btn.small { font-size: 13px; padding: 6px 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: #f7f9fb; }
a { color: var(--navy); }
.ono { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--navy); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.pending     { background: #eef2f7; color: #50617a; }
.pill.scheduled   { background: #e4ecfa; color: #1c4fb0; }
.pill.in_progress { background: #fdf1dc; color: #9a6700; }
.pill.done        { background: #e2f3e6; color: var(--green); }
.pill.cancelled   { background: #f6e3e1; color: var(--red); }
.prio { font-weight: 700; }
.prio.urgent { color: var(--red); }
.prio.high   { color: #d9730d; }
.prio.normal { color: #50617a; }
.prio.low    { color: var(--muted); }
.overdue { color: var(--red); font-weight: 700; }
.error { background: #fdecea; border: 1px solid #f5c6c0; color: #92281c;
         padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.success { background: #e8f5ec; border: 1px solid #bfe3c8; color: #18602b;
           padding: 14px 18px; border-radius: 8px; margin-bottom: 20px; }
.muted { color: var(--muted); font-size: 13px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters > div { min-width: 130px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { margin-left: auto; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.stat { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,30,45,.55);
                 display: flex; align-items: center; justify-content: center;
                 padding: 16px; z-index: 100; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 480px;
         padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); max-height: 90vh; overflow:auto; }
.modal h3 { margin: 0 0 14px; color: var(--navy); font-size: 19px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.modal-actions .spacer { margin-left: auto; }

/* ---- Gantt ---- */
.gantt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.gantt { --label-w: 170px; position: relative; min-width: max-content; }
.lane-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.lane-row:last-child { border-bottom: none; }
.lane-label { width: var(--label-w); flex: 0 0 var(--label-w); position: sticky; left: 0; z-index: 3;
              background: #f7f9fb; border-right: 1px solid var(--line); padding: 10px 12px;
              display: flex; flex-direction: column; justify-content: center; }
.lane-label .m-name { font-weight: 700; font-size: 14px; }
.lane-label .m-stage { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.lane { position: relative; height: 54px; flex: 0 0 auto;
        background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px);
        background-size: var(--hour-px) 100%; }
.lane.axis { height: 30px; background: #f7f9fb; }
.axis-tick { position: absolute; top: 0; height: 100%; display: flex; align-items: center;
             font-size: 11px; color: var(--muted); padding-left: 5px; border-left: 1px solid var(--line); }
.lane-row.header .lane-label { background: #eef2f7; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--red); z-index: 4; pointer-events: none; }

.op-block { position: absolute; top: 6px; height: 42px; border-radius: 7px; overflow: hidden;
            color: #fff; font-size: 12px; padding: 4px 8px; cursor: grab; user-select: none;
            box-shadow: 0 1px 3px rgba(0,0,0,.25); border: 1px solid rgba(0,0,0,.12);
            line-height: 1.25; }
.op-block:active { cursor: grabbing; }
.op-block .op-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-block .op-sub { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-block.dragging { opacity: .8; z-index: 20; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.op-block.conflict { outline: 2px solid var(--red); outline-offset: 1px; }
.op-block.status-in_progress { box-shadow: 0 0 0 2px #fff inset, 0 1px 3px rgba(0,0,0,.25); }
.op-block.status-done { opacity: .55; }
.op-resize { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: ew-resize; }
.op-block .op-flag { position:absolute; top:3px; right:11px; font-size: 11px; }
.op-block .op-chg { position:absolute; top:4px; left:5px; font-size: 11px; }
.op-block.has-chg .op-title { padding-left: 15px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.unscheduled-list { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #eef2f7; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.chip .ono { font-size: 12px; }
