:root {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #111827;
    --surface-2: #172033;
    --surface-3: #202b3d;
    --border: #2d3748;
    --border-soft: rgba(148, 163, 184, .18);
    --text: #f8fafc;
    --muted: #a7b1c2;
    --muted-2: #738195;
    --primary: #2563eb;
    --primary-soft: rgba(37, 99, 235, .16);
    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, .14);
    --yellow: #facc15;
    --yellow-soft: rgba(250, 204, 21, .14);
    --red: #ef4444;
    --red-soft: rgba(239, 68, 68, .15);
    --purple: #8b5cf6;
    --purple-soft: rgba(139, 92, 246, .15);
    --shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.app-shell {
    min-height: 100vh;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 32px;
    line-height: 1.15;
    margin-bottom: 8px;
}

h2 {
    font-size: 17px;
    line-height: 1.3;
    margin-bottom: 0;
}

.muted {
    color: var(--muted);
}

.eyebrow {
    margin: 0 0 8px;
    color: #7dd3fc;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-panel {
    width: min(100%, 420px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b1220;
    color: var(--text);
    padding: 12px 14px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(37, 99, 235, .2);
}

button,
.primary-action {
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    min-height: 42px;
    padding: 11px 16px;
}

.alert {
    margin-top: 16px;
    border: 1px solid rgba(239, 68, 68, .45);
    border-radius: 8px;
    background: var(--red-soft);
    color: #fecaca;
    padding: 12px;
}

.dashboard-page {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
}

.brand-block {
    align-items: center;
    display: flex;
    gap: 12px;
    min-height: 48px;
}

.brand-mark,
.sidebar-nav span,
.logout-button span {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 900;
    justify-content: center;
}

.brand-mark {
    background: var(--primary);
    color: #fff;
    height: 42px;
    width: 42px;
}

.brand {
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
}

.brand-block p {
    color: var(--muted-2);
    font-size: 13px;
    margin: 4px 0 0;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.sidebar-nav a,
.logout-button {
    align-items: center;
    border-radius: 8px;
    color: var(--muted);
    display: flex;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    text-align: left;
    width: 100%;
}

.sidebar-nav span,
.logout-button span {
    background: rgba(148, 163, 184, .12);
    color: var(--muted);
    height: 26px;
    width: 26px;
}

.sidebar-nav a.active,
.sidebar-nav a:hover,
.logout-button:hover {
    background: var(--primary-soft);
    color: var(--text);
}

.sidebar-nav a.active span,
.sidebar-nav a:hover span,
.logout-button:hover span {
    background: rgba(37, 99, 235, .28);
    color: var(--text);
}

.sidebar-user {
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    margin-top: auto;
    padding: 14px;
}

.sidebar-user p {
    font-weight: 800;
    margin-bottom: 4px;
}

.sidebar-user span {
    color: var(--muted-2);
    display: block;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.logout-button {
    background: transparent;
}

.content {
    min-width: 0;
    padding: 32px;
}

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

.page-subtitle {
    color: var(--muted);
    margin-bottom: 0;
}

.header-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.role-badge,
.status-pill {
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    padding: 7px 10px;
    text-transform: capitalize;
    white-space: nowrap;
}

.secondary-action {
    align-items: center;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    color: var(--muted);
    display: inline-flex;
    font-weight: 800;
    min-height: 42px;
    padding: 10px 14px;
}

.secondary-action:hover {
    background: rgba(148, 163, 184, .1);
    color: var(--text);
}

.notice {
    border-radius: 8px;
    font-weight: 700;
    margin-bottom: 16px;
    padding: 13px 14px;
}

.notice p {
    margin-bottom: 0;
}

.notice.success {
    background: var(--green-soft);
    border: 1px solid rgba(34, 197, 94, .28);
    color: #bbf7d0;
}

.notice.error {
    background: var(--red-soft);
    border: 1px solid rgba(239, 68, 68, .35);
    color: #fecaca;
}

.metrics-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.metric-card,
.panel {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.metric-card {
    min-height: 118px;
    padding: 18px;
}

.metric-card span {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 16px;
}

.metric-card strong {
    display: block;
    font-size: 34px;
    line-height: 1;
}

.metric-card.blue {
    background: linear-gradient(180deg, rgba(37, 99, 235, .2), var(--surface-2));
}

.metric-card.green {
    background: linear-gradient(180deg, var(--green-soft), var(--surface-2));
}

.metric-card.yellow {
    background: linear-gradient(180deg, var(--yellow-soft), var(--surface-2));
}

.metric-card.purple {
    background: linear-gradient(180deg, var(--purple-soft), var(--surface-2));
}

.dashboard-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .85fr);
}

.panel {
    min-width: 0;
    padding: 20px;
}

.panel-wide {
    grid-row: span 2;
}

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

.panel-header a {
    color: #93c5fd;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.task-list,
.deadline-list,
.project-list,
.activity-list {
    display: grid;
    gap: 10px;
}

.task-row,
.deadline-row,
.project-row,
.activity-row,
.empty-state {
    background: rgba(15, 23, 42, .5);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
}

.task-row {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 72px;
    padding: 14px;
}

.task-row strong,
.deadline-row strong,
.project-row strong,
.activity-row strong {
    display: block;
    overflow-wrap: anywhere;
}

.task-row span,
.project-meta,
.activity-row p,
.deadline-row span,
.deadline-row time,
.row-meta time {
    color: var(--muted-2);
    font-size: 13px;
}

.row-meta {
    align-items: flex-end;
    display: grid;
    gap: 8px;
    justify-items: end;
}

.priority-urgente {
    background: var(--red-soft);
    border-color: rgba(239, 68, 68, .35);
    color: #fecaca;
}

.priority-alta {
    background: rgba(249, 115, 22, .14);
    border-color: rgba(249, 115, 22, .35);
    color: #fed7aa;
}

.priority-media {
    background: var(--yellow-soft);
    border-color: rgba(250, 204, 21, .3);
    color: #fef08a;
}

.deadline-row,
.project-row {
    display: grid;
    gap: 8px;
    padding: 13px;
}

.project-topline,
.project-meta {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.progress-track {
    background: rgba(148, 163, 184, .15);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
}

.progress-track span {
    background: var(--green);
    border-radius: inherit;
    display: block;
    height: 100%;
}

.activity-row {
    display: grid;
    gap: 10px;
    grid-template-columns: 10px minmax(0, 1fr);
    padding: 13px;
}

.activity-row > span {
    background: var(--primary);
    border-radius: 999px;
    height: 10px;
    margin-top: 5px;
    width: 10px;
}

.activity-row p {
    margin: 4px 0 0;
}

.empty-state {
    padding: 18px;
}

.empty-state.compact {
    min-height: 138px;
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
}

.empty-state p {
    margin-bottom: 0;
}

.projects-table {
    display: grid;
    gap: 8px;
}

.projects-table-head,
.projects-table-row {
    align-items: center;
    display: grid;
    gap: 14px;
    grid-template-columns: minmax(220px, 1.4fr) minmax(110px, .55fr) minmax(110px, .55fr) minmax(130px, .65fr) minmax(150px, .8fr);
}

.projects-table-head {
    color: var(--muted-2);
    font-size: 12px;
    font-weight: 900;
    padding: 0 14px 6px;
    text-transform: uppercase;
}

.projects-table-row {
    background: rgba(15, 23, 42, .5);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    min-height: 72px;
    padding: 14px;
}

.projects-table-row:hover {
    background: rgba(37, 99, 235, .1);
}

.projects-table-row small {
    color: var(--muted-2);
    display: block;
    font-size: 12px;
    margin-top: 4px;
}

.projects-table-row time {
    color: var(--muted);
    font-size: 13px;
}

.projects-table-row .progress-track {
    margin-bottom: 6px;
}

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

.field-wide {
    grid-column: 1 / -1;
}

.form-actions {
    align-items: center;
    display: flex;
    justify-content: flex-end;
}

.detail-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
}

.detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.detail-list div {
    align-items: center;
    background: rgba(15, 23, 42, .45);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 12px;
}

.detail-list dt {
    color: var(--muted-2);
    font-size: 13px;
    font-weight: 800;
}

.detail-list dd {
    margin: 0;
    text-align: right;
}

.progress-track.large {
    height: 12px;
}

.detail-note {
    margin: 16px 0 0;
}

.danger-zone {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.danger-button {
    background: var(--red-soft);
    border: 1px solid rgba(239, 68, 68, .35);
    color: #fecaca;
}

.danger-button:hover {
    background: rgba(239, 68, 68, .22);
}

.steps-panel {
    margin-top: 16px;
}

.step-list {
    display: grid;
    gap: 12px;
}

.step-row {
    align-items: start;
    background: rgba(15, 23, 42, .5);
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    padding: 14px;
}

.step-order {
    align-items: center;
    background: rgba(37, 99, 235, .18);
    border: 1px solid rgba(37, 99, 235, .25);
    border-radius: 8px;
    color: #bfdbfe;
    display: flex;
    font-weight: 900;
    height: 42px;
    justify-content: center;
    width: 42px;
}

.step-main strong {
    display: block;
    overflow-wrap: anywhere;
}

.step-main p {
    color: var(--muted);
    margin: 6px 0 10px;
}

.step-meta {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.step-meta time {
    color: var(--muted-2);
    font-size: 13px;
}

.step-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.step-actions .secondary-action,
.step-actions .danger-button {
    min-height: 36px;
    padding: 8px 11px;
}

@media (max-width: 1120px) {
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

    .panel-wide {
        grid-row: auto;
    }
}

@media (max-width: 860px) {
    .dashboard-page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-bottom: 1px solid var(--border-soft);
        border-right: 0;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sidebar-user {
        margin-top: 0;
    }

    .content {
        padding: 24px;
    }

    .page-header {
        display: grid;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .projects-table-head {
        display: none;
    }

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

    .step-row {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .step-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    h1 {
        font-size: 26px;
    }

    .auth-panel,
    .content,
    .sidebar {
        padding: 20px;
    }

    .metrics-grid,
    .sidebar-nav {
        grid-template-columns: 1fr;
    }

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

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

    .row-meta {
        align-items: start;
        justify-items: start;
    }

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