:root {
    --bg: #050816;
    --bg-elevated: #0b1020;
    --bg-elevated-soft: #101528;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.14);
    --accent-soft-strong: rgba(99, 102, 241, 0.25);
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --danger: #f97373;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.75);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-pill: 999px;
    --transition-fast: 150ms ease-out;
    --transition-med: 220ms ease;
    --focus-ring: 0 0 0 1px rgba(148, 163, 184, 0.2), 0 0 0 4px rgba(99, 102, 241, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #1d2437, #020617 55%, #000 100%);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px clamp(20px, 4vw, 40px);
    gap: 20px;
    max-width: 1366px;
    margin: 0 auto;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at top left, rgba(99, 102, 241, 0.15), transparent 65%),
    linear-gradient(135deg, rgba(15, 23, 42, 0.92), rgba(15, 23, 42, 0.85));
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: var(--shadow-soft);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 32% 68% 53% 47% / 30% 30% 70% 70%;
    background: radial-gradient(circle at 30% 20%, #e5e7eb, #4f46e5 40%, #1d4ed8 80%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #020617;
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.75);
}

.top-bar h1 {
    margin: 0;
    font-size: clamp(1.2rem, 2.1vw, 1.55rem);
    letter-spacing: 0.01em;
}

.subtitle {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.6fr);
    gap: 20px;
    align-items: flex-start;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

.card {
    position: relative;
    padding: 18px 18px 20px;
    border-radius: var(--radius-lg);
    background: radial-gradient(circle at top left, rgba(30, 64, 175, 0.45), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(148, 163, 184, 0.5);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.15), transparent 60%);
    opacity: 0.9;
    pointer-events: none;
}

.card-primary {
    min-height: 260px;
}

.card-side {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.95));
}

.card h2 {
    position: relative;
    z-index: 1;
    margin: 0 0 10px;
    font-size: 0.98rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: #c7d2fe;
}

.card > *:not(h2) {
    position: relative;
    z-index: 1;
}

.empty-state {
    margin: 10px 0 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.9);
    border: 1px dashed rgba(148, 163, 184, 0.5);
    color: var(--text-muted);
    font-size: 0.88rem;
}

.tasks-table-wrapper {
    margin-top: 4px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.45);
    overflow: auto;
    max-height: min(520px, 70vh);
}

.tasks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.tasks-table thead {
    background: #111827;
}

.tasks-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #111827;
}

.tasks-table th,
.tasks-table td {
    padding: 9px 10px;
    border-bottom: 1px solid rgba(31, 41, 55, 0.95);
    text-align: left;
    white-space: nowrap;
    vertical-align: middle;
}

.tasks-table th {
    font-weight: 500;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: rgba(209, 213, 219, 0.95);
}

.tasks-table tbody tr:last-child td {
    border-bottom: none;
}

.tasks-table tbody tr {
    background: rgba(15, 23, 42, 0.96);
    transition: background var(--transition-fast), transform var(--transition-fast);
    height: 48px;
}

.task-subtotal {
    display: inline-block;
    min-width: 80px;
    text-align: right;
}

.tasks-table tbody tr:hover {
    background: rgba(17, 24, 39, 1);
}

.tasks-table .col-include {
    width: 62px;
}

.tasks-table .col-type {
    width: 138px;
}

.tasks-table .col-minutes {
    width: 110px;
}

.tasks-table .col-quantity {
    width: 120px;
}

.tasks-table .col-subtotal {
    width: 110px;
}

.tasks-table .col-actions {
    width: 90px;
    text-align: right;
}

.task-name {
    white-space: normal;
}

.muted {
    color: var(--text-muted);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.65);
    background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.9));
    cursor: pointer;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform 90ms ease-out;
}

input[type="checkbox"]:hover {
    border-color: rgba(129, 140, 248, 0.9);
}

input[type="checkbox"]:checked {
    background: radial-gradient(circle at 30% 20%, #e5e7eb, #4f46e5 55%, #1d4ed8 90%);
    border-color: rgba(79, 70, 229, 0.9);
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.5), 0 0 0 6px rgba(79, 70, 229, 0.2);
}

input[type="checkbox"]:checked::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 3px;
    background: rgba(15, 23, 42, 0.95);
}

input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

input[type="number"],
input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 7px 9px;
    border-radius: 9px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.9), rgba(17, 24, 39, 1));
    color: var(--text-main);
    font: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), transform 90ms ease-out;
}

input[type="number"]::placeholder,
input[type="text"]::placeholder,
input[type="password"]::placeholder,
textarea::placeholder {
    color: rgba(148, 163, 184, 0.7);
}

input[type="number"]:focus-visible,
input[type="text"]:focus-visible,
input[type="password"]:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: none;
    border-color: rgba(129, 140, 248, 0.9);
    box-shadow: var(--focus-ring);
    background: radial-gradient(circle at top, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 1));
}

select {
    padding-right: 28px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, rgba(148, 163, 184, 0.95) 50%), linear-gradient(135deg, rgba(148, 163, 184, 0.95) 50%, transparent 50%);
    background-position: calc(100% - 16px) 48%, calc(100% - 11px) 48%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

select option {
    color: #020617;
    background-color: #e5e7eb;
}

.layout.layout-single {
    grid-template-columns: minmax(0, 1fr);
}

