:root {
  --ink: #102a43;
  --ink-2: #243b53;
  --muted: #627d98;
  --paper: #f5f7fa;
  --white: #fff;
  --line: #d9e2ec;
  --line-dark: #bcccdc;
  --teal: #087f8c;
  --teal-dark: #05606a;
  --teal-pale: #e5f4f5;
  --yellow: #f4b942;
  --yellow-pale: #fff6dd;
  --red: #b42318;
  --red-pale: #fff0ee;
  --green: #087a55;
  --green-pale: #e7f6ef;
  --blue: #1769aa;
  --shadow: 0 14px 38px rgba(16, 42, 67, .11);
  font-family: Inter, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--paper); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.auth-screen { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; background: #fff; }
.auth-panel { padding: clamp(28px, 6vw, 88px); display: flex; flex-direction: column; justify-content: center; }
.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; text-decoration: none; }
.brand img { border-radius: 50%; object-fit: cover; }
.brand span { display: grid; gap: 1px; }
.brand strong { font-family: "Libre Franklin", Arial, sans-serif; font-size: 17px; }
.brand small { color: var(--muted); font-size: 11px; }
.auth-panel .brand { margin-bottom: clamp(54px, 9vh, 96px); }
.eyebrow { margin: 0 0 9px; color: var(--teal); font-size: 11px; font-weight: 800; }
.auth-panel h1 { max-width: 650px; margin: 0 0 18px; font-family: "Libre Franklin", Arial, sans-serif; font-size: clamp(42px, 5vw, 68px); line-height: 1.02; }
.auth-copy { max-width: 580px; margin: 0 0 34px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.button-google { width: min(100%, 310px); min-height: 52px; padding: 0 18px; border: 1px solid var(--line-dark); border-radius: 6px; background: #fff; display: flex; align-items: center; justify-content: center; gap: 11px; cursor: pointer; font-weight: 700; box-shadow: 0 3px 10px rgba(16,42,67,.06); }
.button-google svg { width: 21px; height: 21px; stroke: none; }
.auth-note { max-width: 370px; margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-visual { padding: 8vw 6vw; display: grid; place-items: center; background: var(--ink); overflow: hidden; position: relative; }
.auth-visual::after { content: "PE"; position: absolute; right: -10px; bottom: -40px; color: rgba(244,185,66,.07); font: 800 340px/1 "Libre Franklin"; }
.schedule-card { width: min(720px, 100%); padding: 28px; border: 1px solid rgba(255,255,255,.15); background: #fff; box-shadow: 0 28px 70px rgba(0,0,0,.3); position: relative; z-index: 1; }
.schedule-card > div:first-child { display: grid; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.schedule-card span { color: var(--teal); font-size: 11px; font-weight: 800; }
.schedule-card b { font-size: 23px; }
.demo-row { min-height: 54px; display: grid; grid-template-columns: 28% 1fr; align-items: center; border-bottom: 1px solid #edf2f7; position: relative; }
.demo-row i { width: 70%; height: 8px; background: #d9e2ec; }
.demo-row span { width: var(--width); height: 18px; margin-left: var(--start); background: var(--teal); border-radius: 2px; }
.demo-row span.accent { background: var(--yellow); }

.app-shell { min-height: 100vh; }
.topbar { height: 68px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand-area, .top-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; cursor: pointer; }
.icon-button:hover { background: #edf2f7; }
.icon-button svg { width: 21px; height: 21px; }
.icon-button.small { width: 34px; height: 34px; font-size: 24px; }
.mobile-menu { display: none; }
.save-status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.save-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.save-status.saving i { background: var(--yellow); }
.save-status.error i { background: var(--red); }
.user-button { min-height: 42px; padding: 4px 9px 4px 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; font-weight: 700; }
.user-button img { width: 32px; height: 32px; border-radius: 50%; background: #d9e2ec; object-fit: cover; }

.layout { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { min-height: calc(100vh - 68px); padding: 18px 12px 14px; display: flex; flex-direction: column; background: #0e263d; color: #fff; position: sticky; top: 68px; height: calc(100vh - 68px); }
.sidebar-head { min-height: 40px; padding: 0 6px 8px 12px; display: flex; align-items: center; justify-content: space-between; color: #bcccdc; font-size: 10px; font-weight: 800; }
.sidebar .icon-button:hover { background: rgba(255,255,255,.1); }
.project-list { display: grid; gap: 5px; overflow-y: auto; }
.project-item { width: 100%; min-height: 50px; padding: 9px 10px; border: 0; border-left: 3px solid transparent; border-radius: 4px; background: transparent; color: #d9e2ec; display: grid; grid-template-columns: 27px minmax(0,1fr); align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.project-item:hover { background: rgba(255,255,255,.07); }
.project-item.active { border-left-color: var(--yellow); background: rgba(255,255,255,.11); color: #fff; }
.project-item i { width: 26px; height: 26px; border-radius: 5px; display: grid; place-items: center; background: rgba(8,127,140,.35); color: #8bd2d9; font-style: normal; font-size: 11px; font-weight: 800; }
.project-item[data-color="yellow"] i { background: rgba(244,185,66,.2); color: #ffd978; }
.project-item[data-color="blue"] i { background: rgba(23,105,170,.3); color: #8bc7f6; }
.project-item[data-color="red"] i { background: rgba(180,35,24,.3); color: #ffaca5; }
.project-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; }
.project-item small { display: block; margin-top: 3px; color: #9fb3c8; font-size: 10px; font-weight: 400; }
.sidebar-footer { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255,255,255,.12); display: grid; gap: 12px; }
.sidebar-footer a, .sidebar-footer button { padding: 0; border: 0; background: transparent; color: #bcccdc; text-align: left; text-decoration: none; cursor: pointer; font-size: 11px; }

.workspace { min-width: 0; }
.empty-project { min-height: calc(100vh - 68px); padding: 30px; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-mark { width: 68px; height: 68px; margin-bottom: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-pale); color: var(--teal); }
.empty-mark svg { width: 34px; height: 34px; }
.empty-project h2 { margin: 0 0 8px; font: 800 28px "Libre Franklin"; }
.empty-project p { margin: 0 0 24px; color: var(--muted); }
.project-view { padding-bottom: 50px; }
.project-header { padding: 28px clamp(18px, 3vw, 42px) 22px; display: flex; justify-content: space-between; gap: 28px; background: #fff; border-bottom: 1px solid var(--line); }
.breadcrumb { margin-bottom: 8px; color: var(--teal); font-size: 10px; font-weight: 800; }
.title-line { display: flex; align-items: center; gap: 8px; }
.title-line h1 { margin: 0; font: 800 clamp(27px, 3vw, 38px) "Libre Franklin"; }
.project-header p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.project-actions { display: flex; align-items: center; gap: 9px; }
.button { min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; font-weight: 700; text-decoration: none; }
.button svg { width: 17px; height: 17px; }
.button-primary { background: var(--teal); color: #fff; }
.button-primary:hover { background: var(--teal-dark); }
.button-secondary { border-color: var(--line-dark); background: #fff; }
.danger-link { color: var(--red); background: transparent; }

.stats { display: grid; grid-template-columns: 1.3fr repeat(3, 1fr); background: #fff; border-bottom: 1px solid var(--line); }
.stats > div { min-height: 105px; padding: 20px clamp(16px, 2.4vw, 34px); border-right: 1px solid var(--line); display: grid; align-content: center; }
.stats > div:last-child { border-right: 0; }
.stats span { color: var(--muted); font-size: 9px; font-weight: 800; }
.stats strong { margin-top: 7px; font-size: 25px; line-height: 1; }
.stats small { margin-top: 5px; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats i { width: 100%; height: 5px; margin-top: 11px; border-radius: 2px; background: #e6edf3; overflow: hidden; }
.stats i b { display: block; width: 0; height: 100%; background: var(--teal); transition: width .25s ease; }

.controls { padding: 16px clamp(18px, 3vw, 42px); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: #f9fbfc; }
.view-tabs, .zoom-control { display: inline-flex; padding: 3px; background: #e6edf3; border-radius: 6px; }
.view-tabs button, .zoom-control button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.view-tabs button.active, .zoom-control button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 5px rgba(16,42,67,.12); }
.search-box { width: min(340px, 34vw); margin-left: auto; position: relative; }
.search-box svg { position: absolute; left: 11px; top: 9px; width: 18px; height: 18px; color: var(--muted); }
.search-box input, .controls select { height: 38px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); outline: none; }
.search-box input { width: 100%; padding: 0 12px 0 36px; }
.controls select { padding: 0 30px 0 11px; font-size: 11px; }

.table-view, .gantt-view { padding: 22px clamp(18px, 3vw, 42px); }
.task-table-wrap, .gantt-scroll { border: 1px solid var(--line); background: #fff; overflow: hidden; }
.task-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.task-table th { height: 42px; padding: 0 13px; background: #edf2f7; color: var(--muted); text-align: left; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.task-table th:first-child { width: 32%; }
.task-table th:nth-child(2) { width: 15%; }
.task-table th:nth-child(3), .task-table th:nth-child(4) { width: 11%; }
.task-table th:nth-child(5) { width: 13%; }
.task-table th:nth-child(6) { width: 13%; }
.task-table th:last-child { width: 46px; }
.task-table td { height: 62px; padding: 9px 13px; border-top: 1px solid #edf2f7; color: var(--ink-2); font-size: 12px; vertical-align: middle; }
.task-table tbody tr { cursor: pointer; }
.task-table tbody tr:hover { background: #f8fbfc; }
.task-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.task-name i { width: 9px; height: 9px; border-radius: 2px; flex: none; background: var(--teal); }
.task-name i.milestone { transform: rotate(45deg); background: var(--yellow); }
.task-name div { min-width: 0; }
.task-name b, .task-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-name b { font-size: 12px; }
.task-name small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.progress-cell { display: flex; align-items: center; gap: 7px; }
.progress-cell i { width: 60px; height: 5px; background: #e6edf3; }
.progress-cell b { display: block; height: 100%; background: var(--teal); }
.progress-cell span { color: var(--muted); font-size: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 4px; background: #edf2f7; color: var(--muted); font-size: 9px; font-weight: 700; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.active { color: var(--teal-dark); background: var(--teal-pale); }
.status-pill.done { color: var(--green); background: var(--green-pale); }
.status-pill.blocked { color: var(--red); background: var(--red-pale); }
.row-menu { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; font-size: 18px; }
.row-menu:hover { background: #e6edf3; }
.no-tasks { padding: 55px 20px; text-align: center; color: var(--muted); }
.no-tasks button { border: 0; background: transparent; color: var(--teal); cursor: pointer; font-weight: 700; }

.gantt-scroll { min-height: 480px; overflow: auto; }
#gantt { min-width: 100%; }
.gantt .bar-progress { fill: var(--teal-dark); }
.gantt .bar { fill: #9bd2d6; }
.gantt .bar-wrapper.bar-milestone .bar { fill: var(--yellow); }
.gantt .bar-wrapper.bar-blocked .bar { fill: #efaaa4; }
.gantt .bar-wrapper.bar-done .bar { fill: #9cd7bf; }
.gantt .today-highlight { fill: rgba(244,185,66,.12); }
.gantt-container { overflow: visible; }

dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 28px 85px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(5,20,34,.72); }
.modal-form { max-height: calc(100dvh - 24px); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #fff; }
.modal-form header, .history-panel header { padding: 22px 24px 17px; display: flex; align-items: start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.modal-form h2, .history-panel h2 { margin: 0; font: 800 25px "Libre Franklin"; }
.fields { padding: 22px 24px; display: grid; gap: 15px; overflow-y: auto; }
.fields label { display: grid; gap: 7px; font-size: 12px; font-weight: 700; }
.fields input:not([type="checkbox"]):not([type="range"]), .fields select, .fields textarea { width: 100%; min-height: 44px; padding: 10px 11px; border: 1px solid var(--line-dark); border-radius: 6px; color: var(--ink); background: #fff; outline: none; }
.fields textarea { resize: vertical; }
.fields input:focus, .fields select:focus, .fields textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,127,140,.12); }
.fields select[multiple] { min-height: 90px; }
.fields small { margin-top: -10px; color: var(--muted); font-size: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.check-field { grid-template-columns: 18px 1fr !important; align-items: center; }
.check-field input { width: 17px; height: 17px; margin: 0; }
.modal-form footer { padding: 15px 24px 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; }
.side-dialog { width: min(440px, 100%); height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; border-radius: 0; }
.history-panel { min-height: 100%; background: #fff; }
.history-list { padding: 8px 24px 28px; }
.history-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.history-item b { display: block; margin-bottom: 4px; font-size: 12px; }
.history-item p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.history-item time { display: block; margin-top: 6px; color: #829ab1; font-size: 9px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: 360px; padding: 13px 16px; border-radius: 6px; background: #102a43; color: #fff; box-shadow: var(--shadow); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .layout { grid-template-columns: 1fr; }
  .mobile-menu { display: grid; }
  .sidebar { width: min(320px, 88vw); position: fixed; left: -340px; top: 68px; z-index: 28; transition: left .2s ease; box-shadow: 16px 0 40px rgba(0,0,0,.25); }
  .sidebar.open { left: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div:nth-child(2) { border-right: 0; }
  .stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .task-table { min-width: 850px; }
  .task-table-wrap { overflow-x: auto; }
}

@media (max-width: 680px) {
  .topbar { height: 62px; padding: 0 12px; }
  .brand small, .save-status, #user-name { display: none; }
  .layout { min-height: calc(100vh - 62px); }
  .sidebar { top: 62px; height: calc(100vh - 62px); }
  .project-header { align-items: flex-start; flex-direction: column; }
  .project-actions { width: 100%; }
  .project-actions .button { flex: 1; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats > div { min-height: 92px; padding: 16px; }
  .controls { flex-wrap: wrap; }
  .search-box { width: 100%; order: 3; margin: 0; }
  .controls select { margin-left: auto; }
  .zoom-control { width: 100%; order: 4; }
  .zoom-control button { flex: 1; }
  .table-view, .gantt-view { padding: 14px 12px; }
  .field-row { grid-template-columns: 1fr; }
  dialog:not(.side-dialog) { width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .modal-form { min-height: 100%; }
  .modal-form footer { position: sticky; bottom: 0; background: #fff; grid-template-columns: 1fr 1fr; }
  .modal-form footer span { display: none; }
  .modal-form footer .danger-link { grid-column: 1 / -1; }
}
