/** common styles **/

:root {
    /* --- 品牌蓝色调 --- */
    --primary-blue: #007aff;
    --primary-hover: #0056b3;
    --primary-light: #e6f0ff;

    /* --- Body 基础背景 --- */
    /* 使用微弱的蓝灰色，增加高级感并衬托出上层元素 */
    --body-bg-color: #f2f4f7;

    /* --- 子元素（Form, Table）背景与边框 --- */
    /* 容器使用纯白，与 body 形成明度差 */
    --bg-color: #ffffff;
    --bg-even-color: #ffffff;
    --bg-odd-color: #f9fafb;
    /* 用于表格隔行换色 */
    --bg-selected-color: var(--primary-light);
    --border-color: #dce2e8;

    /* --- 文字与链接 --- */
    --text-color: #1d1d1f;
    --text-selected-color: var(--primary-blue);
    --link-selected-color: var(--primary-blue);
    --link-hover-color: var(--primary-hover);

    /* --- 表单元素 --- */
    --input-bg-color: #ffffff;
    --input-text-color: #1d1d1f;
    --input-border-color: #ced4da;
}

[data-theme="dark"] {
    /* --- 品牌蓝 (深色模式稍作提亮) --- */
    --primary-blue: #409eff;
    --primary-hover: #66b1ff;
    --primary-light: rgba(64, 158, 255, 0.15);

    /* --- Body 基础背景 --- */
    /* 最底层使用最深的色调 */
    --body-bg-color: #0b0e12;

    /* --- 子元素背景与边框 --- */
    /* 容器层级稍高，颜色比 body 略浅一点 */
    --bg-color: #181c22;
    --bg-even-color: #181c22;
    --bg-odd-color: #1d2228;
    --bg-selected-color: #262c36;
    --border-color: #2d333b;

    /* --- 文字与链接 --- */
    --text-color: #e6edf3;
    --text-selected-color: var(--primary-blue);
    --link-selected-color: var(--primary-blue);
    --link-hover-color: var(--primary-hover);

    /* --- 表单元素 --- */
    --input-bg-color: #181c22;
    --input-text-color: #e6edf3;
    --input-border-color: #444c56;
}

body {
    background-color: var(--body-bg-color);
    color: var(--text-color);
    /* 增加行高，提升易读性 */
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 让表单或表格容器“浮”起来 */
.table-container {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    /* 圆角增加现代感 */
    padding: 20px;
    /* 浅色模式下增加微弱投影，深色模式下主要靠边框 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

input,
select,
textarea {
    font-size: 14px;
    padding: 6px 12px;
    background: var(--input-bg-color);
    color: var(--input-text-color);
    border: 1px solid var(--input-border-color);
    border-radius: 4px;
    outline: none;
    transition: all 0.2s ease;
}

/* 焦点态：表单与主色调呼应 */
input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

* {
    padding: 0;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", STHeiti, "Microsoft Yahei", Tahoma, Simsun, sans-serif;
}

select,
option,
button,
input[type="button" i],
input[type="submit" i],
input[type="reset" i],
input[type="file" i]::-webkit-file-upload-button {
    cursor: pointer;
}

a {
    color: var(--text-color);
}

a:hover {
    color: var(--link-hover-color);
}

label {
    cursor: pointer;
}

.float_left {
    float: left;
}

.nosee {
    visibility: hidden;
}

.noshow {
    display: none;
}

.v {
    background: var(--bg-color);
}

.fsize12 {
    font-size: 0.9em;
}

.clear {
    clear: both;
}

input.input_cb {
    border: none;
}

input.price:before {
    content: "\f157";
}

input.price {
    text-align: center;
    color: var(--link-selected-color);
}

.change_btn {
    cursor: pointer;
}

#loading {
    position: fixed;
    top: 23px;
    right: 0;
    display: ;
    background: #ccc;
    padding: 2px 8px;
    z-index: 99;
}

hr {
    border-top: 1px solid #f3f3f3;
}

.flex_outline {
    display: flex;
}

.flex_outline>* {
    width: 44%;
}

/** nav styles **/

ul#nav {
    list-style-type: none;
    padding-left: 2em;
}

ul#nav li {
    padding: .5em .5em;
    margin: .1em .1em 0;
    text-align: center;
    float: left;
    cursor: pointer;
    border-radius: .25em .25em 0 0;
}

ul#nav liaside>dl_on {
    background-color: var(--bg-color);
}

ul#nav li.onselected {
    background-color: var(--bg-color);
    color: var(--link-selected-color);
    font-weight: bold;
    border-radius: .25em .25em 0 0;
}

