:root {
  --bg: #f4f6f9;
  --card: #fff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --primary: #0d5c8c;
  --primary-hover: #0a4a70;
  --danger: #c0392b;
  --border: #dde3ea;
  --shadow: 0 2px 12px rgba(26, 35, 50, 0.08);
  --radius: 10px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); }

.loading-screen { padding: 4rem; text-align: center; color: var(--muted); }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #0f2940; color: #e8eef4; padding: 1.25rem 0; flex-shrink: 0;
}
.sidebar .brand { padding: 0 1.25rem 1.5rem; font-weight: 700; font-size: 1.05rem; line-height: 1.4; }
.sidebar .brand small { display: block; font-weight: 400; opacity: 0.75; font-size: 0.8rem; margin-top: 0.25rem; }
.sidebar nav a {
  display: block; padding: 0.65rem 1.25rem; color: #c5d4e3; text-decoration: none; font-size: 0.95rem;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
.sidebar .user-block {
  margin-top: auto; padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem; opacity: 0.9;
}
.sidebar .logout { margin-top: 0.5rem; background: transparent; border: 1px solid rgba(255,255,255,0.35);
  color: #fff; padding: 0.4rem 0.75rem; border-radius: 6px; cursor: pointer; width: 100%;
}
.sidebar .logout:hover { background: rgba(255,255,255,0.1); }

.main { flex: 1; padding: 1.5rem 2rem; overflow: auto; }
.page-title { margin: 0 0 1rem; font-size: 1.35rem; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem; margin-bottom: 1rem; border: 1px solid var(--border);
}

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, #0f2940 0%, #1a5276 50%, #2980b9 100%);
}
.login-card { width: 100%; max-width: 400px; }
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-card .sub { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
input, select, textarea {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 8px;
  font-size: 0.95rem; margin-bottom: 1rem;
}
input:focus, select:focus { outline: 2px solid rgba(13, 92, 140, 0.25); border-color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.55rem 1rem; border: none; border-radius: 8px; font-size: 0.95rem; cursor: pointer;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: #e8eef4; color: var(--text); }
.btn-secondary:hover { background: #dde3ea; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.toolbar input[type="search"] { max-width: 320px; margin-bottom: 0; flex: 1; min-width: 180px; }
.toolbar .meta { color: var(--muted); font-size: 0.9rem; margin-left: auto; }

.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.5rem 0.65rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; position: sticky; top: 0; z-index: 1; font-weight: 600; white-space: nowrap; }
tr:hover td { background: #fafbfc; }
td.desc { max-width: 420px; word-break: break-word; }
td.num { white-space: nowrap; }

.alert {
  padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem;
}
.alert-error { background: #fdecea; color: #922b21; border: 1px solid #f5c6cb; }
.alert-success { background: #e8f8f0; color: #1e6f4a; border: 1px solid #b8e6cf; }
.alert-info { background: #e8f4fc; color: #1a5276; border: 1px solid #bee5eb; }

.pagination { display: flex; gap: 0.5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.pagination span { color: var(--muted); font-size: 0.9rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center;
  justify-content: center; z-index: 100; padding: 1rem;
}
.modal { background: var(--card); border-radius: var(--radius); max-width: 480px; width: 100%;
  padding: 1.25rem 1.5rem; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal h3 { margin: 0 0 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.5rem; }

.hidden { display: none !important; }
.chip { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem;
  background: #e8eef4; color: var(--muted); }

@media (max-width: 768px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .main { padding: 1rem; }
}
