/* ==========================================================================
   吧师便利店零管系统 —— 后台样式
   ========================================================================== */

:root {
    --brand: #1677ff;
    --brand-dark: #0e5fd8;
    --brand-grad: linear-gradient(90deg, #1b6df3, #4c9aff);
    --bg: #f0f2f5;
    --card: #ffffff;
    --border: #ebeef5;
    --border-strong: #dcdfe6;
    --head-bg: #f5f9ff;
    --active-row: #eaf3fc;
    --hover-row: #f5f9ff;
    --warn-bg: #fbf3d5;
    --text: #303133;
    --text-2: #606266;
    --text-3: #909399;
    --danger: #f56c6c;
    --success: #52c41a;
    --radius: 8px;
    --sidebar-w: 240px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

/* --------------------------------------------------------------- 整体框架 */

.layout {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    flex: none;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--brand-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    box-shadow: 0 2px 6px rgba(22, 119, 255, 0.28);
}

.brand-logo svg {
    width: 19px;
    height: 19px;
    color: #fff;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.brand-text b {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.brand-text i {
    font-style: normal;
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav {
    padding: 12px 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 12px;
    border-radius: 6px;
    color: var(--text-2);
    font-size: 14px;
    transition: background 0.15s, color 0.15s;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    flex: none;
}

.nav-item:hover {
    background: #f2f7ff;
    color: var(--brand);
}

.nav-item.is-active {
    background: var(--brand-grad);
    color: #fff;
    box-shadow: 0 2px 8px rgba(22, 119, 255, 0.3);
}

.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 15;
}

.page-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.content {
    flex: 1;
    padding: 18px 24px 28px;
}

/* --------------------------------------------------------------- 通用控件 */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px rgba(15, 35, 95, 0.06);
    padding: 18px 20px 16px;
}

.card + .card {
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 15px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn svg {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-plain {
    background: #fff;
    color: var(--brand);
    border-color: #a6c8ff;
}

.btn-plain:hover {
    background: #ecf3ff;
    border-color: var(--brand);
}

.btn-ghost {
    background: #fff;
    color: var(--text-2);
    border-color: var(--border-strong);
}

.btn-ghost:hover {
    color: var(--brand);
    border-color: var(--brand);
}

.field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.field > label {
    color: var(--text-2);
    font-size: 13px;
    white-space: nowrap;
}

.input,
.select {
    height: 32px;
    min-width: 150px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.select {
    padding-right: 26px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23909399' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.filter-row .spacer {
    flex: 1;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text-2);
    font-size: 13px;
    background: #fafbfc;
}

.file-chip svg {
    width: 14px;
    height: 14px;
    color: var(--brand);
}

/* --------------------------------------------------------------- 概览卡片 */

.stats {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 6px 4px;
}

.stat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 24px;
    position: relative;
}

.stat + .stat::before {
    content: "";
    position: absolute;
    left: 0;
    top: 12%;
    height: 76%;
    width: 1px;
    background: var(--border);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #eaf3ff;
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.stat-icon svg {
    width: 21px;
    height: 21px;
}

.stat-body {
    min-width: 0;
}

.stat-label {
    font-size: 13px;
    color: var(--text-3);
    margin-bottom: 3px;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.25;
    white-space: nowrap;
}

.stat-value small {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-2);
    margin-left: 2px;
}

/* --------------------------------------------------------------- 数据表格 */

.table-wrap {
    margin: 0 -20px;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    height: 44px;
    padding: 0 14px;
    background: var(--head-bg);
    color: var(--text-2);
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    height: 48px;
    padding: 0 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--hover-row);
}

.data-table tbody tr.is-selected {
    background: var(--active-row);
}

.data-table tbody tr.is-selected:hover {
    background: #e2eefc;
}

.data-table .col-check {
    width: 46px;
    text-align: center;
    padding: 0 0 0 14px;
}

.data-table .col-index {
    width: 62px;
    color: var(--text-2);
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .center {
    text-align: center;
}

.data-table .name {
    min-width: 260px;
    max-width: 460px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.data-table tfoot td {
    background: var(--warn-bg);
    border-bottom: none;
    font-weight: 600;
    height: 46px;
}

.check-input {
    width: 15px;
    height: 15px;
    accent-color: var(--brand);
    cursor: pointer;
    vertical-align: middle;
}

.unit-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #eaf3ff;
    color: var(--brand);
    font-size: 12px;
    margin-right: 10px;
    flex: none;
    vertical-align: middle;
}

.name-cell {
    display: flex;
    align-items: center;
    min-width: 0;
}

.name-cell span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-ok {
    color: var(--brand);
}

.status-off {
    color: var(--danger);
}

/* --------------------------------------------------------------- 卡片底栏 */

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 16px;
}

.foot-info {
    color: var(--text-2);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.foot-info b {
    color: var(--text);
    font-weight: 600;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination .page-size {
    width: auto;
    min-width: 96px;
    height: 30px;
}

.pager {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pager-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: #fff;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1;
}

.pager-btn:hover {
    color: var(--brand);
    border-color: var(--brand);
}

.pager-btn.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.pager-btn.is-disabled {
    color: #c0c4cc;
    border-color: var(--border);
    pointer-events: none;
}

.pager-ellipsis {
    color: var(--text-3);
    padding: 0 2px;
}

/* --------------------------------------------------------------- 空状态 / 提示 */

.empty {
    padding: 56px 0;
    text-align: center;
    color: var(--text-3);
    font-size: 13px;
}

.alert {
    margin: 0 0 16px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
}

.alert-error {
    background: #fef0f0;
    color: var(--danger);
    border: 1px solid #fde2e2;
}

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

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* 背景挂在 body 上，保证任何视口尺寸下都不会露出接缝或白底 */
body.login-body {
    background:
        radial-gradient(1200px 520px at 12% -8%, rgba(76, 154, 255, 0.35), transparent 60%),
        radial-gradient(900px 460px at 100% 108%, rgba(27, 109, 243, 0.32), transparent 62%),
        linear-gradient(160deg, #0f2a4d 0%, #14498c 52%, #1b6df3 100%) #14498c;
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    padding: 36px 34px 30px;
    box-shadow: 0 24px 60px rgba(6, 26, 60, 0.35);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.login-brand .brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 11px;
}

.login-brand .brand-logo svg {
    width: 23px;
    height: 23px;
}

.login-brand-text b {
    display: block;
    font-size: 17px;
    font-weight: 600;
}

.login-brand-text i {
    font-style: normal;
    font-size: 12px;
    color: var(--text-3);
}

.login-sub {
    margin: 0 0 24px;
    font-size: 13px;
    color: var(--text-3);
}

.login-field {
    margin-bottom: 16px;
}

.login-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    color: var(--text-2);
}

.login-field .input {
    width: 100%;
    min-width: 0;
    height: 40px;
}

.login-submit {
    width: 100%;
    height: 40px;
    margin-top: 6px;
    font-size: 14px;
}

/* --------------------------------------------------------------- 响应式 */

@media (max-width: 1180px) {
    :root {
        --sidebar-w: 200px;
    }

    .brand-text i {
        display: none;
    }

    .content {
        padding: 16px 16px 24px;
    }

    .topbar {
        padding: 0 16px;
    }
}

@media (max-width: 860px) {
    .sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
    }

    .brand {
        border-bottom: none;
        border-right: 1px solid var(--border);
    }

    .nav {
        flex-direction: row;
        padding: 8px 10px;
    }

    .main {
        margin-left: 0;
    }

    .stats {
        flex-direction: column;
    }

    .stat + .stat::before {
        display: none;
    }
}
