* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #409eff;
    --primary-light: #ecf5ff;
    --primary-dark: #337ecc;
    --success: #67c23a;
    --warning: #e6a23c;
    --danger: #f56c6c;
    --info: #909399;
    --text-primary: #303133;
    --text-regular: #606266;
    --text-secondary: #909399;
    --border-color: #dcdfe6;
    --border-light: #e4e7ed;
    --bg-color: #f5f7fa;
    --bg-white: #ffffff;
    --sidebar-width: 220px;
    --header-height: 50px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

/* ===== Layout ===== */
.app-layout {
    display: flex;
    height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.sidebar-logo h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 1px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: #c0c4cc;
    border-radius: 2px;
}

.menu-group {
    margin-bottom: 4px;
}

.menu-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    height: 40px;
    color: var(--text-regular);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.menu-group-title:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

.menu-group-title.active {
    color: var(--primary);
    background-color: var(--primary-light);
    font-weight: 600;
}

.menu-group-title .menu-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.menu-group-title .menu-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.menu-group-title .text {
    flex: 1;
}

.menu-group-title .arrow {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.menu-group-title.expanded .arrow {
    transform: rotate(180deg);
}

.menu-submenu {
    display: none;
    background: #fafafa;
}

.menu-submenu.active {
    display: block;
}

.menu-submenu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px 0 50px;
    height: 40px;
    color: var(--text-regular);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.menu-submenu a:hover {
    color: var(--primary);
    background-color: var(--primary-light);
}

.menu-submenu a.active {
    color: var(--primary);
    background-color: var(--primary-light);
    font-weight: 600;
}

.menu-submenu a i {
    width: 16px;
    font-size: 14px;
    text-align: center;
}

/* ===== Main Area ===== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ===== Top Header ===== */
.top-header {
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.header-icon:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    position: relative;
}

.user-info:hover {
    background: var(--primary-light);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.user-name {
    font-size: 13px;
    color: var(--text-regular);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 140px;
    padding: 4px 0;
    z-index: 100;
}

.user-info:hover .user-dropdown {
    display: block;
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-regular);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.2s;
}

.user-dropdown a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.user-dropdown a i {
    width: 14px;
    font-size: 13px;
}

/* ===== Content ===== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-color);
}

/* ===== Common Components ===== */
.search-panel {
    background: var(--bg-white);
    border-radius: 4px;
    padding: 16px 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 160px;
    flex: 1;
}

.form-group label {
    font-size: 13px;
    color: var(--text-regular);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-primary);
    background-color: var(--bg-white);
    transition: border-color 0.2s;
    height: 32px;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

select.form-control {
    appearance: auto;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    align-items: center;
}

.form-row label {
    width: 100px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
}

.form-row input,
.form-row select {
    flex: 1;
    max-width: 300px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    gap: 6px;
    white-space: nowrap;
}

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

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

.btn-success {
    background-color: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover {
    background-color: #5daf34;
    border-color: #5daf34;
}

.btn-warning {
    background-color: var(--warning);
    color: #fff;
    border-color: var(--warning);
}

.btn-warning:hover {
    background-color: #cf9236;
    border-color: #cf9236;
}

.btn-danger {
    background-color: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-danger:hover {
    background-color: #dd6161;
    border-color: #dd6161;
}

.btn-info {
    background-color: var(--info);
    color: #fff;
    border-color: var(--info);
}

.btn-info:hover {
    background-color: #82868f;
    border-color: #82868f;
}

.btn-default {
    background-color: var(--bg-white);
    color: var(--text-regular);
    border-color: var(--border-color);
}

.btn-default:hover {
    color: var(--primary);
    border-color: var(--primary-light);
    background-color: var(--primary-light);
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Table ===== */
.table-container {
    background: var(--bg-white);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    white-space: nowrap;
}

.data-table th {
    background-color: #fafafa;
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:hover {
    background-color: var(--primary-light);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Status Tags ===== */
.status {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending { background-color: #fef3c7; color: #92400e; }
.status-active, .status-released { background-color: #d1fae5; color: #065f46; }
.status-processing { background-color: #dbeafe; color: #1e40af; }
.status-completed { background-color: #d1fae5; color: #065f46; }
.status-canceled, .status-cancelled { background-color: #fee2e2; color: #991b1b; }
.status-abnormal { background-color: #fee2e2; color: #991b1b; }

/* ===== Pagination ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 4px;
    width: 600px;
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-color);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
}

/* ===== Metric Cards ===== */
.top-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.metric-card {
    background: var(--bg-white);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    padding: 20px;
    transition: box-shadow 0.2s;
}

.metric-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.metric-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.metric-title i { font-size: 15px; }

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.metric-change {
    font-size: 12px;
    font-weight: 500;
}

.metric-change.up { color: var(--success); }
.metric-change.down { color: var(--danger); }

/* ===== Chart Card ===== */
.chart-card {
    background: var(--bg-white);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    padding: 20px;
    margin-bottom: 16px;
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
}

/* ===== Order Cards ===== */
.orders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.order-card {
    background: var(--bg-white);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    padding: 20px;
}

.order-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.order-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--success);
    border-radius: 2px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f2f3f5;
}

.order-item:last-child { border-bottom: none; }

.order-number {
    color: var(--text-regular);
    font-size: 13px;
}

.order-priority {
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.priority-high { background: #fee2e2; color: #991b1b; }
.priority-normal { background: #d1fae5; color: #065f46; }
.priority-emergency { background: #fef3c7; color: #92400e; }

/* ===== Inventory Trend ===== */
.inventory-trend {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.inventory-item { text-align: center; flex: 1; }

.inventory-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.inventory-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.trend-chart {
    height: 140px;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 10px 0;
}

.trend-bar {
    width: 36px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    position: relative;
    transition: height 0.3s;
}

.trend-bar:hover { opacity: 0.8; }

.trend-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ===== Login Page ===== */
.login-container {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}

.login-box {
    width: 400px;
    background: var(--bg-white);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    padding: 40px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 6px;
}

.login-form .form-control {
    width: 100%;
    height: 36px;
}

.login-form .btn-primary {
    width: 100%;
    height: 38px;
    font-size: 14px;
}

/* ===== Tabs ===== */
.tab-btns {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }
