:root {
  --bg: #0f1419;
  --bg-elev: #1a2029;
  --bg-elev-2: #232b37;
  --border: #2d3748;
  --text: #e2e8f0;
  --text-muted: #8b95a5;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --warn: #f59e0b;
  --radius: 6px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: #0a0e13;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
  flex-shrink: 0;
}
.sidebar .brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 0 20px 18px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar nav { display: flex; flex-direction: column; padding: 0 12px; gap: 2px; }
.sidebar nav a {
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
}
.sidebar nav a:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--bg-elev); color: var(--text); }
.sidebar nav a.muted { margin-top: auto; color: var(--text-muted); font-size: 12px; }

.content { flex: 1; padding: 28px 32px; min-width: 0; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; font-weight: 600; }
.page-head h3 { font-size: 16px; font-weight: 600; margin-top: 8px; }
.page-head .hint { color: var(--text-muted); margin-top: 4px; font-size: 13px; }

.flash {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  color: var(--text);
}
.flash.error { border-left-color: var(--danger); }
.flash.success { border-left-color: var(--success); }

.btn {
  display: inline-block;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  text-decoration: none;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; text-align: center; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.role-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s;
}
.role-card:hover { border-color: var(--primary); }
.role-card h3 { font-size: 16px; font-weight: 600; }
.role-card .arn { color: var(--text-muted); font-size: 12px; word-break: break-all; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.role-card .desc { color: var(--text); font-size: 13px; }
.role-card .remark { color: var(--warn); font-size: 12px; }
.role-card .btn { margin-top: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: block;
  color: var(--text);
}
.stat-card:hover { text-decoration: none; }
.stat-card .n { font-size: 28px; font-weight: 700; }
.stat-card .l { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.table-wrap { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; background: var(--bg-elev-2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td.arn, .arn { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; word-break: break-all; }
.actions-col { white-space: nowrap; text-align: right; }
.inline { display: inline; }

.form { max-width: 640px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; background: var(--bg-elev); }
legend { padding: 0 8px; color: var(--text-muted); font-size: 13px; font-weight: 600; }
label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--text); }
label > input, label > select { display: block; width: 100%; margin-top: 6px; }
input[type="text"], input[type="password"], input[type="email"], input[type="search"], select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
input:disabled { opacity: .55; cursor: not-allowed; }
label.checkbox { display: flex; align-items: center; gap: 8px; }
label.checkbox input { width: auto; margin: 0; }
label small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.form-actions { display: flex; gap: 10px; }

.bind-form { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.bind-form h4 { font-size: 14px; margin-bottom: 10px; }
.bind-form .row { display: flex; gap: 8px; align-items: center; }
.bind-form .row select { flex: 1; }
.bind-form .row input { flex: 1; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: var(--bg-elev-2); color: var(--text-muted); }
.badge.ok { background: rgba(16,185,129,.15); color: var(--success); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warn); }

.muted { color: var(--text-muted); }
.empty { background: var(--bg-elev); border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--text-muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.login-wrap { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.login-card h1 { font-size: 28px; font-weight: 700; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 20px; font-size: 13px; }
.login-card label { margin-bottom: 14px; }
.login-card .btn.block { margin-top: 6px; }

.redirecting { text-align: center; padding: 60px 20px; color: var(--text-muted); }

@media (max-width: 640px) {
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .app { flex-direction: column; }
  .content { padding: 18px; }
  .page-head { flex-direction: column; align-items: stretch; }
}
