/* ===========================================================
   小阔客服工单系统 - 全局样式
   视觉基线对齐原零代码平台：浅灰底 + 白色卡片 + 蓝色主色
   =========================================================== */
:root {
    --primary: #1677ff;
    --primary-hover: #4096ff;
    --primary-active: #0e5fd8;
    --bg: #f0f2f5;
    --card: #ffffff;
    --border: #e5e6eb;
    --border-light: #f0f1f3;
    --text: #1f2329;
    --text-sub: #86909c;
    --text-light: #c9cdd4;
    --green: #00b42a;
    --green-bg: #e8ffea;
    --orange: #ff7d00;
    --orange-bg: #fff7e8;
    --red: #f53f3f;
    --red-bg: #ffece8;
    --grey-bg: #f2f3f5;
    --sidebar: #f7f8fa;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 4px 12px rgba(0, 0, 0, .04);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------------- 顶栏 ---------------- */
.topbar {
    height: 52px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px 0 12px;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 60;
}
.topbar .logo {
    width: 30px; height: 30px;
    border-radius: 7px;
    background: linear-gradient(135deg, #1677ff, #52a3ff);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    margin-right: 10px;
    box-shadow: 0 2px 6px rgba(22, 119, 255, .3);
}
.topbar .app-name { font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px; border-radius: 20px; cursor: pointer;
    position: relative;
}
.topbar .user-chip:hover { background: var(--grey-bg); }
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, #40a9ff, #1677ff);
    color: #fff; font-size: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}
.avatar.gray { background: linear-gradient(135deg, #b8bec9, #8a919e); }
.avatar.avatar-sm { width: 22px; height: 22px; font-size: 11px; }
.topbar .dropdown {
    position: absolute; right: 0; top: 42px;
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 160px; padding: 6px 0; display: none;
}
.topbar .dropdown.open { display: block; }
.topbar .dropdown a {
    display: block; padding: 8px 16px; color: var(--text); font-size: 13px;
}
.topbar .dropdown a:hover { background: var(--grey-bg); color: var(--primary); }

/* ---------------- 侧边栏 ---------------- */
.sidebar {
    position: fixed;
    top: 52px; left: 0; bottom: 0;
    width: 220px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 12px;
    overflow-y: auto;
    z-index: 50;
}
.search-box {
    position: relative;
    margin-bottom: 12px;
}
.search-box input {
    width: 100%; height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 30px 0 10px;
    background: #fff;
    font-size: 13px; color: var(--text);
    outline: none;
}
.search-box input:focus { border-color: var(--primary); }
.search-box .icon {
    position: absolute; right: 9px; top: 8px;
    color: var(--text-sub); cursor: pointer; font-size: 14px;
}
.menu-item {
    display: flex; align-items: center; gap: 9px;
    height: 38px; padding: 0 10px;
    border-radius: var(--radius);
    color: var(--text); font-size: 14px;
    cursor: pointer; margin-bottom: 2px;
}
.menu-item:hover { background: #eceef1; }
.menu-item.active { background: #e6f0ff; color: var(--primary); font-weight: 500; }
.menu-item .mi-icon { width: 17px; text-align: center; font-size: 15px; }
.menu-group-title {
    font-size: 12px; color: var(--text-sub);
    padding: 12px 10px 6px;
}
.menu-item .badge {
    margin-left: auto;
    background: var(--primary); color: #fff;
    font-size: 11px; padding: 1px 6px; border-radius: 9px;
}

/* ---------------- 主区域 ---------------- */
.main {
    margin-left: 220px;
    padding: 64px 16px 24px;
    min-height: 100vh;
}
.card {
    background: var(--card);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 16px 20px 20px;
    min-height: calc(100vh - 88px);
}
.tabs {
    display: flex; gap: 28px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    padding: 10px 2px 12px;
    font-size: 15px; color: var(--text);
    cursor: pointer; position: relative;
}
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after {
    content: ''; position: absolute; left: 50%; transform: translateX(-50%);
    bottom: -1px; width: 44px; height: 3px; border-radius: 2px;
    background: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- 按钮 ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 32px; padding: 0 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff; color: var(--text);
    font-size: 13px; cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn:hover { color: var(--primary); border-color: var(--primary-hover); }
.btn-primary {
    background: var(--primary); border-color: var(--primary); color: #fff;
    box-shadow: 0 2px 6px rgba(22, 119, 255, .25);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-sm { height: 28px; padding: 0 11px; font-size: 12px; }
.btn-link {
    border: none; background: none; color: var(--primary);
    height: auto; padding: 0; box-shadow: none;
}
.btn-link:hover { background: none; text-decoration: underline; }
.btn-danger { color: var(--red); }
.btn-danger:hover { color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 工具栏 ---------------- */
.toolbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 14px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar .hint { color: var(--text-sub); font-size: 12px; }

/* ---------------- 表单 ---------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px 20px;
}
@media (max-width: 1500px) { .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-item.span-2 { grid-column: span 2; }
.form-label {
    font-size: 13px; color: var(--text); font-weight: 500;
    display: flex; align-items: center; gap: 4px;
}
.form-label .req { color: var(--red); }
.form-ctrl {
    height: 34px; padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff; color: var(--text);
    font-size: 13px; outline: none; width: 100%;
    transition: border-color .15s;
}
.form-ctrl:focus { border-color: var(--primary); }
.form-ctrl::placeholder { color: var(--text-light); }
select.form-ctrl {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23c9cdd4' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    padding-right: 28px;
}
.form-inline { display: flex; gap: 10px; align-items: center; }
.form-inline .form-ctrl { flex: 1; }
.form-inline .btn { flex: none; height: 34px; }
.form-error { color: var(--red); font-size: 12px; min-height: 16px; }
.form-section-title {
    font-size: 15px; font-weight: 600; margin: 24px 0 12px;
    display: flex; align-items: center; gap: 8px;
}
.form-section-title::before {
    content: ''; width: 3px; height: 15px; background: var(--primary); border-radius: 2px;
}
.form-actions {
    margin-top: 28px; display: flex; gap: 12px;
    padding-top: 20px; border-top: 1px solid var(--border-light);
}

/* ---------------- 表格 ---------------- */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: auto;
    background: #fff;
}
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th {
    background: #f7f8fa;
    color: var(--text); font-weight: 600;
    text-align: left; padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.grid td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #f7f9fc; }
table.grid .col-idx { width: 46px; text-align: center; color: var(--text-sub); }
table.grid .col-check { width: 42px; text-align: center; }
.link-title { color: var(--primary); font-weight: 500; cursor: pointer; }
.link-title:hover { text-decoration: underline; }
.cell-sub { color: var(--text-sub); font-size: 12px; }
.empty {
    padding: 60px 20px; text-align: center; color: var(--text-sub);
}
.empty .big { font-size: 40px; opacity: .35; margin-bottom: 8px; }

/* 状态标签 */
.st {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 4px;
    font-size: 12px; line-height: 20px; white-space: nowrap;
}
.st-pending   { background: var(--orange-bg); color: var(--orange); }
.st-processing{ background: #e8f3ff; color: var(--primary); }
.st-done      { background: var(--green-bg); color: var(--green); }
.st-closed    { background: var(--grey-bg); color: var(--text-sub); }
.st-rejected  { background: var(--red-bg); color: var(--red); }
.st-default   { background: var(--grey-bg); color: var(--text-sub); }

/* 分页 */
.pager {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 6px; padding: 14px 2px 0; font-size: 13px; color: var(--text-sub);
}
.pager a, .pager span {
    min-width: 30px; height: 30px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 4px; background: #fff;
    color: var(--text); cursor: pointer;
}
.pager .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .disabled { opacity: .45; cursor: not-allowed; }
.pager .total { margin-right: auto; }

/* ---------------- 抽屉（工单详情） ---------------- */
.drawer-mask {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
    z-index: 90; opacity: 0; visibility: hidden; transition: all .25s;
}
.drawer-mask.open { opacity: 1; visibility: visible; }
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(1180px, 72vw);
    background: #fff; z-index: 100;
    transform: translateX(100%); transition: transform .28s ease;
    display: flex; flex-direction: column;
    box-shadow: -6px 0 24px rgba(0, 0, 0, .12);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px;
}
.drawer-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.drawer-head .spacer { flex: 1; }
.drawer-tools { display: flex; align-items: center; gap: 4px; color: var(--text-sub); }
.drawer-tools button {
    background: none; border: none; cursor: pointer;
    color: var(--text-sub); font-size: 13px; padding: 5px 8px; border-radius: 4px;
}
.drawer-tools button:hover { background: var(--grey-bg); color: var(--primary); }
.drawer-meta {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 20px; padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: #fbfcfd;
}
.drawer-meta .m-label { font-size: 12px; color: var(--text-sub); margin-bottom: 5px; }
.drawer-meta .m-value { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 30px; }
.drawer-foot {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; justify-content: flex-end; background: #fff;
}
.drawer-section-title {
    font-size: 14px; font-weight: 600; margin: 20px 0 10px;
    display: flex; align-items: center; gap: 8px;
}
.drawer-section-title::before {
    content: ''; width: 3px; height: 14px; background: var(--primary); border-radius: 2px;
}
.detail-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px 20px;
}
.detail-item .d-label { font-size: 12px; color: var(--text-sub); margin-bottom: 4px; }
.detail-item .d-value { font-size: 14px; color: var(--text); word-break: break-all; }
.detail-item .d-value.muted { color: var(--text-light); }

/* ---------------- SKU 子表 ---------------- */
.subtable-wrap {
    border: 1px solid var(--border); border-radius: var(--radius);
    overflow-x: auto; background: #fff;
}
table.subtable { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 100%; }
table.subtable th {
    background: #f7f8fa; padding: 10px 8px; white-space: nowrap;
    border-bottom: 1px solid var(--border); font-weight: 600; text-align: left;
}
table.subtable td { padding: 7px 6px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
table.subtable .req { color: var(--red); margin-right: 2px; }
table.subtable input, table.subtable select {
    width: 100%; min-width: 110px; height: 32px;
    padding: 0 8px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 13px; outline: none; background: #fff;
}
table.subtable input:focus, table.subtable select:focus { border-color: var(--primary); }
table.subtable input.num { min-width: 84px; }
table.subtable .col-idx { width: 44px; text-align: center; color: var(--text-sub); }
table.subtable .col-op { width: 70px; text-align: center; }
table.subtable .col-op button {
    background: none; border: none; color: var(--text-sub); cursor: pointer; font-size: 13px;
}
table.subtable .col-op button:hover { color: var(--red); }
.subtable-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; }

/* ---------------- 图片上传 ---------------- */
.upload-area {
    border: 1px solid var(--border); border-radius: var(--radius);
    background: #fff; overflow: hidden;
}
.upload-toolbar {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 10px; border-bottom: 1px solid var(--border-light);
    background: #fafbfc;
}
.upload-toolbar .tbtn {
    width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
    border: none; background: none; border-radius: 4px; cursor: pointer; color: var(--text-sub); font-size: 15px;
}
.upload-toolbar .tbtn:hover { background: var(--grey-bg); color: var(--primary); }
.upload-toolbar select { height: 28px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.upload-body { padding: 12px; min-height: 150px; }
.upload-body textarea {
    width: 100%; min-height: 130px; border: none; outline: none; resize: vertical;
    font: inherit; color: var(--text); background: transparent;
}
.upload-body textarea::placeholder { color: var(--text-light); }
.thumb-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.thumb {
    position: relative; width: 96px; height: 96px;
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fafbfc;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .del {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px; border-radius: 50%;
    background: rgba(0, 0, 0, .55); color: #fff; border: none;
    cursor: pointer; font-size: 12px; line-height: 18px; text-align: center;
}
.thumb .del:hover { background: var(--red); }

/* ---------------- 详情图片 ---------------- */
.image-view { display: flex; flex-wrap: wrap; gap: 10px; }
.image-view img {
    max-width: 190px; max-height: 190px; border-radius: var(--radius);
    border: 1px solid var(--border); cursor: zoom-in; background: #fafbfc;
}
.image-note {
    background: #fafbfc; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 12px; color: var(--text); font-size: 13px; white-space: pre-wrap;
}

/* ---------------- 日志 ---------------- */
.log-list { border-left: 2px solid var(--border); margin-left: 6px; padding-left: 16px; }
.log-item { position: relative; padding: 0 0 14px; font-size: 13px; }
.log-item::before {
    content: ''; position: absolute; left: -21px; top: 6px;
    width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
}
.log-item .l-time { color: var(--text-sub); font-size: 12px; margin-top: 2px; }

/* ---------------- 提示 / 弹层 ---------------- */
.toast-wrap {
    position: fixed; top: 68px; left: 50%; transform: translateX(-50%);
    z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
    background: #fff; border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
    padding: 10px 18px; font-size: 13px; display: flex; align-items: center; gap: 8px;
    border-left: 3px solid var(--primary);
    animation: toast-in .22s ease;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.modal-mask {
    position: fixed; inset: 0; background: rgba(0, 0, 0, .4);
    z-index: 200; display: none; align-items: center; justify-content: center;
}
.modal-mask.open { display: flex; }
.modal {
    background: #fff; border-radius: 8px; width: 460px; max-width: 92vw;
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal.wide { width: 680px; }
.modal-head {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    font-size: 15px; font-weight: 600; display: flex; align-items: center;
}
.modal-head .spacer { flex: 1; }
.modal-head .close { cursor: pointer; color: var(--text-sub); font-size: 18px; line-height: 1; }
.modal-body { padding: 18px; max-height: 66vh; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------------- 登录页 ---------------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #eaf2ff 0%, #f6f9ff 45%, #eef3f8 100%);
}
.login-box {
    width: 380px; background: #fff; border-radius: 12px;
    box-shadow: 0 12px 40px rgba(31, 35, 41, .12);
    padding: 34px 32px 28px;
}
.login-box .brand { text-align: center; margin-bottom: 24px; }
.login-box .brand .logo {
    width: 46px; height: 46px; border-radius: 12px; margin: 0 auto 12px;
    background: linear-gradient(135deg, #1677ff, #52a3ff); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.login-box .brand h1 { font-size: 19px; margin: 0 0 6px; }
.login-box .brand p { margin: 0; color: var(--text-sub); font-size: 13px; }
.login-box .form-item { margin-bottom: 16px; }
.login-box .form-ctrl { height: 38px; }
.login-box .btn { width: 100%; height: 38px; justify-content: center; font-size: 14px; }
.login-tip {
    margin-top: 16px; padding: 10px 12px; background: #f7f9fc;
    border-radius: var(--radius); font-size: 12px; color: var(--text-sub); line-height: 1.7;
}
.alert {
    padding: 9px 12px; border-radius: var(--radius); font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-info { background: #e8f3ff; color: var(--primary); }

/* ---------------- 概览卡 ---------------- */
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
    background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .s-label { color: var(--text-sub); font-size: 12px; }
.stat .s-value { font-size: 22px; font-weight: 600; margin-top: 6px; }
.stat .s-value small { font-size: 13px; color: var(--text-sub); font-weight: 400; margin-left: 4px; }
.stat.primary .s-value { color: var(--primary); }
.stat.green .s-value { color: var(--green); }
.stat.orange .s-value { color: var(--orange); }

/* ---------------- 筛选条 ---------------- */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    padding: 12px 14px; background: #fafbfc;
    border: 1px solid var(--border-light); border-radius: var(--radius);
    margin-bottom: 14px;
}
.filter-bar .f-item { display: flex; align-items: center; gap: 6px; }
.filter-bar .f-item > span { color: var(--text-sub); font-size: 13px; white-space: nowrap; }
.filter-bar .form-ctrl { height: 30px; width: 150px; }
.filter-bar .form-ctrl.wide { width: 190px; }
.filter-bar .spacer { flex: 1; }

/* ---------------- 通用 ---------------- */
.muted { color: var(--text-sub); }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }
