* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f6f8;
    color: #222;
}

a {
    color: #1f5fbf;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.login-card {
    width: 360px;
    background: #fff;
    border-radius: 12px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.login-card h1 {
    margin: 0 0 20px;
    font-size: 24px;
}

.login-card label,
.field {
    display: block;
    margin-bottom: 16px;
}

.login-card span,
.field span {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.field em {
    font-style: normal;
    font-size: 12px;
    color: #c0392b;
    margin-left: 4px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 14px;
    background: #fff;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3f7fd8;
    box-shadow: 0 0 0 3px rgba(63, 127, 216, 0.16);
}

button,
.button {
    display: inline-block;
    border: 0;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 14px;
    line-height: 1.3;
    cursor: pointer;
    text-decoration: none;
    background: #e9edf3;
    color: #222;
}

button:hover,
.button:hover {
    text-decoration: none;
    filter: brightness(0.97);
}

button.primary,
.button.primary {
    background: #1f5fbf;
    color: #fff;
}

.button.secondary {
    background: #e9edf3;
    color: #222;
}

.button.danger {
    background: #c0392b;
    color: #fff;
}

.alert {
    border-radius: 10px;
    padding: 12px 14px;
    margin: 0 0 18px;
}

.alert.error {
    background: #fdecea;
    border: 1px solid #f5c2bd;
    color: #7f1d1d;
}

.alert ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.navbar {
    background: #1f2937;
    color: #fff;
    padding: 12px 24px;
}

.navbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar a {
    color: #fff;
}

.navbar .brand {
    font-weight: 700;
    font-size: 18px;
}

.muted {
    color: #667085;
    font-size: 13px;
}

.card {
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-header h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.table th,
.table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.table th {
    background: #f0f3f7;
    font-weight: 700;
    white-space: nowrap;
}

.table tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-block;
    min-width: 64px;
    text-align: center;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge.not_started {
    background: #e5e7eb;
    color: #374151;
}

.badge.in_progress {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.done {
    background: #dcfce7;
    color: #166534;
}

.badge.on_hold {
    background: #ede9fe;
    color: #5b21b6;
}

.badge.cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

.health {
    display: inline-block;
    min-width: 56px;
    border-radius: 999px;
    padding: 3px 9px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

.health.ok {
    background: #dcfce7;
    color: #166534;
}

.health.warning {
    background: #fef3c7;
    color: #92400e;
}

.health.overdue {
    background: #fee2e2;
    color: #991b1b;
}

.health.done {
    background: #dcfce7;
    color: #166534;
}

.health.not_started {
    background: #e5e7eb;
    color: #374151;
}

.form-card {
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 14px;
    padding: 20px;
}

.form-section {
    border-bottom: 1px solid #e5e7eb;
    padding: 0 0 20px;
    margin-bottom: 22px;
}

.form-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 0;
}

.form-section h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 16px 20px;
}

.field {
    margin-bottom: 0;
}

.field small {
    display: block;
    color: #667085;
    margin-top: 6px;
    line-height: 1.5;
}

.span-2 {
    grid-column: span 2;
}

.progress-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-input input {
    max-width: 120px;
}

.progress-input span {
    display: inline;
    margin: 0;
    font-weight: 600;
}

.dependency-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 8px 14px;
    max-height: 360px;
    overflow: auto;
    border: 1px solid #e1e5ea;
    border-radius: 10px;
    padding: 12px;
    background: #fafafa;
}

.dependency-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #eef1f4;
    font-size: 14px;
}

.dependency-item input {
    width: auto;
    margin-top: 2px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 18px;
}

.gantt-wrap {
    overflow-x: auto;
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 12px;
    padding: 14px;
}

.gantt-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
    align-items: center;
    min-height: 34px;
    border-bottom: 1px solid #f0f2f5;
}

.gantt-row:last-child {
    border-bottom: 0;
}

.gantt-label {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gantt-track {
    position: relative;
    height: 18px;
    min-width: 720px;
    background: #f3f4f6;
    border-radius: 999px;
}

.gantt-bar {
    position: absolute;
    top: 2px;
    height: 14px;
    border-radius: 999px;
    background: #1f5fbf;
}

.gantt-bar.done {
    background: #16a34a;
}

.gantt-bar.overdue {
    background: #dc2626;
}

.gantt-bar.not_started {
    background: #9ca3af;
}

@media (max-width: 760px) {
    .container {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .dependency-list {
        grid-template-columns: 1fr;
    }

    .gantt-row {
        grid-template-columns: 1fr;
    }
}

/* v0.2.1 compatibility: existing WBS / gantt layout */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #1f2937;
    color: #fff;
}

.topbar a {
    color: #fff;
    text-decoration: none;
    margin-left: 14px;
}

.brand {
    font-weight: 700;
}

.panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.actions {
    margin: 12px 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(130px,1fr));
    gap: 12px;
    margin: 18px 0;
}

.metric {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
}

.metric strong {
    font-size: 2rem;
}

.metric.danger { border-color: #fecaca; }
.metric.warn { border-color: #fde68a; }
.metric.ok { border-color: #bbf7d0; }

.split {
    display: grid;
    grid-template-columns: minmax(420px,1fr) minmax(620px,1.35fr);
    gap: 16px;
    margin: 18px 0;
}

.task-row {
    padding: 7px 4px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    gap: 8px;
    align-items: center;
}

.task-row a {
    color: #1d4ed8;
    text-decoration: none;
}

.task-row small {
    margin-left: auto;
    color: #64748b;
    white-space: nowrap;
}

.indent {
    display: inline-block;
    flex: 0 0 auto;
}

.hint {
    color: #64748b;
    font-size: .9em;
}

.gantt {
    overflow: auto;
}

.gantt-line {
    display: flex;
    min-width: 760px;
    height: 30px;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
}

.gantt-label {
    width: 230px;
    flex: 0 0 230px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .85rem;
}

.gantt-bar-wrap {
    position: relative;
    flex: 1;
    height: 22px;
    background: repeating-linear-gradient(
        90deg,
        #fff,
        #fff 15px,
        #f1f5f9 16px
    );
}

.gantt-bar {
    position: absolute;
    top: 3px;
    height: 16px;
    border-radius: 4px;
    color: #fff;
    font-size: .72rem;
    text-align: center;
    overflow: hidden;
    min-width: 3px;
    background: #2563eb;
}

.badge.hold,
.gantt-bar.hold {
    background: #7c3aed;
}

.badge.deadline_over,
.gantt-bar.deadline_over {
    background: #dc2626;
}

.badge.delayed,
.gantt-bar.delayed {
    background: #f97316;
}

.badge.on_track,
.gantt-bar.on_track {
    background: #2563eb;
}

.gantt-bar.done {
    background: #16a34a;
}

.gantt-bar.not_started {
    background: #94a3b8;
}

@media(max-width:900px) {
    .split {
        grid-template-columns: 1fr;
    }

    .gantt-panel {
        min-width: 0;
    }
}
