:root {
    color-scheme: light;
    --bg: #f5f7f4;
    --surface: #ffffff;
    --text: #17211b;
    --muted: #5d6b64;
    --line: #dce5dd;
    --accent: #236c4a;
    --accent-dark: #174c35;
    --warn: #a33131;
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--accent);
    font-weight: 700;
}

.page {
    min-height: 100vh;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
    min-height: 100vh;
}

.brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(32px, 7vw, 96px);
    background: linear-gradient(135deg, #174c35 0%, #236c4a 52%, #c8d96f 100%);
    color: #ffffff;
}

.brand-panel h1 {
    max-width: 780px;
    margin: 12px 0 18px;
    font-size: clamp(36px, 6vw, 72px);
    line-height: 1;
}

.brand-panel p {
    max-width: 620px;
    color: rgba(255, 255, 255, 0.84);
    font-size: 18px;
    line-height: 1.6;
}

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

.auth-card {
    align-self: center;
    width: min(100% - 40px, 420px);
    margin: 40px auto;
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(23, 33, 27, 0.08);
}

.auth-card h2 {
    margin: 8px 0 24px;
    font-size: 28px;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(35, 108, 74, 0.14);
}

button {
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

button:hover {
    background: var(--accent-dark);
}

.app-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 22px;
    min-height: 64px;
    padding: 0 clamp(16px, 4vw, 48px);
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.brand {
    color: var(--text);
    font-size: 20px;
    font-weight: 900;
    text-decoration: none;
}

.nav-links {
    display: flex;
    flex: 1;
    gap: 18px;
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links a {
    position: relative;
    color: var(--muted);
    font-size: 14px;
    text-decoration: none;
}

.nav-links a:hover {
    color: var(--text);
}

.notification-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.notification-badge {
    display: inline-grid;
    min-width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 999px;
    padding: 0 6px;
    background: var(--warn);
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.nav-button {
    width: auto;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

.notification-permission-status {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pwa-install-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.messages {
    width: min(1120px, calc(100% - 32px));
    margin: 18px auto 0;
}

.messages p {
    margin: 0;
    border: 1px solid rgba(35, 108, 74, 0.24);
    border-radius: 6px;
    padding: 12px 14px;
    background: rgba(35, 108, 74, 0.08);
    color: var(--accent-dark);
    font-weight: 700;
}

.secondary {
    width: auto;
    min-width: 88px;
    padding: 0 18px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
}

.secondary:hover {
    background: #edf3ef;
}

.helper {
    margin: 18px 0 0;
    color: var(--muted);
    text-align: center;
}

.form-error {
    margin: 0 0 16px;
    border: 1px solid rgba(163, 49, 49, 0.24);
    border-radius: 6px;
    padding: 12px;
    background: rgba(163, 49, 49, 0.08);
    color: var(--warn);
    font-size: 14px;
}

.dashboard {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}

.topbar h1 {
    margin: 6px 0 0;
    font-size: clamp(30px, 4vw, 48px);
}

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

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 6px;
    padding: 0 18px;
    background: var(--accent);
    color: #ffffff;
    text-decoration: none;
}

.button-link:hover {
    background: var(--accent-dark);
}

.button-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: min(360px, 100%);
}

.search-form input[type="search"] {
    min-width: 220px;
}

.search-clear {
    width: auto;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.search-clear:hover {
    background: transparent;
    color: var(--text);
}

.is-filtered-out {
    display: none !important;
}

[data-countdown-target] {
    color: var(--accent-dark);
    font-variant-numeric: tabular-nums;
}

.countdown-expired {
    color: var(--warn);
}

.notification-stack {
    position: fixed;
    top: 78px;
    right: clamp(16px, 3vw, 36px);
    z-index: 30;
    display: grid;
    width: min(360px, calc(100vw - 32px));
    gap: 10px;
}

.notification-toast {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    border: 1px solid rgba(163, 49, 49, 0.24);
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
    box-shadow: 0 18px 48px rgba(23, 33, 27, 0.14);
}

.notification-toast-body {
    display: grid;
    min-height: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.notification-toast-body:hover {
    background: transparent;
}

.notification-toast-body span,
.notification-toast-body small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.notification-toast-body strong {
    margin: 3px 0;
}

.notification-toast-read {
    width: auto;
    min-height: 36px;
    align-self: center;
    padding: 0 12px;
}

.notification-read {
    opacity: 0.62;
}

.notification-read-form {
    min-width: max-content;
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--muted);
    font-weight: 800;
    text-decoration: none;
}

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

.status-grid article {
    min-height: 180px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.status-grid span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.status-grid strong {
    display: block;
    margin-top: 14px;
    font-size: 24px;
}

.status-grid p {
    color: var(--muted);
    line-height: 1.5;
}

.content-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0;
}

.content-shell.narrow {
    width: min(720px, calc(100% - 32px));
}

.page-head,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-head h1,
.section-head h2 {
    margin: 6px 0 0;
}

.page-head h1 {
    font-size: clamp(30px, 4vw, 48px);
}

.section-head h2 {
    font-size: 22px;
}

.split-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-top: 28px;
}

.item-list,
.table-list {
    display: grid;
    gap: 12px;
}

.list-item,
.row-item,
.detail-panel,
.data-form {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.list-item,
.row-item {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
}

.mission-task-card {
    padding-top: 42px;
}

.mission-task-card::before {
    content: "Missao: " attr(data-mission-title);
    position: absolute;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    min-height: 28px;
    padding: 0 18px;
    background: linear-gradient(90deg, #2f6f83, #236c4a);
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
}

.task-completed-card {
    border-color: #8cc39f;
    background:
        linear-gradient(135deg, rgba(31, 122, 75, 0.18), rgba(200, 217, 111, 0.22)),
        #f3fbf5;
    box-shadow: inset 4px 0 0 #1f7a4b;
}

.overdue-card {
    border-color: #c96d6d;
    background:
        linear-gradient(135deg, rgba(163, 49, 49, 0.18), rgba(255, 226, 226, 0.7)),
        #fff5f5;
    box-shadow: inset 4px 0 0 var(--warn);
}

.task-completed-card h2 a,
.task-completed-card h3 a {
    color: #145637;
}

.overdue-card h2 a,
.overdue-card h3 a {
    color: #7f2424;
}

.missed-history-card {
    border-color: #c96d6d;
    background: #fff5f5;
    box-shadow: inset 4px 0 0 var(--warn);
}

.list-item h3,
.row-item h2 {
    margin: 8px 0 6px;
}

.list-item p,
.row-item p {
    margin: 0;
    color: var(--muted);
}

.compact {
    min-height: 92px;
}

.progress-row {
    align-items: stretch;
}

.progress-row > div:first-child {
    flex: 1;
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 180px;
}

.row-actions a {
    color: var(--muted);
    text-decoration: none;
}

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 10px;
    background: color-mix(in srgb, var(--tag-color, var(--accent)) 16%, white);
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 900;
}

.color-dot {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(23, 33, 27, 0.06);
}

.progress {
    width: 100%;
    height: 10px;
    margin-top: 14px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eee9;
}

.progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #c8d96f);
}

.progress.large {
    height: 14px;
}

.small-button {
    width: auto;
    min-height: 36px;
    padding: 0 14px;
    white-space: nowrap;
}

.secondary-action {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

.secondary-action:hover {
    background: #edf3ef;
}

.danger {
    background: var(--warn);
}

.danger:hover {
    background: #7f2424;
}

.icon-text {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.icon {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 999px;
    vertical-align: -3px;
}

.icon-check {
    background: #1f7a4b;
}

.icon-check::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 3px;
    width: 6px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.icon-x {
    background: #a83232;
}

.icon-x::before,
.icon-x::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    width: 10px;
    height: 2px;
    border-radius: 999px;
    background: #ffffff;
}

.icon-x::before {
    transform: rotate(45deg);
}

.icon-x::after {
    transform: rotate(-45deg);
}

.icon-pending {
    border: 2px solid #b38600;
    background: #fff0a8;
}

.icon-pending::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 4px;
    width: 3px;
    height: 7px;
    border-radius: 999px;
    background: #7a5a00;
}

.icon-pending::after {
    content: "";
    position: absolute;
    left: 7px;
    bottom: 3px;
    width: 3px;
    height: 3px;
    border-radius: 999px;
    background: #7a5a00;
}

.icon-clock {
    border: 2px solid #b37820;
    background: #fff8e8;
}

.icon-clock::before,
.icon-clock::after {
    content: "";
    position: absolute;
    left: 8px;
    top: 4px;
    width: 2px;
    border-radius: 999px;
    background: #8c5a12;
    transform-origin: bottom center;
}

.icon-clock::before {
    height: 5px;
}

.icon-clock::after {
    height: 7px;
    transform: rotate(90deg);
}

.icon-bell {
    background: #f4efe2;
    border: 2px solid #8c6b2d;
    border-radius: 8px 8px 6px 6px;
}

.icon-bell::before {
    content: "";
    position: absolute;
    left: 5px;
    top: -5px;
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: #8c6b2d;
}

.icon-bell::after {
    content: "";
    position: absolute;
    left: 5px;
    bottom: -5px;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: #8c6b2d;
}

.icon-repeat {
    border: 2px solid #2f6f83;
    background: #ecf8fb;
}

.icon-repeat::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 6px;
    height: 6px;
    border: solid #2f6f83;
    border-width: 2px 2px 0 0;
    border-radius: 0 6px 0 0;
}

.icon-repeat::after {
    content: "";
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid #2f6f83;
}

.icon-history {
    border: 2px solid #55625a;
    background: #eef3ef;
}

.icon-history::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 4px;
    width: 5px;
    height: 5px;
    border-left: 2px solid #55625a;
    border-bottom: 2px solid #55625a;
}

.icon-history::after {
    content: "";
    position: absolute;
    left: -3px;
    top: 2px;
    width: 6px;
    height: 6px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 7px solid #55625a;
}

.empty {
    margin: 0;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 24px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.62);
}

