/* =========================
   全局基础样式
========================= */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    background: #f3f4f6;
    color: #111827;
    font-size: 14px;
}

/* =========================
   顶部栏
========================= */
.topbar {
    height: 60px;
    background: #111827;
    color: white;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 24px;
    box-sizing: border-box;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.system-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-btn {
    color: white;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: #374151;
}

/* =========================
   主体布局
========================= */
.layout {
    display: flex;
    height: calc(100vh - 60px);
}

/* =========================
   左侧菜单
========================= */
.sidebar {
    width: 220px;
    background: #1f2937;
    color: white;
    padding-top: 16px;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.12);
}

.sidebar a {
    display: block;
    color: #e5e7eb;
    text-decoration: none;
    padding: 13px 22px;
    box-sizing: border-box;
    font-size: 15px;
    border-left: 4px solid transparent;
    transition: all 0.2s;
}

.sidebar a:hover {
    background: #374151;
    color: #ffffff;
    border-left-color: #60a5fa;
}

/* 当前菜单选中时可以给 a 加 active 类 */
.sidebar a.active {
    background: #2563eb;
    color: #ffffff;
    border-left-color: #93c5fd;
}

/* =========================
   页面内容区域
========================= */
.content {
    flex: 1;
    padding: 24px;
    background: #f3f4f6;
    overflow-y: auto;
    box-sizing: border-box;
}

/* 页面标题 */
.content h1,
.content h2,
.content h3 {
    margin-top: 0;
    color: #111827;
}

.content h2 {
    font-size: 22px;
    margin-bottom: 18px;
}

/* =========================
   通用卡片
========================= */
.card,
.panel,
.form-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
}

/* =========================
   表格样式
========================= */
table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    color: #374151;
}

tr:hover td {
    background: #f9fafb;
}

/* =========================
   表单样式
========================= */
form {
    margin: 0;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #374151;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    height: 36px;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    background: #ffffff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea {
    min-height: 72px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* 每一行表单项 */
.form-row,
.form-item {
    margin-bottom: 14px;
}

/* =========================
   按钮样式
========================= */
button,
.btn {
    border: none;
    outline: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background: #2563eb;
    color: white;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

button:hover,
.btn:hover {
    background: #1d4ed8;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.25);
}

button:active,
.btn:active {
    transform: translateY(1px);
}

/* 次要按钮 */
.btn-secondary,
button.secondary {
    background: #6b7280;
}

.btn-secondary:hover,
button.secondary:hover {
    background: #4b5563;
}

/* 删除按钮 */
.btn-danger,
button.danger {
    background: #dc2626;
}

.btn-danger:hover,
button.danger:hover {
    background: #b91c1c;
}

/* 按钮区域 */
.form-actions,
.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

/* =========================
   弹窗遮罩和弹窗
   兼容常见 class：modal / modal-content
========================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);

    display: flex;
    align-items: center;
    justify-content: center;

    z-index: 999;
    padding: 20px;
}

/* 弹窗主体 */
.modal-content,
.dialog,
.popup {
    width: 640px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;

    background: #ffffff;
    border-radius: 12px;
    padding: 24px 28px;

    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

/* 弹窗标题 */
.modal-content h2,
.dialog h2,
.popup h2 {
    margin: 0 0 18px 0;
    font-size: 22px;
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 12px;
}

/* 弹窗里的表单 */
.modal-content label,
.dialog label,
.popup label {
    margin-top: 10px;
    margin-bottom: 5px;
}

/* 弹窗按钮 */
.modal-content button,
.dialog button,
.popup button {
    margin-right: 8px;
}

/* =========================
   状态标签
========================= */
.status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-normal {
    background: #dcfce7;
    color: #166534;
}

.status-offline {
    background: #fee2e2;
    color: #991b1b;
}

.status-alarm {
    background: #fef3c7;
    color: #92400e;
}

/* =========================
   工具栏
========================= */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* =========================
   小屏幕适配
========================= */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        display: flex;
        overflow-x: auto;
        padding-top: 0;
    }

    .sidebar a {
        white-space: nowrap;
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .content {
        padding: 16px;
    }

    .modal-content,
    .dialog,
    .popup {
        width: 100%;
        padding: 20px;
    }
}

/* =========================
   导航链接统一类
========================= */

.nav-link {
    display: block;
}

/* =========================
   页面滚动更顺滑
========================= */

html {
    scroll-behavior: smooth;
}

/* =========================
   滚动条美化
========================= */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f3f4f6;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =========================
   内容区顶部间距优化
========================= */

.content > :first-child {
    margin-top: 0;
}

/* =========================
   默认链接颜色
========================= */

a {
    color: inherit;
}

/* =========================
   禁止按钮文字选中
========================= */

button {
    user-select: none;
}

/* =========================
   输入框 placeholder
========================= */

input::placeholder,
textarea::placeholder {
    color: #9ca3af;
}

/* =========================
   小屏幕优化
========================= */

@media (max-width: 768px) {

    .topbar {
        padding: 0 14px;
    }

    .system-title {
        font-size: 16px;
    }

    .sidebar {
        box-shadow: none;
        border-bottom: 1px solid #e5e7eb;
    }

    .sidebar a {
        padding: 14px 18px;
        font-size: 14px;
    }
}

.current-user-info {

    display: flex;

    flex-direction: column;

    align-items: flex-end;

    margin-right: 16px;
}

.current-user-name {

    font-size: 14px;

    font-weight: 600;

    color: #ffffff;
}

.current-user-role {

    font-size: 12px;

    color: #cbd5e1;
}