:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #152033;
    --muted: #6a768b;
    --line: #d8deea;
    --brand: #155eef;
    --danger: #d92d20;
    --warn: #dc6803;
    --ok: #067647;
    --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
    --radius: 14px;
}

body.theme-dark {
    --bg: #101622;
    --panel: #1a2435;
    --text: #e8eefc;
    --muted: #b4c0d9;
    --line: #2a3a54;
    --shadow: 0 10px 30px rgba(3, 8, 18, 0.5);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top right, #dbe6ff, #f4f6fb 45%);
}

body.theme-dark {
    background: radial-gradient(circle at top right, #1b2d4f, #101622 48%);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    transition: grid-template-columns 0.24s ease;
}

.sidebar {
    background: linear-gradient(200deg, #0f274f, #163970);
    color: #fff;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: padding 0.24s ease;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-bottom: 0.95rem;
}

.brand-full {
    width: 168px;
    height: auto;
    display: block;
}

.brand-icon {
    display: none;
    width: 34px;
    height: 34px;
}

.sidebar-collapse-btn {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 10px;
    padding: 0.45rem 0.55rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    justify-content: center;
    cursor: pointer;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: rgba(255, 255, 255, 0.86);
    text-decoration: none;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    font-weight: 600;
}

.nav-icon {
    width: 1.2rem;
    text-align: center;
    flex: 0 0 1.2rem;
}

.nav-label {
    white-space: nowrap;
}

.side-nav a.active,
.side-nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.sidebar-collapsed .app-shell {
    grid-template-columns: 86px 1fr;
}

.sidebar-collapsed .sidebar {
    padding: 1.25rem 0.55rem;
}

.sidebar-collapsed .brand-full {
    display: none;
}

.sidebar-collapsed .brand-icon {
    display: block;
}

.sidebar-collapsed .sidebar-collapse-btn .label,
.sidebar-collapsed .nav-label {
    display: none;
}

.sidebar-collapsed .sidebar-collapse-btn {
    padding: 0.45rem;
}

.sidebar-collapsed .side-nav a {
    justify-content: center;
    padding: 0.65rem 0.45rem;
}

.main-column {
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

body.theme-dark .topbar {
    background: rgba(15, 24, 38, 0.92);
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 700;
}

.topbar-user {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: var(--muted);
    font-size: 0.95rem;
}

.content {
    padding: 1.1rem;
    display: grid;
    gap: 1rem;
}

.grid.two {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.panel h2 {
    margin-top: 0;
    margin-bottom: 0.9rem;
    font-size: 1.03rem;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

th,
td {
    padding: 0.65rem 0.55rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 0.92rem;
}

th {
    color: var(--muted);
    font-weight: 700;
}

.form-grid {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.compact {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem 0.65rem;
    background: #fff;
}

body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background: #111c2f;
    color: var(--text);
    border-color: #30435f;
}

textarea {
    min-height: 84px;
    resize: vertical;
    grid-column: 1 / -1;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-outline {
    border-color: var(--line);
    background: #fff;
    color: var(--text);
}

body.theme-dark .btn-outline {
    background: #101b2d;
    color: #e8eefc;
    border-color: #30435f;
}

.pill {
    display: inline-block;
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.pill.red {
    background: #fef3f2;
    color: var(--danger);
}

.pill.amber {
    background: #fffaeb;
    color: var(--warn);
}

.pill.green {
    background: #ecfdf3;
    color: var(--ok);
}

.stat-grid {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.75rem;
    background: #fbfcff;
}

.stat .label {
    font-size: 0.84rem;
    color: var(--muted);
}

.stat .value {
    margin-top: 0.3rem;
    font-size: 1.2rem;
    font-weight: 800;
}

.error-text {
    color: var(--danger);
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.stack {
    display: grid;
    gap: 1rem;
}

.menu-toggle {
    display: none;
}

.overdue {
    color: var(--danger);
    font-weight: 700;
}

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

.login-card {
    width: min(94vw, 430px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 0.35rem;
}

.login-logo {
    width: min(270px, 100%);
    height: auto;
    display: block;
    margin-bottom: 0.3rem;
}

.login-card p {
    color: var(--muted);
}

.login-subtitle {
    margin-top: 0.1rem;
    margin-bottom: 1rem;
}

.login-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
}

.login-submit-btn {
    min-width: 130px;
}

.btn-link {
    border: 0;
    background: transparent;
    color: var(--brand);
    padding: 0.2rem 0;
    font-weight: 700;
}

.forgot-password-panel {
    margin-top: 0.8rem;
    padding-top: 0.8rem;
    border-top: 1px solid var(--line);
    display: none;
}

.forgot-password-panel.open {
    display: block;
}

.forgot-password-panel h3 {
    margin: 0 0 0.55rem;
    font-size: 0.98rem;
}

.hint {
    font-size: 0.82rem;
}

.hidden-input {
    display: none;
}

.board-grid {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    overflow-x: auto;
}

.board-column {
    background: #f8faff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.6rem;
    min-height: 240px;
}

.board-column h3 {
    margin: 0 0 0.55rem;
    font-size: 0.92rem;
    color: var(--muted);
}

.board-list {
    min-height: 190px;
    display: grid;
    gap: 0.5rem;
    align-content: start;
}

.board-list.drag-over {
    outline: 2px dashed var(--brand);
    outline-offset: 2px;
}

.board-card {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    padding: 0.55rem;
    cursor: grab;
}

body.theme-dark .board-card,
body.theme-dark .stat,
body.theme-dark .notification-card,
body.theme-dark .notification-popover,
body.theme-dark .notification-toast,
body.theme-dark .login-card {
    background: #172438;
    border-color: #30435f;
}

body.theme-dark .board-column {
    background: #121e31;
}

body.theme-dark table th,
body.theme-dark table td {
    border-bottom-color: #30435f;
}

.board-card .title {
    font-size: 0.9rem;
    font-weight: 700;
}

.board-card .meta {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.subtask-summary {
    font-size: 0.78rem;
    color: var(--muted);
}

.progress-line {
    width: 100%;
    height: 6px;
    background: #e8edf8;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-line > span {
    display: block;
    height: 100%;
    background: var(--brand);
}

.btn-xs {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
}

.notifications-list {
    display: grid;
    gap: 0.65rem;
}

.notification-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
}

.notification-card.unread {
    border-color: #b6ccff;
    box-shadow: 0 6px 16px rgba(21, 94, 239, 0.12);
    background: #f8fbff;
}

.notification-title-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.notification-title {
    font-weight: 700;
}

.notification-time {
    color: var(--muted);
    font-size: 0.82rem;
}

.notification-message {
    color: #2b3a57;
    font-size: 0.9rem;
}

.notification-meta {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.notification-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.notification-widget {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 60;
}

.notification-fab {
    border: 0;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    background: linear-gradient(160deg, #155eef, #0f4ec9);
    box-shadow: 0 14px 26px rgba(21, 94, 239, 0.35);
    color: #fff;
    cursor: pointer;
    position: relative;
    font-size: 1.18rem;
    transition: transform 0.24s ease, box-shadow 0.24s ease, background 0.24s ease;
    z-index: 2;
}

.notification-fab.pulse {
    animation: notif-pulse 0.9s ease-in-out 2;
}

.notification-fab:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 18px 34px rgba(21, 94, 239, 0.42);
}

.notification-fab.has-unread .notification-bell {
    animation: notif-ring 1.5s ease-in-out infinite;
    transform-origin: 50% 18%;
}

.notification-bell {
    display: inline-block;
    transform: translateY(1px);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d92d20;
    color: #fff;
    font-size: 0.72rem;
    line-height: 20px;
    font-weight: 700;
    text-align: center;
}

.notification-badge:empty {
    display: none;
}

.notification-popover {
    position: absolute;
    right: 0;
    bottom: 0;
    width: min(420px, calc(100vw - 2rem));
    max-height: min(72vh, 580px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 16px 36px rgba(16, 24, 40, 0.2);
    padding: 0.75rem;
    opacity: 0;
    transform: scale(0.1);
    transform-origin: 100% 100%;
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.notification-popover.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.notification-widget.open .notification-fab {
    transform: scale(0.35);
    opacity: 0;
    pointer-events: none;
    box-shadow: none;
}

.notification-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.notification-list {
    display: grid;
    gap: 0.65rem;
}

.notification-list .notification-card {
    animation: notif-card-in 0.24s ease both;
}

.notification-list .notification-card:nth-child(2) {
    animation-delay: 0.03s;
}

.notification-list .notification-card:nth-child(3) {
    animation-delay: 0.06s;
}

.notification-toast-stack {
    position: fixed;
    right: 1rem;
    bottom: 5.4rem;
    z-index: 70;
    width: min(420px, calc(100vw - 2rem));
    display: grid;
    gap: 0.55rem;
    pointer-events: none;
}

.notification-toast {
    border: 1px solid #bdd0ff;
    border-radius: 12px;
    background: #f8fbff;
    box-shadow: 0 14px 26px rgba(15, 39, 79, 0.18);
    padding: 0.7rem 0.75rem;
    display: grid;
    gap: 0.45rem;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    pointer-events: auto;
}

.notification-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.notification-toast.exit {
    transform: translateY(16px);
    opacity: 0;
}

.notification-toast-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.45rem;
}

.notification-toast-title {
    font-weight: 700;
    font-size: 0.92rem;
}

.notification-toast-close {
    border: 0;
    background: transparent;
    color: #466090;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
}

.notification-toast-message {
    color: #2b3a57;
    font-size: 0.88rem;
}

.notification-toast-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.notifications-page-panel h2 {
    margin-bottom: 0.35rem;
}

.notifications-page-panel.muted {
    background: #f9fbff;
}

.ack-pill {
    display: inline-block;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
}

.ack-pill.viewed {
    background: #ecfdf3;
    color: #067647;
}

.ack-pill.new {
    background: #eff4ff;
    color: #155eef;
}

.ack-pill.dismissed {
    background: #f2f4f7;
    color: #475467;
}

.ack-pill.na {
    background: #f4f6fb;
    color: #667085;
}

.toolbar {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-end {
    margin-left: auto;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: none;
}

.modal.open {
    display: block;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
}

.modal-card {
    position: relative;
    width: min(760px, calc(100vw - 1.8rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    margin: 1rem auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.28);
    padding: 1rem;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

.modal-close {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

body.theme-dark .modal-close {
    background: #111c2f;
}

.form-field {
    display: grid;
    gap: 0.3rem;
    align-content: start;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.35rem;
}

.switch-label {
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-flex;
    width: 54px;
    height: 30px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: #c8d2e6;
    border-radius: 999px;
    transition: background 0.2s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    top: 3px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(17, 24, 39, 0.25);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
    background: var(--brand);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(24px);
}

.row-highlight {
    animation: row-highlight-fade 3.8s ease;
    background: rgba(21, 94, 239, 0.12);
}

tr.row-highlight td {
    background: rgba(21, 94, 239, 0.12);
}

.section-highlight {
    animation: section-highlight-fade 4s ease;
    box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.26), var(--shadow);
}

@keyframes notif-pulse {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes notif-ring {
    0% {
        transform: translateY(1px) rotate(0deg);
    }
    10% {
        transform: translateY(1px) rotate(12deg);
    }
    20% {
        transform: translateY(1px) rotate(-10deg);
    }
    30% {
        transform: translateY(1px) rotate(8deg);
    }
    40% {
        transform: translateY(1px) rotate(-6deg);
    }
    50% {
        transform: translateY(1px) rotate(3deg);
    }
    100% {
        transform: translateY(1px) rotate(0deg);
    }
}

@keyframes notif-card-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes row-highlight-fade {
    0% {
        background: rgba(21, 94, 239, 0.24);
    }
    100% {
        background: transparent;
    }
}

@keyframes section-highlight-fade {
    0% {
        box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.45), var(--shadow);
    }
    100% {
        box-shadow: var(--shadow);
    }
}

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

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

    .sidebar {
        position: fixed;
        left: -280px;
        width: 260px;
        transition: left 0.25s ease;
        z-index: 30;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle {
        display: inline-block;
        border: 1px solid var(--line);
        background: #fff;
        border-radius: 10px;
        padding: 0.45rem 0.7rem;
    }

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

    .board-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .topbar-user span {
        display: none;
    }

    .brand-full {
        width: 156px;
    }

    .sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar-collapsed .brand-full {
        display: block;
    }

    .sidebar-collapsed .brand-icon {
        display: none;
    }

    .sidebar-collapsed .nav-label {
        display: inline;
    }

    .sidebar-collapsed .side-nav a {
        justify-content: flex-start;
        padding: 0.65rem 0.8rem;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 0.7rem;
    }

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

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

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

    .notification-widget {
        right: 0.7rem;
        bottom: 0.7rem;
    }

    .notification-toast-stack {
        right: 0.7rem;
        bottom: 5rem;
        width: calc(100vw - 1.4rem);
    }

    .notification-fab {
        width: 52px;
        height: 52px;
    }
}