.data-form {
    padding: 24px;
}

.data-form select,
.data-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font: inherit;
}

.data-form textarea {
    resize: vertical;
}

.data-form [hidden],
.data-form .is-hidden {
    display: none;
}

.help-text,
.field-error {
    font-size: 13px;
}

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

.field-error {
    color: var(--warn);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.form-actions button {
    width: auto;
    padding: 0 18px;
}

.detail-panel {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 18px;
    padding: 22px;
}

.detail-panel span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
}

.detail-panel strong {
    display: block;
    margin-top: 8px;
    font-size: 24px;
}

.detail-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px;
    background: rgba(255, 255, 255, 0.78);
}

.detail-card p {
    margin: 0 0 12px;
}

.detail-card p:last-child {
    margin-bottom: 0;
}

@media (max-width: 820px) {
    .auth-shell,
    .status-grid,
    .split-grid,
    .detail-panel {
        grid-template-columns: 1fr;
    }

    .brand-panel {
        min-height: 42vh;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-nav,
    .nav-links,
    .page-head,
    .section-head,
    .row-item,
    .list-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-links {
        gap: 10px;
    }

    .row-actions,
    .button-group {
        justify-content: flex-start;
        flex-wrap: wrap;
        min-width: 0;
    }

    .search-form {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-form input[type="search"] {
        min-width: 0;
        flex: 1 1 220px;
    }
}
