/* ===
   V8: 最终美化版 (KPI Header Links)
=== */

/* 1. 全局和字体优化 */
html {
    font-size: 95%; 
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--pico-secondary-background);
}

body {
    background-color: var(--pico-secondary-background);
}

main.container {
    padding-top: var(--pico-spacing);
    padding-bottom: var(--pico-spacing); 
}

h1, h2, h3, h4, h5, h6 {
    color: var(--pico-h1-color);
    font-weight: 700;
}

/* 动效 */
a[role="button"], button,
article,
table tbody tr:hover,
form fieldset .grid label:hover {
    transition: all 0.2s ease-in-out;
}
a[role="button"]:not(.secondary):not(.outline),
button[type="submit"]:not(.secondary):not(.outline) {
    transform: translateY(0);
}
a[role="button"]:not(.secondary):not(.outline):hover,
button[type="submit"]:not(.secondary):not(.outline):hover {
    transform: translateY(-2px);
    box-shadow: var(--pico-box-shadow);
}


/* 2. 导航栏 (来自 V4/V7) */
nav.container-fluid {
    background-color: var(--pico-background-color);
    box-shadow: var(--pico-box-shadow);
    border-bottom: 1px solid var(--pico-muted-border-color);
}
nav.container-fluid ul li details[role="list"] {
    margin-bottom: 0;
}
nav.container-fluid ul li details[role="list"] summary {
    padding: 0.5rem 0.75rem;
}
nav .danger {
    color: var(--pico-color-red-600);
}
nav .danger:hover {
    color: var(--pico-color-red-700);
    background-color: var(--pico-color-red-50);
}
nav.container-fluid ul li a.contrast strong {
    font-size: 1.25rem; 
    display: inline-block;
    padding-top: 0.15rem; 
}
nav.container-fluid ul li:last-child {
    position: relative;
}
nav.container-fluid ul li details[role="list"] ul[role="listbox"] {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: 0;
    z-index: 1000; 
    background-color: var(--pico-background-color);
    border: 1px solid var(--pico-muted-border-color);
    box-shadow: var(--pico-box-shadow);
    border-radius: var(--pico-border-radius);
    width: 160px; 
}
nav.container-fluid ul li details[role="list"] ul[role="listbox"] li {
    width: 100%;
    text-align: right; 
}
nav.container-fluid ul li details[role="list"] ul[role="listbox"] li a.danger {
    justify-content: flex-end;
}
nav.container-fluid ul:nth-child(2) > li > a {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    margin: 0 0.25rem;
    border-radius: var(--pico-border-radius);
}
nav.container-fluid ul:nth-child(2) > li > a:hover {
    background-color: var(--pico-form-element-background-color);
}


/* 3. 卡片 (article) */
article {
    border: 1px solid var(--pico-muted-border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03), 
                0 1px 4px rgba(0, 0, 0, 0.02);
    border-radius: var(--pico-border-radius);
}
article header {
    border-bottom: 1px solid var(--pico-muted-border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
}
article footer {
    border-top: 1px solid var(--pico-muted-border-color);
    padding-top: 0.75rem;
    margin-top: 1rem;
}

/* 4. 表格样式 (Table) */
figure {
    border: none;
    padding: 0;
    margin-bottom: 0; 
    overflow-x: auto;
}
table {
    border-collapse: collapse;
}
table th {
    background-color: var(--pico-form-element-background-color);
    color: var(--pico-h5-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.05em;
}
table td, table th {
    padding: 0.75rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}
table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}
table tbody tr:last-child td {
    border-bottom: none;
}
.truncate {
    max-width: 350px; 
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
}
.no-wrap {
    white-space: nowrap;
}


/* 5. 表单和过滤器样式 */
form.filter-form,
form.search-form {
    background: var(--pico-form-element-background-color);
    padding: var(--pico-spacing);
    border-radius: var(--pico-border-radius);
    margin-bottom: var(--pico-spacing);
    border: 1px solid var(--pico-muted-border-color);
}
form.filter-form .grid,
form.search-form .grid {
    margin-bottom: 0;
}
form.filter-form label,
form.search-form label {
    margin-bottom: 0;
}
form.search-form .grid {
    grid-template-columns: 1fr auto; 
    gap: var(--pico-spacing);
}
form.search-form input[type="search"] {
    margin-bottom: 0;
}
form.search-form button {
    margin-bottom: 0;
}

/* 6. 登录页面 */
body#login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: var(--pico-secondary-background);
}
body#login-page article {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    border: 1px solid var(--pico-muted-border-color);
}
body#login-page h1 {
    text-align: center;
}

/* 7. 特定页面样式 */
.detail-list { 
    list-style: none; 
    padding-left: 0; 
}
.detail-list li { 
    margin-bottom: 0.5rem;
}
.detail-list li strong { 
    color: var(--pico-muted-color); 
    min-width: 100px; 
    display: inline-block;
}
.action-group { 
    display: flex; 
    gap: 0.5rem; 
}
.action-group a { 
    padding: 5px 10px;
    font-size: 0.8em; 
    margin: 0; 
}
.log-complete { 
    text-decoration: line-through; 
    color: var(--pico-muted-color);
}
.detail-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
.detail-header h2 { 
    margin-bottom: 0; 
}
.detail-header a { 
    width: auto;
}
.task-overdue { 
    color: var(--pico-color-red-600);
    font-weight: bold; 
}

/* 角色权限页面 (role_edit.php) */
article form fieldset .grid {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 0.5rem; 
}
article form fieldset .grid label {
    margin-bottom: 0;
    padding: 0.5rem;
    border-radius: var(--pico-border-radius);
    font-size: 0.9em; 
}
article form fieldset .grid label:hover {
    background-color: var(--pico-form-element-background-color);
}

/* [!!!] V8 新增：KPI卡片右上角链接 */
.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kpi-card-header h5 {
    margin-bottom: 0; 
}
.kpi-card-header a {
    font-size: 0.8em;
    margin: 0;
    padding: 5px 10px;
}