﻿:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #eef3f8;
    --text: #172033;
    --muted: #647084;
    --line: #d9e1ec;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --sidebar-text: #e5e7eb;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --green: #0f766e;
    --green-soft: #ccfbf1;
    --red: #b42318;
    --red-soft: #fee4e2;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 0;
}

body {
    margin: 0;
    min-width: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.nav-toggle,
.nav-backdrop,
.hamburger,
.sidebar-close,
.mobile-logo {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 16px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow-y: auto;
    z-index: 40;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.brand-mark,
.mobile-logo {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    place-items: center;
    background: #f8fafc;
    color: #111827;
    font-weight: 800;
}

.brand-mark {
    display: grid;
}

.brand-name {
    font-size: 18px;
    font-weight: 800;
}

.brand-subtitle {
    color: #aab4c2;
    font-size: 12px;
    margin-top: 2px;
}

.sidebar-quick {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    margin: 0 0 18px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 650;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.sidebar-link.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-link.muted {
    color: #94a3b8;
}

.sidebar-link.disabled {
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.72;
}

.sidebar-link.disabled:hover {
    background: transparent;
    color: #64748b;
}

.content-shell {
    min-width: 0;
}

.content-topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 32px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.content-topbar strong {
    display: block;
    font-size: 21px;
}

.topbar-title {
    min-width: 0;
}

.topbar-kicker,
.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0;
}

.topbar-spacer {
    width: 120px;
    min-height: 1px;
}

.page {
    width: min(1280px, calc(100% - 48px));
    margin: 28px auto 56px;
}

.notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 650;
}

.notice.error {
    background: var(--red-soft);
    color: var(--red);
}

.notice.success {
    background: var(--green-soft);
    color: var(--green);
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.dashboard-hero h1,
.section-head h1,
.page h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.12;
}

.muted-text,
.dashboard-hero p,
.status-card p {
    color: var(--muted);
}

.primary-action,
button,
.button {
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    min-height: 48px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.button.secondary,
button.secondary {
    background: #e2e8f0;
    color: #1f2937;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 20px;
    align-items: start;
}

.dashboard-main {
    min-width: 0;
}

.today-panel {
    margin-bottom: 20px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.metric-card,
.card,
.panel,
.work-panel,
.status-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    display: grid;
    gap: 8px;
    padding: 18px;
    color: inherit;
    text-decoration: none;
    min-height: 138px;
}

.metric-card strong {
    font-size: 38px;
    line-height: 1;
}

.metric-card span:last-child {
    color: var(--muted);
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card.accent {
    border-color: #bfdbfe;
    background: linear-gradient(180deg, #ffffff 0%, var(--accent-soft) 100%);
}

.metric-card.danger {
    border-color: #fecaca;
}

.work-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.work-panel,
.status-card,
.panel,
.card,
.today-panel {
    padding: 18px;
}

.panel-head,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.panel-head h2,
.status-card h2,
.work-panel h2,
.today-panel h2 {
    margin: 0;
    font-size: 18px;
}

.panel-head a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

.focus-line {
    margin: 0;
    color: var(--text);
}

.empty-state,
.empty {
    margin: 0;
    color: var(--muted);
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 12px;
}

.status-rail {
    display: grid;
    gap: 14px;
}

.owner-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.owner-list span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: #314158;
    font-weight: 700;
}

.system-ok {
    border-color: #99f6e4;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.card strong {
    display: block;
    font-size: 32px;
    margin-top: 8px;
}

.form,
.inline-form,
.form-grid {
    display: grid;
    gap: 12px;
}

.form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.inline-form,
.search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    min-height: 48px;
    padding: 10px 12px;
    font: inherit;
}

textarea {
    resize: vertical;
}

.list-section {
    margin-top: 20px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--line);
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    background: #f8fafc;
    font-size: 13px;
}

tr:last-child td {
    border-bottom: 0;
}

.entry-list,
.project-list {
    display: grid;
    gap: 12px;
}

.entry-card,
.project-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow);
}

.entry-card small,
.project-row small,
.project-row em {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-style: normal;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 999px;
    background: var(--surface-soft);
    color: #314158;
    font-size: 12px;
    font-weight: 750;
}

a {
    color: var(--accent);
}