ul#nav li.onhovered {
    color: var(--link-hover-color);
}


/** main contents styles **/

aside {
    flex: 0 0 16em;
}

aside>dl a {
    text-decoration: none;
}

aside>dl dt,
aside>dl dd {
    margin: 0 5px;
}

aside>dl dt {
    cursor: pointer;
    text-align: center;
    padding: .5em 0;
    margin-top: .3em;
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: .25em .25em 0 0;
    border: 1px solid var(--border-color);
}

aside>dl dd {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-top: none;
    text-align: center;
    padding: .8em 0;
}

#money_month_selector input,
#report_month_selector input {
    text-align: center;
    color: var(--text-color);
}

#money_month_selector .fa-calendar {
    position: absolute;
    top: .5em;
}

#money_month_selector input {
    padding: .2em 0em .2em 1.2em;
    background: transparent;
    border: none;
    width: 5.3em;
}

#report_fliters a {
    line-height: 2em;
    padding: .4em .9em .4em 0;
}

#report_fliters a.selected {
    color: var(--link-selected-color);
}

#report_fliters a.selected {
    color: var(--link-selected-color);
}


.op_tool,
.op_tool li {
    margin: .5em 0;
    padding: 0 0 0 0px;
    list-style: none;
    text-align: center;
}

.amount {
    display: flex;
    flex-direction: row;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-bottom: none;
    text-align: center;
    padding: .3em 0;
    margin-top: .3em;
    border-radius: .25em .25em 0 0;
}

.amount li {
    line-height: 2em;
    padding: 0;
    margin: 0;
    list-style: none;
}

.amount li:first-child {
    flex-basis: 50%;
    text-align: left;
    padding-left: .75em;
}

.amount li:last-child {
    flex-basis: 50%;
    text-align: right;
    padding-right: .75em;
    position: relative;
}

.amount #month_total {
    margin-right: .5em;
}

.amount .fa-calendar-check,
.amount #selected_total {
    color: var(--link-selected-color);
}

.type_sec li {
    font-size: 0.9em;
    text-align: left;
    padding: .4em 1em;
    list-style: none;
}

.type_sec a:hover {
    color: var(--link-hover-color);
}

.type_sec a.selected {
    color: var(--link-selected-color);
}

.type_sec li a {
    text-decoration: none;
}

.type_sec p {
    text-align: left;
    padding-top: 1em;
    padding: .5em 1.5em;
}

#selected_qd li {
    font-size: .8em;
}

dd#report_year_selector {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

dd#report_year_selector span {
    line-height: 2em;
    padding: .4em .9em;
}

dd#report_year_selector span.selected a {
    color: var(--link-selected-color);
}

/* table styles */

table.table_list {
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    width: 100%;
}

table.table_list th,
table.table_list td {
    padding: .3em .3em;
}

table.month_report_list,
table.qd_list {
    margin-top: 5px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    /* 圆角增加现代感 */
    padding: 4px;
    /* 浅色模式下增加微弱投影，深色模式下主要靠边框 */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

table.month_report_list thead {
    background: var(--bg-color);
}

table.month_report_list tbody th {}

table.month_report_list tbody td:last-child {}

table.month_report_list thead th:first-child {
    border-radius: .25em 0 0 0;
}

table.month_report_list thead th:last-child {
    border-radius: 0 .25em 0 0;
}

table.month_report_list td {
    padding: .3em .3em;
    line-height: 1.6em;
}

table.table_list td.price {
    text-align: right;
    padding: 0 .3em;
}

table.table_list td.description {
    white-space: nowrap;
    font-size: clamp(12px, 2vw, 14px);
}

table.table_list td:last-child {
    padding: 0 .3em;
}

table.table_list caption {
    display: none;
}

table.table_list thead {
    color: var(--text-color);
}

table.table_list thead th {
    padding: .5em 0;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
}

#type_summary_list tbody tr:hover {
    background: var(--bg-selected-color);
}

tr.sel th,
tr.sel td {
    color: var(--text-selected-color);
}

.nosel {
    width: 3em;
    text-align: right;
    border-left: 1px solid var(--border-color);
    background: transparent !important;
}

tr.even {
    background: var(--bg-even-color);
    ;
}

tr.odd {
    background: var(--bg-odd-color);
}

/** form styles **/

.form-div {
    border-top: 1px solid var(--border-color);
    padding-top: 5px;
}

.add_form>div {
    margin-bottom: .5em;
}

