* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0f1216; color: #e6e6e6; font-size: 14px; }

/* ===== Login ===== */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: #171b22; border: 1px solid #262b34; border-radius: 10px; padding: 28px 24px;
        width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.card h1 { margin: 0 0 18px; font-size: 20px; font-weight: 600; }
.card .sub { color: #8a919c; font-size: 12px; margin-bottom: 20px; }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: #a3a9b3; margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 9px 11px; font-size: 14px;
  background: #0f1216; border: 1px solid #2b313b; border-radius: 6px; color: #e6e6e6; outline: none; }
.field input:focus, .field select:focus { border-color: #477FB3; }
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

button.primary, button.secondary, button.danger {
  padding: 8px 14px; font-size: 13px; font-weight: 600; border: 0; border-radius: 6px; cursor: pointer;
}
button.primary { background: #477FB3; color: #fff; }
button.primary:hover { background: #5a93c7; }
button.secondary { background: #2b313b; color: #e6e6e6; }
button.secondary:hover { background: #363c47; }
button.danger { background: #a1333a; color: #fff; }
button.danger:hover { background: #bb3f47; }
button.primary:disabled, button.secondary:disabled { opacity: .5; cursor: default; }
.full { width: 100%; }

.err { color: #ff6b6b; font-size: 12px; margin-top: 10px; min-height: 16px; }
.ok  { color: #4caf50; font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ===== App shell (full width) ===== */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #12161c; border-right: 1px solid #262b34; padding: 18px 0; }
.sidebar .brand { padding: 0 20px 18px; font-size: 16px; font-weight: 700; letter-spacing: 1px; color: #fff; }
.sidebar .nav a { display: block; padding: 10px 20px; color: #a3a9b3; text-decoration: none;
  border-left: 3px solid transparent; font-size: 13px; }
.sidebar .nav a:hover { background: #171b22; color: #e6e6e6; }
.sidebar .nav a.active { background: #171b22; color: #477FB3; border-left-color: #477FB3; font-weight: 600; }
.sidebar .meta { padding: 16px 20px; color: #666c76; font-size: 11px; border-top: 1px solid #262b34; margin-top: 18px; }
.sidebar .meta .me { color: #a3a9b3; font-size: 13px; margin-bottom: 4px; font-weight: 600; }
.sidebar .meta .lang-row { display: flex; align-items: center; gap: 6px; margin: 10px 0 6px; color: #8a919c; }
.sidebar .meta .lang-sel { flex: 1; padding: 4px 6px; font-size: 12px; background: #0f1216;
  border: 1px solid #2b313b; border-radius: 4px; color: #e6e6e6; }
.sidebar .meta .meta-link { color: #8a919c; display: block; margin-top: 4px; text-decoration: none; }
.sidebar .meta .meta-link:hover { color: #e6e6e6; }

/* ===== Login language bar ===== */
.login-lang { display: flex; justify-content: center; gap: 12px; margin-top: 16px;
  padding-top: 16px; border-top: 1px solid #262b34; font-size: 12px; }
.login-lang a { color: #666c76; text-decoration: none; }
.login-lang a:hover { color: #a3a9b3; }
.login-lang a.active { color: #477FB3; font-weight: 600; }

.main { padding: 24px 32px; overflow: auto; }
.main .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.main h2 { margin: 0; font-size: 18px; font-weight: 600; }
.main .top .muted { color: #8a919c; font-size: 12px; }

/* ===== Chips ===== */
.chip { display: inline-block; padding: 1px 8px; font-size: 11px; border-radius: 10px;
  background: #253244; color: #9ab8dd; margin-left: 8px; vertical-align: middle; }
.chip.locked  { background: #3a1e20; color: #ff6b6b; }
.chip.active  { background: #1f3a2a; color: #4caf50; }
.chip.pending { background: #2f2a1a; color: #ffb365; }
.chip.revoked { background: #3a1e20; color: #ff6b6b; }

/* ===== Panels / cards ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.panel { background: #171b22; border: 1px solid #262b34; border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 13px; color: #a3a9b3; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.stat { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.hint { font-size: 12px; color: #8a919c; margin-top: 4px; }

/* ===== Dashboard stat tiles ===== */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px; }
.tile { padding: 14px 16px; margin: 0; }
.tile-label { font-size: 11px; color: #8a919c; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 600; margin-bottom: 8px; }
.tile-value { font-size: 24px; font-weight: 700; letter-spacing: -.5px; color: #e6e6e6; }
.tile-primary .tile-value { color: #67a8dc; }
.tile-ok      .tile-value { color: #4caf50; }
.tile-danger  .tile-value { color: #ff6b6b; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; }
table th { text-align: left; padding: 10px 12px; font-size: 11px; color: #8a919c;
  font-weight: 600; text-transform: uppercase; border-bottom: 1px solid #262b34; }
table td { padding: 10px 12px; border-bottom: 1px solid #1d2229; font-size: 13px; }
table tr:hover td { background: #1a1f26; }
table td.actions { text-align: right; white-space: nowrap; }
table td.actions button { margin-left: 4px; padding: 4px 10px; font-size: 12px; }
table td.mono { font-family: Consolas, "SF Mono", monospace; font-size: 12px; color: #c0c0c0; }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar select, .toolbar input { padding: 7px 10px; font-size: 13px;
  background: #0f1216; border: 1px solid #2b313b; border-radius: 6px; color: #e6e6e6; }

/* ===== Modal ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #171b22; border: 1px solid #262b34; border-radius: 10px; padding: 24px;
  width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: #253244; color: #fff;
  padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.toast.err { background: #a1333a; }
.toast.ok  { background: #2a5d3a; }

/* ===== Responsive ===== */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; padding: 8px; }
  .sidebar .brand, .sidebar .meta { display: none; }
  .sidebar .nav { display: flex; gap: 4px; }
  .sidebar .nav a { padding: 6px 12px; border-left: 0; border-bottom: 2px solid transparent; }
  .sidebar .nav a.active { border-bottom-color: #477FB3; border-left: 0; }
  .main { padding: 16px; }
}