@media (max-width: 1080px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .status-rail {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    body {
        background: #f8fafc;
    }

    .app-shell {
        display: block;
    }

    .nav-backdrop {
        position: fixed;
        inset: 0;
        display: block;
        background: rgba(15, 23, 42, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease;
        z-index: 35;
    }

    .nav-toggle:checked ~ .nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 86vw);
        height: 100vh;
        padding: 18px;
        transform: translateX(-104%);
        transition: transform 180ms ease;
        border-right: 0;
        box-shadow: 24px 0 50px rgba(15, 23, 42, 0.22);
    }

    .nav-toggle:checked ~ .sidebar {
        transform: translateX(0);
    }

    .sidebar-close {
        margin-left: auto;
        width: 44px;
        height: 44px;
        display: grid;
        place-items: center;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.08);
        color: #ffffff;
        font-size: 28px;
        line-height: 1;
        cursor: pointer;
    }

    .sidebar-nav {
        display: grid;
        gap: 6px;
    }

    .sidebar-link,
    .sidebar-quick {
        min-height: 48px;
        font-size: 16px;
    }

    .content-topbar {
        min-height: 62px;
        padding: 0 14px;
        display: grid;
        grid-template-columns: 48px 42px minmax(0, 1fr);
        gap: 10px;
        justify-content: start;
    }

    .hamburger {
        width: 48px;
        height: 48px;
        display: grid;
        place-items: center;
        gap: 4px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
        cursor: pointer;
    }

    .hamburger span {
        width: 20px;
        height: 2px;
        display: block;
        background: var(--text);
        border-radius: 999px;
    }

    .mobile-logo {
        display: grid;
    }

    .topbar-kicker,
    .topbar-spacer,
    .dashboard-hero > div {
        display: none;
    }

    .content-topbar strong {
        font-size: 18px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page {
        width: 100%;
        margin: 0;
        padding: 16px 14px 36px;
    }

    .dashboard-hero {
        display: block;
        margin-bottom: 14px;
    }

    .primary-action {
        width: 100%;
        min-height: 52px;
        font-size: 17px;
    }

    .dashboard-layout,
    .dashboard-main,
    .work-grid,
    .status-rail {
        display: grid;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .today-panel,
    .work-panel,
    .status-card,
    .panel,
    .card {
        width: 100%;
        padding: 16px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .metric-card {
        min-height: 104px;
        padding: 16px;
    }

    .metric-card strong {
        font-size: 34px;
    }

    .work-grid {
        grid-auto-flow: row;
    }

    .today-work { order: 1; }
    .waiting-work { order: 2; }
    .ideas-work { order: 3; }
    .projects-work { order: 4; }

    .status-card.status-today,
    .status-card.status-owner {
        display: none;
    }

    .panel-head,
    .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-head a,
    .section-head a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .inline-form,
    .search-form,
    .form-grid {
        grid-template-columns: 1fr;
    }

    button,
    .button,
    input,
    select,
    textarea {
        min-height: 48px;
        font-size: 16px;
    }

    table,
    thead,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    table {
        background: transparent;
        border: 0;
        overflow: visible;
    }

    thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    tr {
        margin-bottom: 12px;
        padding: 14px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: var(--shadow);
    }

    td {
        display: grid;
        grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
        gap: 10px;
        padding: 9px 0;
        border-bottom: 1px solid var(--line);
        overflow-wrap: anywhere;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 800;
    }

    td a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        font-weight: 800;
    }

    .entry-card,
    .project-row {
        align-items: stretch;
        flex-direction: column;
        min-height: 112px;
    }

    .entry-card .button {
        width: 100%;
    }
}

@media (max-width: 430px) {
    .page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .today-panel,
    .work-panel,
    .status-card,
    .panel,
    .card,
    tr {
        padding: 14px;
    }

    .content-topbar {
        grid-template-columns: 46px 40px minmax(0, 1fr);
    }
}

@media (max-width: 360px) {
    .page {
        padding-left: 10px;
        padding-right: 10px;
    }

    td {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* V1.4 actions */
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.card-actions {
    justify-content: flex-end;
}

.stack-card {
    align-items: flex-start;
}

.entry-main {
    min-width: 0;
    flex: 1 1 260px;
}

.button.danger,
button.danger {
    background: var(--red);
    color: #ffffff;
}

.button.danger:hover,
button.danger:hover {
    background: #8f1d14;
    text-decoration: none;
}

.danger-panel {
    border-color: #fecaca;
}

.delete-preview {
    display: grid;
    gap: 6px;
    padding: 14px;
    margin: 14px 0;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: #fff7f7;
}

@media (max-width: 820px) {
    .action-row,
    .card-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .action-row .button,
    .action-row button,
    .card-actions .button,
    .card-actions button {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
    }
}
