/* split from former app.css: shared */

:root {
    --bg: #f4f8fc;
    --bg-soft: #fbfdff;
    --panel: #ffffff;
    --panel-strong: #ffffff;
    --sidebar-bg: rgba(255, 255, 255, 0.84);
    --line: #d9e4ef;
    --line-strong: #c6d4e2;
    --text: #1f2d3d;
    --text-soft: #64748b;
    --text-faint: #94a3b8;
    --accent: #2e7cf6;
    --accent-strong: #1f6ae0;
    --accent-soft: rgba(46, 124, 246, 0.1);
    --success: #1f8b5f;
    --warning: #b7791f;
    --danger: #c24141;
    --shadow: 0 18px 36px rgba(15, 23, 42, 0.06);
    --shadow-soft: 0 6px 16px rgba(15, 23, 42, 0.04);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --font-body: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-display: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: var(--font-body);
    background:
            radial-gradient(circle at top left, rgba(46, 124, 246, 0.08), transparent 32%),
            linear-gradient(180deg, #f9fbfe 0%, #f3f7fb 100%);
}

body.is-scroll-locked {
    overflow: hidden;
}

body.has-mobile-nav::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.36);
    backdrop-filter: blur(2px);
}

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

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

textarea {
    resize: vertical;
}

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

.app-sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100vh;
    padding: 24px 18px;
    color: var(--text);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.app-sidebar::after {
    display: none;
}

