/* 手写的样式表，**不用任何 CDN**。
 *
 * 店里的 WiFi 时好时坏，外网更是经常不通。用 Bootstrap 那种 CDN 引入的框架，
 * 网一断页面就整个裸奔（只剩默认的宋体和蓝链接），比没有样式还难看。所以
 * 全部样式就在这一个文件里，跟着代码一起拷过去，断网也长一个样。
 *
 * 移动优先：老板和工人多半拿手机看，所以基础样式按窄屏写，
 * 再用 min-width 的媒体查询往上加宽屏的排布。
 */

:root {
    --navy: #1f4e78;          /* 主色：顶栏、主按钮、表头 */
    --navy-d: #173d5e;        /* 主色加深，hover 用 */
    --navy-l: #e8f0f8;
    --line: #d7dee6;
    --bg: #f2f5f8;
    --card: #fff;
    --text: #1c2733;
    --muted: #64748b;
    --ok: #166534;
    --ok-bg: #dcfce7;
    --err: #991b1b;
    --err-bg: #fee2e2;
    --warn: #92400e;
    --warn-bg: #fef3c7;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 32, 48, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 通用撑开：一排东西里把它插在中间，后面的就被推到右边去。
 *
 * 以前只在 .topbar / .page-head 底下各写了一条，别处用（卡片里的 .actions、
 * 表单底下那排按钮）完全不生效 —— 也不报错，就是那几个按钮挤在左边。
 * 写成一个不挑父元素的规则，哪儿用都算数。 */
.spacer { flex: 1; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 10px;
    height: 52px; padding: 0 12px;
    background: var(--navy); color: #fff;
    box-shadow: var(--shadow);
}
.topbar a { color: #fff; }
.brand { font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.menu-toggle {
    background: none; border: 0; color: #fff;
    font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer;
}

.lang-switch { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.lang-switch a, .lang-switch .cur {
    padding: 2px 8px; border-radius: 999px; line-height: 1.6;
}
.lang-switch a { opacity: .8; }
.lang-switch .cur { background: rgba(255, 255, 255, .22); font-weight: 600; }

.who { font-size: 13px; opacity: .9; white-space: nowrap; }
.who form { display: inline; }
.who button {
    background: none; border: 0; color: #fff; opacity: .75;
    cursor: pointer; font-size: 13px; padding: 0 2px; text-decoration: underline;
}

/* ---------------------------------------------------------------- 侧栏 */

.shell { display: flex; min-height: calc(100vh - 52px); }

.nav {
    position: fixed; top: 52px; bottom: 0; left: 0; z-index: 25;
    width: 232px; padding: 12px 8px 32px;
    background: var(--card); border-right: 1px solid var(--line);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .18s ease;
}
body.nav-open .nav { transform: none; }

.nav-group { margin-bottom: 14px; }
.nav-group h4 {
    margin: 0 0 4px; padding: 0 10px;
    font-size: 11px; font-weight: 600; letter-spacing: .06em;
    color: var(--muted); text-transform: uppercase;
}
.nav a {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px; border-radius: 8px;
    color: var(--text); font-size: 14px;
}
.nav a:hover { background: var(--navy-l); text-decoration: none; }
.nav a.on { background: var(--navy); color: #fff; }
.nav a .ic { width: 18px; text-align: center; }

.backdrop {
    display: none; position: fixed; inset: 52px 0 0 0; z-index: 20;
    background: rgba(16, 32, 48, .35);
}
body.nav-open .backdrop { display: block; }

.content { flex: 1; min-width: 0; padding: 14px 12px 48px; }

/* ---------------------------------------------------------------- 通用块 */

.page-head {
    display: flex; align-items: center; flex-wrap: wrap;
    gap: 8px; margin-bottom: 12px;
}
.page-head h2 { margin: 0; font-size: 19px; }
.page-head .sub { color: var(--muted); font-size: 13px; }

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px; margin-bottom: 14px;
}
.card > h3 {
    margin: 0 0 10px; font-size: 15px;
    padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.card > h3 .sub { font-weight: 400; color: var(--muted); font-size: 13px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.center { text-align: center; }

/* 统计卡片 */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.stat {
    display: block; padding: 12px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    color: var(--text);
}
a.stat:hover { border-color: var(--navy); text-decoration: none; }
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.stat .v {
    font-size: 21px; font-weight: 600;
    font-variant-numeric: tabular-nums; line-height: 1.25;
}
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); }
.stat.ok .v { color: var(--ok); }
.stat.warn .v { color: var(--warn); }
.stat.err .v { color: var(--err); }

/* ---------------------------------------------------------------- 表格 */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
    padding: 7px 9px; border-bottom: 1px solid var(--line);
    text-align: left; vertical-align: top;
}
table.data th {
    background: var(--navy-l); color: var(--navy);
    font-weight: 600; font-size: 13px; white-space: nowrap;
}
table.data tbody tr:hover { background: #fafcfe; }
table.data td.num, table.data th.num { text-align: right; }
table.data tfoot td {
    font-weight: 600; background: #f8fafc;
    border-top: 2px solid var(--line);
}
table.data .empty {
    text-align: center; color: var(--muted); padding: 28px 10px;
}
table.data tr.warn-row { background: #fffbf0; }
table.data tr.warn-row:hover { background: #fff6e0; }

/* ---------------------------------------------------------------- 表单 */

.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }

label.f { display: block; }
label.f > span.lb {
    display: block; margin-bottom: 4px;
    font-size: 13px; font-weight: 600; color: #33475b;
}
label.f .req { color: var(--err); margin-left: 2px; }
.hint { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }

/* 进货入库页那两行现算的预览（「现在 30 → 这次进 20 → 完事 50」）。
   它是这一页最该看的一眼，所以从灰扑扑的小字里拎出来：浅底、深色、
   数字加粗。段间距靠 gap，不靠 <br>。 */
.hint.calc {
    display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline;
    margin-top: 14px; padding: 9px 12px; border-radius: 4px;
    background: var(--navy-l); color: var(--text);
}
.hint.calc b { font-size: 15px; color: var(--navy); }
.hint.calc > span { white-space: nowrap; }

input[type=text], input[type=password], input[type=number],
input[type=date], input[type=month], select, textarea {
    width: 100%; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--text);
    font-size: 15px; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(31, 78, 120, .12);
}
textarea { min-height: 68px; resize: vertical; }
input[readonly] { background: #f4f6f8; color: var(--muted); }

.span2 { grid-column: 1 / -1; }
.form-actions {
    display: flex; gap: 10px; align-items: center;
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}

/* 筛选条 */
.filters {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end;
}
.filters label.f { flex: 1 1 130px; min-width: 110px; }
.filters input, .filters select { padding: 7px 9px; font-size: 14px; }

/* ---------------------------------------------------------------- 按钮 */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
    padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--text);
    font-size: 14px; font-family: inherit; cursor: pointer;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #f5f8fb; text-decoration: none; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-d); }
.btn-danger { background: #fff; border-color: #e6b6b6; color: var(--err); }
.btn-danger:hover { background: var(--err-bg); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ---------------------------------------------------------------- 提示 */

.flash {
    padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
    font-size: 14px; border: 1px solid transparent;
}
.flash.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: #bbf7d0; }
.flash.err  { background: var(--err-bg);  color: var(--err);  border-color: #fecaca; }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.notice {
    padding: 10px 12px; border-radius: 8px; margin-bottom: 12px;
    font-size: 14px; background: var(--navy-l); color: var(--navy);
}
.notice.warn { background: var(--warn-bg); color: var(--warn); }

.tag {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; white-space: nowrap;
    background: #eef2f6; color: #475569;
}
.tag.ok    { background: var(--ok-bg);   color: var(--ok); }
.tag.warn  { background: var(--warn-bg); color: var(--warn); }
.tag.err   { background: var(--err-bg);  color: var(--err); }
.tag.info  { background: var(--navy-l);  color: var(--navy); }

/* ---------------------------------------------------------------- 分页 */

.pager {
    display: flex; gap: 8px; align-items: center; justify-content: center;
    margin-top: 14px; font-size: 14px;
}
.pager a, .pager span {
    padding: 5px 11px; border: 1px solid var(--line);
    border-radius: 7px; background: #fff;
}
.pager span { color: var(--muted); }

/* ---------------------------------------------------------------- 明细表 */

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
    font-size: 12px; color: var(--muted); font-weight: 600;
    padding: 4px 6px; text-align: left; white-space: nowrap;
}
table.grid td { padding: 3px 4px; }
table.grid input, table.grid select {
    padding: 6px 7px; font-size: 14px; border-radius: 6px;
}
table.grid td.num input { text-align: right; }
.row-del {
    background: none; border: 0; color: var(--err);
    cursor: pointer; font-size: 17px; line-height: 1; padding: 0 4px;
}

/* 详情页的键值对 */
.kv { display: grid; grid-template-columns: 1fr; gap: 2px 14px; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { margin-bottom: 8px; }

/* 权限勾选 */
.perm-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.perm-list label {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
    font-size: 14px; cursor: pointer;
}
.perm-list input { width: auto; }

/* ---------------------------------------------------------------- 登录页 */

.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 20px; background: var(--navy);
}
.login-wrap .card { width: 100%; max-width: 360px; padding: 22px; }
.login-wrap h1 { margin: 0 0 4px; font-size: 20px; }
.login-wrap .lang-switch { justify-content: center; margin-bottom: 16px; }
.login-wrap .lang-switch a { color: var(--navy); opacity: 1; }
.login-wrap .lang-switch .cur { background: var(--navy); color: #fff; }
.login-wrap .btn { width: 100%; margin-top: 6px; padding: 10px; }

/* ---------------------------------------------------------------- 列表与详情 */

/* 最右边那列「操作」。表头是空的（<th class="act"></th>），不给它定宽就会
 * 白占一大格，把配件名那几列挤窄。 */
table.data th.act, table.data td.act { width: 1%; white-space: nowrap; }

/* 表格单元格里的行内表单（删除）。不设 inline 的话按钮会另起一行，
 * 一条记录被撑成两倍高，一屏看不了几条。 */
form.inline { display: inline; }
form.inline button { vertical-align: middle; }
form.inline select { width: auto; display: inline-block; padding: 5px 8px; font-size: 13px; }

/* 长文本（故障描述、备注）只占一行，超出打省略号。
 * 一列长文字就能把整张表撑到要横拉，其它列跟着一起看不全。 */
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 筛选条里那个搜索框：让它把剩下的宽度吃掉，别的控件才不会被拉变形 */
.grow { flex: 1 1 200px; min-width: 0; }

.low, td.low { color: var(--err); font-weight: 600; }

/* 合计条。业主核价先看这个数，所以给它上底色、放大字号。 */
.total-bar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    background: var(--navy-l); border-color: #c9dcef;
}
.total-bar .k { color: var(--navy); font-size: 13px; }
.total-bar .money, .total-bar .big { margin-left: auto; }
.big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* 金额一律等宽数字 + 右对齐：位数对得上，一眼能比出大小 */
.money { font-variant-numeric: tabular-nums; }
input.money { text-align: right; }

/* 明细表的列宽。工时、数量、单价这些列不定宽的话，「配件名」会被挤成一条。 */
table.grid th.w-sm { width: 72px; }
table.grid th.w-md { width: 104px; }

/* 表单里占满整行的字段（备注、故障描述）。
 * 窄屏本来就是一行一个，所以只需在宽屏的两列布局里跨过去。 */
label.f.col-full, label.f.col-2 { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- 切页 / 分段 */

/* 报表之间的切换条，和库存页的「按配件汇总 / 按仓库明细」。同一套长相。 */
.tabs, .seg { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs { margin-bottom: 12px; }
.tabs a, .seg a {
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
    background: #fff; color: var(--muted); font-size: 13px;
}
.tabs a:hover, .seg a:hover { border-color: var(--navy); text-decoration: none; }
.tabs a.on, .seg a.on {
    background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 600;
}

.range-note { margin: 4px 0 12px; }

/* 不进筛选条的「清空」链接：不画边框，免得跟旁边的主按钮抢眼 */
.btn-plain {
    border-color: transparent; background: none; color: var(--muted);
}
.btn-plain:hover { background: none; color: var(--navy); text-decoration: underline; }

/* ---------------------------------------------------------------- 权限勾选 */

.perm-group { margin-bottom: 10px; }
.perm-group-name {
    font-size: 12px; font-weight: 600; color: var(--muted);
    margin-bottom: 4px; padding-left: 2px;
}
label.chk, label.radio {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 9px; border-radius: 7px;
    font-size: 14px; cursor: pointer;
}
label.chk:hover, label.radio:hover { background: #f5f8fb; }
label.chk input, label.radio input { width: auto; margin: 0; }
label.radio { margin-bottom: 2px; }

/* 选了「按角色默认」的时候，下面那堆勾选框整块变淡。
 * 单靠 JS 把 input 设成 disabled 是不够的 —— 看着还是能点的样子，
 * 人会一直点，然后以为程序坏了。 */
.perm-list.off { opacity: .45; }

/* 权限小标签。给账号列表用，一个人一行铺开太长。 */
.chip {
    display: inline-block; padding: 1px 8px; margin: 1px 2px;
    border-radius: 999px; background: #eef2f6; color: #475569; font-size: 12px;
}

/* 出入库类型的小色块。颜色按语义分：进绿、出红、调整黄、期初蓝。
 * 一屏流水里扫一眼就能看出哪几笔是进货、哪几笔是领料。 */
/* 类名是英文的：模板里把中文的 kind 映射过来（见 stock/list.html）。
 * 直接拿 kind 当类名的话，葡语界面下它会被翻译，这几条就全失效了。 */
.tag.kind-in     { background: var(--ok-bg);   color: var(--ok); }
.tag.kind-out    { background: var(--err-bg);  color: var(--err); }
.tag.kind-adjust { background: var(--warn-bg); color: var(--warn); }
.tag.kind-init   { background: var(--navy-l);  color: var(--navy); }

/* ---------------------------------------------------------------- 宽屏 */

@media (min-width: 640px) {
    .stats { grid-template-columns: repeat(3, 1fr); }
    .kv { grid-template-columns: auto 1fr; }
    .kv .k { margin-bottom: 0; }
    .perm-list { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 820px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 900px) {
    .menu-toggle { display: none; }
    .nav { position: sticky; top: 52px; height: calc(100vh - 52px); transform: none; }
    .content { padding: 20px 24px 60px; }
    .backdrop { display: none !important; }
}

/* 窄屏上把表格摊成一张张卡片。
 *
 * 手机上看六列的表格要左右横拉，很容易拉错行 —— 把每一行摊成一块，
 * 用 data-label 把列名显示在值前面，一眼就知道哪个数是哪个。 */
@media (max-width: 719px) {
    table.data thead { display: none; }
    table.data, table.data tbody, table.data tr, table.data td {
        display: block; width: 100%;
    }
    table.data tr {
        border: 1px solid var(--line); border-radius: 8px;
        margin-bottom: 9px; padding: 5px 2px; background: #fff;
    }
    table.data td {
        display: flex; justify-content: space-between; gap: 12px;
        border: 0; padding: 4px 10px; text-align: right;
    }
    table.data td::before {
        content: attr(data-label);
        flex: 0 0 auto; text-align: left;
        color: var(--muted); font-size: 13px;
    }
    table.data td.num { text-align: right; }
    /* 摊成卡片之后没有「列宽」这回事了，再截断反而看不全 —— 让长文本换行 */
    table.data td.ellipsis {
        max-width: none; white-space: normal; overflow: visible; text-overflow: clip;
    }
    table.data td.empty { display: block; text-align: center; }
    table.data td.empty::before { content: none; }
    table.data tfoot td { border-top: 0; }
    table.data tfoot td::before { content: none; }
    table.data tfoot td { display: block; text-align: right; }
}
