:root {
  --bg:        #0e0f12;
  --surface:   #16181d;
  --surface-2: #1e2128;
  --border:    #2a2d33;
  --fg:        #e9ecef;
  --muted:     #9aa3ad;
  --accent:    #f5a623;
  --accent-fg: #1a1207;
  --danger:    #e5484d;
  --ok:        #3ddc84;
  --radius:    8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: -.02em;
}
.topbar nav { display: flex; gap: 1.2rem; align-items: center; }
.topbar nav a { color: var(--fg); font-size: .95rem; }
.topbar nav a.active { color: var(--accent); }
.topbar .user { color: var(--muted); font-size: .85rem; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

/* Flash */
.flash { margin: 0 0 1rem; }
.flash-item {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: .5rem;
  font-size: .9rem;
}
.flash-ok    { background: rgba(61,220,132,.1);  border: 1px solid rgba(61,220,132,.3);  color: #b6f0cf; }
.flash-error { background: rgba(229,72,77,.1);   border: 1px solid rgba(229,72,77,.3);   color: #ffb8ba; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.card + .card { margin-top: 1rem; }

/* Forms */
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; margin-bottom: .3rem; font-size: .85rem; color: var(--muted); }
.form-row input[type=text],
.form-row input[type=email],
.form-row input[type=password],
.form-row select {
  width: 100%;
  padding: .55rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: .95rem;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row .hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.form-row.inline { display: flex; align-items: center; gap: .5rem; }
.form-row.inline input[type=checkbox] { width: auto; }
.form-row.inline label { margin: 0; color: var(--fg); }

.btn {
  display: inline-block;
  padding: .55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg);
  font-size: .9rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(229,72,77,.4); }
.btn-danger:hover { background: rgba(229,72,77,.1); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }

/* Tables */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
table.data th, table.data td {
  text-align: left;
  padding: .65rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
table.data th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data tr:hover td { background: var(--surface-2); }

.pill {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pill-ok    { background: rgba(61,220,132,.12); color: #a4ecc4; border-color: rgba(61,220,132,.3); }
.pill-mute  { color: var(--muted); }

/* Matrix */
table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
table.matrix th, table.matrix td {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.matrix thead th {
  position: sticky; top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 500;
  text-align: center;
}
table.matrix thead th:first-child { text-align: left; }
table.matrix td.perm-name { color: var(--fg); }
table.matrix td.perm-name small { color: var(--muted); display: block; font-size: .75rem; }
table.matrix td.cell { text-align: center; }
table.matrix tr.group-header td {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
table.matrix tr.locked td.cell { color: var(--muted); }

.actions { display: flex; gap: .5rem; margin-top: 1.5rem; }

/* Login centered */
.login-wrap {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--accent);
  font-size: 1.8rem;
}