.brand-lockup {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1.55rem;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.sidebar-section {
    flex: 1;
    margin-top: 0;
}

.sidebar-label {
    margin-bottom: 12px;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.nav-links {
    display: grid;
    gap: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    border-color: rgba(46, 124, 246, 0.12);
    background: rgba(46, 124, 246, 0.08);
    color: var(--accent-strong);
}

.nav-link small {
    color: var(--text-faint);
}

.sidebar-footer {
    display: none;
}

.app-main {
    padding: 24px 26px 28px;
}

.app-main--pinned {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

.page-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.page-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
}

.app-main--pinned .page-header,
.app-main--pinned .toolbar,
.app-main--pinned .hero-metrics,
.app-main--pinned .issue-filter-panel {
    flex: 0 0 auto;
}

.app-main--pinned .page-header {
    position: sticky;
    top: 0;
    z-index: 40;
}

.project-list-grid,
.role-list-grid,
.dashboard-content-grid {
    align-content: start;
}

.issue-list-panel,
.user-list-panel {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.issue-list-panel .surface__body,
.user-list-panel .surface__body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.issue-list-panel .table-wrap,
.user-list-panel .table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-soft);
}

.page-header > :first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.page-header__title {
    min-width: 0;
    flex: 1 1 auto;
}

.page-header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.7rem, 1.2vw + 1.2rem, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.page-header h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(1.35rem, 1vw + 1rem, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.topbar-actions {
    align-items: center;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-self: flex-start;
}

.topbar-menu {
    position: relative;
}

.icon-button,
.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    cursor: pointer;
}

.icon-button {
    position: relative;
    justify-content: center;
    width: 42px;
    padding: 0;
}

.user-menu-trigger {
    gap: 12px;
    min-height: 44px;
    padding: 0 8px 0 4px;
    border: none;
    background: transparent;
    box-shadow: none;
}

.user-menu-trigger:hover {
    box-shadow: none;
    background: rgba(245, 248, 252, 0.9);
}

.icon-button svg,
.user-menu-trigger svg {
    width: 18px;
    height: 18px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #d6d7db;
    color: #ffffff;
    font-size: 0.82rem;
    font-weight: 700;
    overflow: hidden;
}

.topbar-menu--user .user-avatar {
    display: none;
}

.user-avatar img,
.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-meta {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.user-name {
    max-width: 116px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.98rem;
    font-weight: 600;
}

.user-role {
    color: var(--text-faint);
    font-size: 0.9rem;
    white-space: nowrap;
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    display: none;
    width: 320px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.topbar-menu.is-open .dropdown-panel {
    display: block;
}

.dropdown-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 4px 10px;
}

.empty-state--compact {
    padding: 18px 12px;
}

.user-dropdown {
    width: 200px;
}

.dropdown-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.dropdown-link svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.dropdown-link:hover {
    background: #f5f8fc;
}

.dropdown-link--danger {
    color: var(--danger);
}

.page-grid {
    display: grid;
    gap: 20px;
}

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

.page-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.surface {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

.surface__header,
.surface__body,
.surface__footer {
    position: relative;
}

.surface__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
}

.surface__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.surface__meta {
    margin-top: 6px;
    color: var(--text-soft);
    line-height: 1.7;
    font-size: 0.92rem;
}

.surface__body {
    padding: 0 20px 20px;
}

.surface__footer {
    padding: 14px 20px 20px;
}

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

.metric-card {
    padding: 20px;
}

.metric-card--compact {
    padding: 16px 18px;
    border-radius: 16px;
}

.metric-card--compact .metric-label {
    font-size: 0.8rem;
    letter-spacing: 0.06em;
}

.metric-card--compact .metric-value {
    margin-top: 8px;
    font-size: clamp(1.65rem, 1.8vw, 2.15rem);
    line-height: 1.1;
}

.metric-card--inline {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.metric-card--inline .metric-label,
.metric-card--inline .metric-value {
    margin-top: 0;
    white-space: nowrap;
}

.metric-card--inline .metric-label {
    flex: 1 1 auto;
    text-transform: none;
    letter-spacing: 0.02em;
}

.metric-card--inline .metric-value {
    flex: 0 0 auto;
    font-size: clamp(1.3rem, 1.8vw, 1.8rem);
    line-height: 1;
}

.metric-label {
    color: var(--text-soft);
    font-size: 0.88rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.metric-value {
    margin-top: 10px;
    font-size: clamp(1.85rem, 2.2vw, 2.6rem);
    font-weight: 800;
    color: var(--accent-strong);
}

.metric-note {
    margin-top: 8px;
    color: var(--text-soft);
    line-height: 1.6;
    font-size: 0.9rem;
}

.list-stack,
.meta-stack {
    display: grid;
    gap: 14px;
}

.project-card,
.activity-item,
.ticket-row,
.user-card,
.role-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid #e7eef5;
    border-radius: 16px;
    background: #f8fbff;
}

.ticket-row__top,
.project-card__top,
.user-card__top,
.role-card__top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.entity-title {
    font-weight: 800;
}

.entity-subtitle {
    color: var(--text-soft);
    font-size: 0.92rem;
    line-height: 1.7;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.meta-pill,
.badge,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    background: #f2f7fc;
    color: var(--text-soft);
    font-size: 0.85rem;
    line-height: 1;
    white-space: nowrap;
}

.badge--slate {
    background: rgba(76, 97, 112, 0.12);
    color: #4c6170;
}

.badge--blue {
    background: rgba(34, 100, 176, 0.12);
    color: #225ea9;
}

.badge--indigo {
    background: rgba(76, 73, 161, 0.12);
    color: #4c49a1;
}

.badge--amber {
    background: rgba(183, 123, 9, 0.12);
    color: #9d6805;
}

.badge--orange {
    background: rgba(217, 99, 54, 0.12);
    color: var(--accent-strong);
}

.badge--green {
    background: rgba(29, 122, 85, 0.12);
    color: var(--success);
}

.badge--red {
    background: rgba(163, 59, 43, 0.12);
    color: var(--danger);
}

.badge--zinc {
    background: rgba(91, 99, 105, 0.1);
    color: #4d585f;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.toolbar__group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.btn--primary {
    color: #ffffff;
    background: var(--accent);
    box-shadow: none;
}

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

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

.btn--danger {
    color: #ffffff;
    background: var(--danger);
    box-shadow: none;
}

.btn--block {
    width: 100%;
}

.btn--small {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.92rem;
}

.table-wrap {
    overflow: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 16px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.table th {
    color: var(--text-soft);
    font-size: 0.86rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: #f8fbff;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table td:not(:first-child) {
    word-break: keep-all;
}

.table td .entity-title {
    display: inline-block;
    white-space: nowrap;
}

.table td .entity-subtitle {
    display: -webkit-box;
    overflow: hidden;
    line-height: 1.6;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.table td .badge,
.table td .meta-pill,
.table td .chip,
.table td .timeline-time,
.table td .btn {
    white-space: nowrap;
}

.table td:last-child {
    min-width: 168px;
}

.table td:last-child .table-actions {
    flex-wrap: nowrap;
}

.project-card__top > div,
.ticket-row__top > div,
.todo-item__main,
.notification-item__main,
.file-attachment-item__main {
    min-width: 0;
}

.project-card .surface__title,
.project-card .entity-title,
.ticket-row .entity-title,
.file-attachment-name {
    word-break: break-word;
}

.meta-row > .meta-pill,
.meta-row > .badge,
.meta-row > .chip {
    white-space: nowrap;
}

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

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

.field {
    display: grid;
    gap: 10px;
}

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

.field label {
    font-weight: 700;
}

.field small {
    color: var(--text-soft);
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border: 1px solid rgba(25, 36, 46, 0.12);
    border-radius: 12px;
    background: #ffffff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.textarea {
    min-height: 140px;
}

.input:focus,
.select:focus,
.textarea:focus,
.rich-editor__canvas:focus {
    border-color: rgba(217, 99, 54, 0.5);
    box-shadow: 0 0 0 4px rgba(217, 99, 54, 0.12);
}

.error-text {
    color: var(--danger);
    font-size: 0.9rem;
}

.error-panel {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid rgba(163, 59, 43, 0.18);
    background: rgba(163, 59, 43, 0.08);
    color: #7f3024;
}

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

.checkbox-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #f8fbff;
}

.checkbox-card input {
    margin-top: 4px;
}

.detail-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
}

.detail-prose > * {
    max-width: 100%;
}

.detail-prose h1,
.detail-prose h2,
.detail-prose h3,
.detail-prose h4 {
    font-family: var(--font-display);
}

.detail-prose blockquote {
    margin: 0;
    padding-left: 16px;
    border-left: 3px solid rgba(217, 99, 54, 0.4);
    color: var(--text-soft);
}

.detail-prose img {
    display: block;
    float: none !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: min(70vh, 560px);
    margin: 12px auto !important;
    border-radius: 10px;
    border: 1px solid #e7eef5;
    object-fit: contain;
}

.meta-stack {
    gap: 10px;
}

.timeline {
    display: grid;
    gap: 0;
}

.timeline--compact {
    gap: 0;
    position: relative;
}

.timeline--compact::before {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 8px;
    width: 1px;
    background: var(--line);
}

.timeline-item {
    position: relative;
    padding: 16px 16px 16px 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
}

.timeline-item::before {
    content: "";
    position: absolute;
    top: 18px;
    left: 10px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-item strong {
    display: block;
    margin-bottom: 6px;
}

.timeline-item p {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.8;
}

.timeline-item--compact {
    padding: 10px 0 10px 24px;
    border: none;
    border-bottom: 1px solid #edf2f7;
    border-radius: 0;
    background: transparent;
}

.timeline-item--compact::before {
    top: 16px;
    left: 4px;
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 3px #ffffff;
}

.timeline-item--compact strong {
    margin-bottom: 2px;
    font-size: 0.92rem;
    font-weight: 700;
}

.timeline-item__line {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    min-width: 0;
}

.timeline-item__actor {
    color: var(--text-faint);
    font-size: 0.8rem;
    line-height: 1.3;
    white-space: nowrap;
}

.timeline-item__summary {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-soft);
    min-width: 0;
    word-break: break-word;
}

.timeline-item__note {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-soft);
    flex: 1 1 100%;
    min-width: 0;
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.timeline-item--compact:last-child {
    border-bottom: none;
}

.timeline-item--hidden {
    display: none;
}

.timeline-actions {
    margin-top: 10px;
}

.timeline-time {
    color: var(--text-faint);
    font-size: 0.78rem;
    white-space: nowrap;
}

.hint-panel p {
    margin: 6px 0 0;
    color: var(--text-soft);
    line-height: 1.8;
}

.toast-stack {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1200;
    display: grid;
    gap: 12px;
    width: min(360px, calc(100vw - 32px));
}

.toast {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.toast--success {
    border-color: rgba(29, 122, 85, 0.18);
}

.toast--error {
    border-color: rgba(163, 59, 43, 0.18);
}

.toast__marker {
    width: 12px;
    height: 12px;
    margin-top: 5px;
    border-radius: 50%;
    background: var(--accent);
}

.toast--success .toast__marker {
    background: var(--success);
}

.toast--error .toast__marker {
    background: var(--danger);
}

.toast__close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
}

.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(31, 45, 61, 0.18);
    backdrop-filter: blur(6px);
    overflow-y: auto;
}

.dialog-overlay.is-open {
    display: grid;
}

.dialog {
    width: min(460px, 100%);
    max-height: calc(100vh - 48px);
    padding: 22px;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow: auto;
}

.dialog h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.35rem;
}

.dialog p {
    margin: 14px 0 0;
    color: var(--text-soft);
    line-height: 1.8;
}

.dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 22px;
}

.dialog-close {
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 1rem;
}

.mobile-toggle {
    display: none;
}

.table td::before {
    content: none;
}

.empty-state {
    padding: 32px 22px;
    text-align: center;
    color: var(--text-soft);
}

.empty-state strong {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
}

.stat-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

@media (max-width: 1200px) {
    .hero-metrics,
    .page-grid.three,
    .page-grid.two,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

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

    .app-sidebar {
        position: fixed;
        top: 86px;
        left: 18px;
        right: 18px;
        z-index: 90;
        display: flex;
        min-height: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: calc(100vh - 110px);
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: var(--shadow);
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        overflow: auto;
        transition: opacity 0.22s ease, transform 0.22s ease;
    }

    .app-sidebar.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .brand-lockup {
        display: none;
    }

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

    .sidebar-label {
        margin-bottom: 10px;
        font-size: 0.72rem;
        letter-spacing: 0.08em;
    }

    .nav-links {
        gap: 8px;
    }

    .nav-link {
        padding: 12px 14px;
        border-radius: 12px;
    }

    .mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        font-size: 0;
        border-radius: 12px;
    }

    .mobile-toggle::before {
        content: "≡";
        font-size: 1.1rem;
        line-height: 1;
        color: var(--text);
    }

    .app-main {
        padding: 20px 18px 24px;
    }

    .app-main--pinned {
        height: 100vh;
        min-height: 100vh;
    }

    .page-scroll {
        padding-right: 0;
    }

    .page-header {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        align-items: stretch;
    }

    .page-header__title {
        order: 2;
        min-width: 0;
    }

    .topbar-actions {
        order: 1;
        width: 100%;
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center;
        gap: 10px;
    }

    .topbar-menu {
        min-width: 0;
    }

    .topbar-menu--notifications {
        order: 2;
        grid-column: 1;
        justify-self: start;
    }

    .topbar-menu--user {
        order: 1;
        grid-column: 2;
        width: 100%;
        min-width: 0;
    }

    .mobile-toggle {
        order: 3;
        grid-column: 3;
        justify-self: end;
    }

    .topbar-menu .dropdown-panel {
        position: fixed;
        top: 138px;
        left: 18px;
        right: 18px;
        width: auto;
        margin-top: 0;
        max-height: calc(100vh - 160px);
        overflow: auto;
    }

    .topbar-menu--user .user-menu-trigger {
        width: 100%;
        max-width: none;
        justify-content: center;
        gap: 10px;
        min-height: 44px;
        padding: 0 6px;
        border: none;
        background: transparent;
    }

    .topbar-menu--user .user-menu-trigger svg:last-child {
        display: none;
    }

    .topbar-menu--user .user-meta {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        justify-content: center;
        min-width: 0;
    }

    .topbar-menu--user .user-name {
        max-width: 100%;
        font-size: 0.94rem;
        line-height: 1.15;
    }

    .topbar-menu--user .user-role {
        font-size: 0.74rem;
    }

    .topbar-menu--user .user-role {
        display: none;
    }

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

    .notification-dropdown,
    .user-dropdown {
        width: auto;
    }

    .timeline-item__line {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .timeline-item__actor,
    .timeline-item__note {
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }
}

@media (max-width: 640px) {
    .app-main,
    .login-shell {
        padding: 18px;
    }

    .page-header,
    .surface__header,
    .surface__body,
    .surface__footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .page-actions,
    .toolbar__group,
    .table-actions,
    .dialog__actions {
        width: 100%;
    }

    .topbar-actions {
        justify-content: stretch;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }

    .topbar-menu,
    .user-menu-trigger {
        width: 100%;
    }

    .icon-button {
        width: 44px;
        justify-content: center;
    }

    .page-header {
        padding-top: 14px;
        padding-bottom: 16px;
    }

    .page-header__title h1,
    .page-header__title h2 {
        font-size: clamp(1.15rem, 5vw, 1.45rem);
        line-height: 1.28;
    }

    .page-actions .btn,
    .toolbar__group .btn,
    .dialog__actions .btn {
        flex: 1;
    }

    .hero-metrics,
    .dashboard-metrics--three {
        grid-template-columns: 1fr;
    }

    .metric-card,
    .metric-card--compact {
        padding: 16px;
    }

    .metric-card--inline {
        gap: 8px;
    }

    .metric-label {
        font-size: 0.76rem;
        letter-spacing: 0.05em;
    }

    .metric-value {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    .metric-card--inline .metric-label {
        font-size: 0.8rem;
        letter-spacing: 0.02em;
    }

    .metric-card--inline .metric-value {
        font-size: clamp(1.18rem, 5vw, 1.45rem);
    }

    .toolbar,
    .toolbar__group,
    .issue-filter-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .table-wrap {
        overflow: visible;
    }

    .surface > .surface__header {
        flex-direction: column;
        align-items: stretch;
    }

    .surface > .surface__header .page-actions,
    .surface > .surface__header .table-actions {
        width: 100%;
    }

    .table,
    .table thead,
    .table tbody,
    .table tr,
    .table th,
    .table td {
        display: block;
        width: 100%;
    }

    .table thead {
        display: none;
    }

    .table tbody {
        display: grid;
        gap: 12px;
    }

    .table tbody tr {
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: #ffffff;
        box-shadow: var(--shadow-soft);
    }

    .table td {
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 8px 0;
        border-bottom: 1px dashed #e7eef5;
        min-width: 0;
    }

    .table td:last-child {
        border-bottom: none;
    }

    .table td::before {
        content: attr(data-label);
        display: block;
        color: var(--text-faint);
        font-size: 0.76rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        line-height: 1.2;
    }

    .table td:not([data-label])::before {
        content: "";
    }

    .table td .entity-title,
    .table td .entity-subtitle,
    .table td .btn,
    .table td .table-actions {
        white-space: normal;
    }

    .table td .meta-pill,
    .table td .badge,
    .table td .chip {
        width: fit-content;
        max-width: 100%;
        white-space: nowrap;
    }

    .table-actions {
        width: 100%;
    }

    .table-actions .btn,
    .table-actions form {
        width: 100%;
    }

    .table-actions form .btn {
        width: 100%;
    }

    .detail-grid,
    .issue-detail-grid,
    .page-grid.two,
    .page-grid.three {
        grid-template-columns: 1fr;
    }

    .page-grid.two > .surface,
    .page-grid.three > .surface {
        min-width: 0;
    }

    .page-grid.two > .surface .meta-row,
    .page-grid.three > .surface .meta-row {
        flex-direction: column;
        align-items: stretch;
    }

    .page-grid.two > .surface .meta-pill,
    .page-grid.two > .surface .badge,
    .page-grid.two > .surface .chip,
    .page-grid.three > .surface .meta-pill,
    .page-grid.three > .surface .badge,
    .page-grid.three > .surface .chip {
        width: 100%;
        justify-content: space-between;
    }

    .project-panel .surface__header {
        align-items: flex-start;
    }

    .project-panel .surface__header .badge {
        display: none;
    }

    .project-panel .surface__title {
        font-size: 1.08rem;
        line-height: 1.18;
    }

    .project-panel .surface__meta {
        font-size: 0.8rem;
        line-height: 1.3;
    }

    .project-panel .surface__body > .entity-subtitle {
        font-size: 0.88rem;
        line-height: 1.42;
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .project-panel .surface__body > .meta-row {
        display: none;
    }

    .project-panel .surface__footer .table-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .project-panel .surface__footer .table-actions .btn,
    .project-panel .surface__footer .table-actions form,
    .project-panel .surface__footer .table-actions form .btn {
        width: 100%;
        min-width: 0;
    }

    .role-panel .surface__header {
        align-items: flex-start;
    }

    .role-panel .surface__title {
        font-size: 1.08rem;
        line-height: 1.18;
    }

    .role-panel .surface__meta {
        font-size: 0.8rem;
        line-height: 1.3;
    }

    .role-panel .surface__body > .entity-subtitle {
        font-size: 0.88rem;
        line-height: 1.42;
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .role-panel .surface__header .table-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .role-panel .surface__header .table-actions .btn,
    .role-panel .surface__header .table-actions form,
    .role-panel .surface__header .table-actions form .btn {
        width: 100%;
        min-width: 0;
    }

    .dialog {
        width: min(100%, 100%);
        max-height: calc(100vh - 24px);
        padding: 18px;
    }

    .dialog-overlay {
        padding: 12px;
    }
}

@media (max-width: 960px) {
    .page-header__title {
        order: 2;
    }

    .topbar-actions {
        order: 1;
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    .topbar-menu {
        min-width: 0;
    }

    .topbar-menu--user {
        order: 1;
        grid-column: 2;
        width: 100%;
        min-width: 0;
    }

    .topbar-menu--notifications {
        order: 2;
        grid-column: 1;
        justify-self: start;
    }

    .topbar-menu--user .user-menu-trigger {
        width: 100%;
        max-width: none;
        justify-content: center;
        gap: 10px;
        min-height: 44px;
        padding: 0 6px;
        border: none;
        background: transparent;
    }

    .topbar-menu--user .user-menu-trigger svg:last-child {
        display: none;
    }

    .topbar-menu--user .user-meta {
        flex-direction: row;
        align-items: center;
        gap: 6px;
        justify-content: center;
        min-width: 0;
    }

    .topbar-menu--user .user-name {
        max-width: 100%;
        font-size: 0.94rem;
        line-height: 1.15;
    }

    .topbar-menu--user .user-role {
        font-size: 0.74rem;
    }

    .mobile-toggle {
        order: 3;
        grid-column: 3;
        justify-self: end;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        font-size: 0;
        border-radius: 12px;
    }

    .mobile-toggle::before {
        content: "≡";
        font-size: 1.1rem;
        line-height: 1;
        color: var(--text);
    }

    .topbar-menu .dropdown-panel {
        position: fixed;
        top: 138px;
        left: 18px;
        right: 18px;
        width: auto;
        margin-top: 0;
        max-height: calc(100vh - 160px);
        overflow: auto;
    }

    .notification-dropdown,
    .user-dropdown {
        width: auto;
    }

    .app-sidebar {
        top: 86px;
        left: 18px;
        right: 18px;
        z-index: 90;
        min-height: 0;
        width: auto;
        max-width: none;
        height: auto;
        max-height: calc(100vh - 110px);
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.96);
        transform: translateY(-8px);
        opacity: 0;
        pointer-events: none;
        overflow: auto;
        transition: opacity 0.22s ease, transform 0.22s ease;
    }

    .app-sidebar.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .brand-lockup {
        display: none;
    }

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

    .sidebar-label {
        margin-bottom: 10px;
        font-size: 0.72rem;
        letter-spacing: 0.08em;
    }

    .nav-links {
        gap: 8px;
    }

    .nav-link {
        padding: 12px 14px;
        border-radius: 12px;
    }
}

@media (max-width: 640px) {
    .page-header {
        padding-top: 14px;
        padding-bottom: 16px;
    }

    .page-header__title h1,
    .page-header__title h2 {
        font-size: clamp(1.15rem, 5vw, 1.45rem);
        line-height: 1.28;
    }

    .topbar-actions {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
    }

    .topbar-menu,
    .user-menu-trigger {
        width: 100%;
    }

    .icon-button {
        width: 44px;
    }
}

@media (max-width: 960px) {
    .page-header {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-areas:
        "topbar"
        "title";
        gap: 12px !important;
        align-items: stretch !important;
    }

    .page-header__title {
        grid-area: title;
        order: initial !important;
        min-width: 0;
    }

    .topbar-actions {
        grid-area: topbar;
        order: initial !important;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto auto !important;
        align-items: center !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .topbar-menu--user {
        order: initial !important;
        grid-column: 1;
        width: 100% !important;
        min-width: 0 !important;
    }

    .topbar-menu--notifications {
        order: initial !important;
        grid-column: 2;
        justify-self: end !important;
    }

    .mobile-toggle {
        order: initial !important;
        grid-column: 3;
        justify-self: end !important;
    }

    .topbar-menu--user .user-menu-trigger {
        display: flex !important;
        width: 100% !important;
        min-height: 44px;
        padding: 0 4px !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 8px !important;
        border: none !important;
        background: transparent !important;
    }

    .topbar-menu--user .user-avatar {
        flex: 0 0 auto;
        width: 34px;
        height: 34px;
    }

    .topbar-menu--user .user-meta {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 6px !important;
        min-width: 0 !important;
    }

    .topbar-menu--user .user-name {
        max-width: 92px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .topbar-menu--user .user-role {
        display: none !important;
    }
}