.estimate-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(260px, 1fr);
    gap: 16px;
    align-items: flex-start;
    margin-top: 4px;
}

.estimate-main {
    min-width: 0;
}

.estimate-side {
    position: sticky;
    top: 84px;
}

.estimate-side .totals-panel {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.layout.layout-admin {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.3fr);
    row-gap: 20px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition-med), border-color var(--transition-med), color var(--transition-med), box-shadow var(--transition-med), transform 90ms ease-out;
}

.button-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #e5e7eb;
    border-color: rgba(129, 140, 248, 0.9);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
}

.button-primary:hover {
    background: linear-gradient(135deg, #818cf8, #4f46e5);
    transform: translateY(-0.5px);
}

.button-soft {
    background: rgba(15, 23, 42, 0.9);
    color: rgba(156, 163, 175, 0.98);
    border-color: rgba(55, 65, 81, 0.95);
}

.button-soft:hover {
    background: rgba(31, 41, 55, 0.95);
    color: #e5e7eb;
}

.button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.full-width {
    width: 100%;
}

.inline-form {
    display: inline;
}

.totals-panel {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.3), rgba(15, 23, 42, 0.96));
    border: 1px solid rgba(129, 140, 248, 0.8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.totals-label {
    margin: 0 0 2px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(191, 219, 254, 0.9);
}

.totals-primary {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.totals-secondary {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(209, 213, 219, 0.9);
}

.stacked-form {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.86rem;
}

.field-label {
    color: rgba(209, 213, 219, 0.98);
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    font-size: 0.82rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.field-label-note {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
}

.side-help {
    margin: 4px 0 10px;
    font-size: 0.87rem;
    color: var(--text-muted);
}

.side-note {
    margin: 6px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Task tooltip */
.task-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
}

.task-tooltip-icon {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.95);
    color: rgba(209, 213, 219, 0.95);
    font-size: 0.68rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.task-tooltip-content {
    position: absolute;
    z-index: 20;
    top: 115%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    opacity: 0;
    pointer-events: none;
    min-width: 220px;
    max-width: 320px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.9);
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.9);
    color: rgba(229, 231, 235, 0.98);
    font-size: 0.78rem;
    line-height: 1.45;
    text-align: left;
    white-space: normal;
    transition: opacity 120ms ease-out, transform 120ms ease-out;
}

.task-tooltip-content::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent rgba(15, 23, 42, 0.98) transparent;
}

.task-tooltip:hover .task-tooltip-content {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Top bar actions */
.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-button {
    padding-inline: 14px;
    font-size: 0.8rem;
}

.user-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.6);
    font-size: 0.78rem;
    color: rgba(209, 213, 219, 0.95);
}

.preview-form {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
}

.preview-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.preview-select {
    max-width: 140px;
    font-size: 0.75rem;
    padding: 4px 18px 4px 8px;
}

/* Packages UI */
.packages-bar {
    margin: 4px 0 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.packages-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(191, 219, 254, 0.9);
}

.packages-select {
    max-width: 260px;
}

.packages-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.package-chip {
    border-radius: 999px;
    border: 1px solid rgba(55, 65, 81, 0.95);
    background: rgba(15, 23, 42, 0.9);
    color: rgba(209, 213, 219, 0.96);
    padding: 4px 11px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), transform 90ms ease-out, box-shadow var(--transition-fast);
}

.package-chip:hover {
    background: rgba(31, 41, 55, 0.95);
}

.package-chip.is-active {
    border-color: rgba(129, 140, 248, 0.9);
    background: radial-gradient(circle at top left, rgba(79, 70, 229, 0.7), rgba(15, 23, 42, 0.95));
    color: #e5e7eb;
    box-shadow: 0 8px 22px rgba(79, 70, 229, 0.5);
}

.packages-admin {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(31, 41, 55, 0.95);
}

.subheading {
    margin: 0 0 6px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: rgba(191, 219, 254, 0.9);
}

.packages-tasks-grid {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(55, 65, 81, 0.9);
    background: rgba(15, 23, 42, 0.9);
    font-size: 0.8rem;
    cursor: pointer;
}

.checkbox-pill input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.packages-list {
    margin-top: 14px;
}

.packages-list-items {
    list-style: none;
    padding: 0;
    margin: 6px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.packages-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(31, 41, 55, 1);
}

.packages-list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.packages-list-name {
    font-size: 0.86rem;
}

.packages-list-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Auth layout */
.auth-shell {
    justify-content: center;
}

.layout-auth {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: 10px;
}

.layout-auth .card {
    max-width: 460px;
    width: 100%;
}

.auth-error {
    margin: 6px 0 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(127, 29, 29, 0.9);
    border: 1px solid rgba(248, 113, 113, 0.7);
    color: #fee2e2;
    font-size: 0.82rem;
}

.auth-link {
    color: #a5b4fc;
    text-decoration: none;
    font-size: 0.82rem;
}

.auth-link:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .app-shell {
        padding: 16px 14px 20px;
    }

    .top-bar {
        padding: 12px 14px;
    }

    .card {
        padding: 14px 12px 16px;
    }

    .tasks-table-wrapper {
        max-height: 380px;
    }

    .totals-primary {
        font-size: 1.2rem;
    }
}