.add_form a {
    text-decoration: none;
    padding: .2em .5em;
    margin-left: .1em;
    margin-bottom: .2em;
    border-radius: .25em;
}

.add_form #add_date {
    text-align: center;
}

#data_input_td a,
#add_description_suggest a,
#add_price_suggest a {
    text-decoration: none;
    background: var(--bg-color);
    padding: .5em;
    margin-right: .5em;
    margin-bottom: .5em;
}

#add_description_suggest a {
    padding: 4px 6px;
    border: 1px solid var(--border-color);
}

#add_price_suggest a {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
}

#add_description_suggest {
    background: var(--bg-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#add_price_keyboard {
    background: var(--bg-color);
}

#add_price_suggest {
    width: 12em;
    margin: .5em auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#data_input_td a:hover,
#add_description_suggest a:hover,
#add_price_suggest a:hover {
    color: var(--link-hover-color);
}

#userInfo {
    position: absolute;
    top: 3px;
    right: 8px;
    padding: 5px;
    text-align: right;
}

/* login & regs form */


#login_form,
#reg_form {
    margin: 1em 2em;
}

#login_form p,
#reg_form p {
    margin-top: .5em;
}



/* New Flex layout */

body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

nav {
    margin: 0;
    background-color: var(--bg-color);
    ;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
}

#out-round {
    display: flex;
    flex: 0 0 auto;
    overflow: auto;
}

main {
    flex: 0 0 28em;
}

aside#addbar {
    flex: 0 0 16em;
}

aside#sidebar {
    flex: 0 0 14em;
}

footer {
    color: #555;
    text-align: right;
    background: var(--bg-color);
    font-style: italic;
    margin-top: 5px;
    padding: 0.5em;
    border-top: 1px solid var(--border-color);
}

nav,
footer {
    flex: 0 0 20px;
}

.fliter_list li {
    list-style: none;
    text-align: left;
    padding: 2% 0 2% 5%;
}

.fliter_list li:last-child {
    border-bottom: none;
}

#selected_type form div,
#selected_qd form div {
    margin-top: 5%;
}

#selected_type ul,
#selected_qd ul {
    margin-bottom: 5%;
}

#selected_type form div,
#selected_qd form div,
#selected_type ul li>a {
    display: flex;
    flex-wrap: wrap;
}

#search_form input[type=date] {
    width: 92%;
    margin-bottom: 2%;
}

#selected_type form div>*,
#selected_qd form div>*,
#selected_type ul li>a>span {
    width: 45%;
    display: inline-block;
}

#selected_type form div>*,
#selected_qd form div>* {
    margin: 2.5%;
}

#selected_type ul li>a>span:last-child {
    font-size: .9em;
}

#search_form div>* {
    width: 45%;
}

@media screen and (max-width: 760px) {

    #type_summary_list {
        font-size: 0.8em;
    }

    #selected_type li {
        font-size: .8em;
    }

    aside {
        flex: 0 0 auto;
        display: flex;
        flex-direction: row-reverse;
        flex-wrap: wrap;
    }

    aside>dl {
        flex-basis: 50%;
        flex-shrink: inherit;
    }

    #add_price_suggest {
        width: 11em;
    }

    input,
    select,
    textarea {
        font-size: 1em;
        padding: 0.2em 0.2em;
    }

    #selected_type ul li>a>span:last-child {
        font-size: .8em;
    }

    main {
        flex: 0 0 auto;
    }

    #out-round {
        flex-direction: column;
    }

    #userInfo {
        flex: 0 0 20px;
        position: inherit;
        background: var(--bg-color);
        padding: 0.5em 0;
        text-align: center;
        font-size: 18px;
        font-weight: bold;
        margin-top: 5px;
        color: var(--text-color);
    }

    #userInfo a {
        color: var(--link-color);
    }

    #loading {
        position: fixed;
        top: 2px;
        right: 2px;
    }

    dt,
    table,
    .amount {
        border-radius: 0 !important;
    }

    aside>dl dt,
    aside>dl dd {
        margin-right: 0;
        margin-left: 0;
    }

    footer {
        text-align: center;
        font-size: 0.8em;
        background: var(--bg-color);
        padding: 0;
        color: var(--text-color);
    }

    footer a {
        color: var(--link-color);
    }

}

@media screen and (max-width: 321px) {

    #selected_type li {
        font-size: .9em;
    }

    aside#addbar {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
    }

    aside#addbar dl {
        flex-shrink: initial;
    }

    #selected_type {
        display: none;
    }

    .amount,
    .money_list th,
    .money_list td {
        font-size: .8em;
    }

}