:root {
  --wine: #722f37;
  --wine-dark: #5a252c;
  --wine-light: #9c4a54;
  --bg: #f7f5f2;
  --card: #ffffff;
  --ink: #2b2320;
  --muted: #7a6f6a;
  --line: #e7e0da;
  --ok: #2e7d46;
  --err: #b3372f;
  --warn: #b07a1e;
  --radius: 10px;
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); min-height: 100vh;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(160deg, var(--wine-dark) 0%, var(--wine) 55%, #3c1a1f 100%); }
.login-card { background: var(--card); border-radius: 14px; padding: 40px 36px; width: 380px; max-width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.brand { text-align: center; margin-bottom: 26px; }
.brand .logo { font-size: 40px; }
.brand h1 { font-size: 22px; letter-spacing: .4px; margin-top: 6px; }
.brand h1 span { color: var(--wine); }
.brand p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: .5px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfaf8; outline: none; }
.field input:focus, .field select:focus { border-color: var(--wine-light); box-shadow: 0 0 0 3px rgba(114,47,55,.12); }

.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 8px;
  padding: 10px 16px; font-weight: 600; }
.btn-primary { background: var(--wine); color: #fff; width: 100%; justify-content: center; padding: 12px; }
.btn-primary:hover { background: var(--wine-dark); }
.btn-ghost { background: transparent; color: var(--wine); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f2ece9; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn[disabled] { opacity: .6; cursor: default; }

.error-box { background: #fdecea; color: var(--err); border: 1px solid #f5c6c0; border-radius: 8px;
  padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; display: none; }
.error-box.show { display: block; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #241a1c; color: #d9cfc7; display: flex; flex-direction: column; }
.side .brand2 { padding: 20px 18px; font-weight: 700; color: #fff; font-size: 17px; border-bottom: 1px solid #3a2c2f; }
.side .brand2 small { display: block; font-weight: 400; color: #a08f88; font-size: 11.5px; margin-top: 2px; }
.nav { padding: 12px 8px; flex: 1; }
.nav button { display: flex; width: 100%; gap: 10px; align-items: center; background: none; border: none;
  color: #cdbeb6; padding: 11px 12px; border-radius: 8px; font-size: 14.5px; text-align: left; }
.nav button:hover { background: #33262a; color: #fff; }
.nav button.active { background: var(--wine); color: #fff; }
.side .foot { padding: 14px 16px; border-top: 1px solid #3a2c2f; font-size: 13px; }
.side .foot .who { color: #fff; font-weight: 600; }
.side .foot .role { color: #a08f88; font-size: 12px; text-transform: capitalize; }
.side .foot button { margin-top: 10px; width: 100%; background: #33262a; color: #d9cfc7; border: none;
  border-radius: 8px; padding: 8px; }
.side .foot button:hover { background: #45333a; }

.main { padding: 26px 32px; max-width: 1200px; }
.main h2 { font-size: 20px; margin-bottom: 4px; }
.main .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

/* ---------- cards & tables ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .code { font-weight: 700; color: var(--wine); font-size: 15px; }
.card .name { color: var(--muted); font-size: 12px; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .nums { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink); }
.card .nums b { display: block; font-size: 15px; }

.tbl-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; padding: 10px 14px; background: #f2ece9; color: #5c5049; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
td { padding: 9px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
tr:hover td { background: #faf7f5; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #e5f3e9; color: var(--ok); }
.badge.error { background: #fdecea; color: var(--err); }
.badge.running { background: #fdf3e0; color: var(--warn); }
.badge.role { background: #f0e6e7; color: var(--wine); text-transform: capitalize; }
.badge.off { background: #eee; color: #888; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,20,22,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--card); border-radius: 14px; padding: 26px; width: 420px; max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.modal h3 { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.temp-pass { background: #f2ece9; border: 1px dashed var(--wine-light); border-radius: 8px; padding: 12px;
  font-family: Consolas, monospace; font-size: 17px; text-align: center; letter-spacing: 1px; margin: 10px 0; }
.hint { font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }
