:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #eef1f2;
  --ink: #172026;
  --muted: #66747c;
  --line: #dbe1e4;
  --nav: #152127;
  --nav-muted: #9fadb3;
  --accent: #25815d;
  --accent-dark: #176443;
  --danger: #b63b44;
  --warning: #a56412;
  --radius: 6px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: var(--nav); color: white; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 26px; font-size: 18px; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 5px; background: #49b985; color: #0d2118; }
.nav-label { margin: 12px 10px 8px; color: #728188; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.nav-link { display: flex; align-items: center; min-height: 42px; margin: 3px 0; padding: 0 12px; border-radius: 5px; color: var(--nav-muted); font-weight: 600; }
.nav-link:hover, .nav-link.active { background: #223139; color: white; }
.sidebar-footer { position: absolute; right: 16px; bottom: 20px; left: 16px; }
.logout-button { width: 100%; border: 1px solid #34454d; background: transparent; color: var(--nav-muted); }

.main { min-width: 0; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); }
.environment { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.admin-name { font-weight: 700; }
.content { width: min(1320px, 100%); margin: 0 auto; padding: 30px 32px 56px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; }
h2 { margin: 0 0 14px; font-size: 18px; }
.subtitle { margin: 6px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.stat-value { margin-top: 10px; font-size: 30px; font-weight: 800; }
.panel { margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; }
.panel-body { padding: 18px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8f9f9; color: var(--muted); font-size: 11px; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 5px; background: var(--surface-2); object-fit: cover; }
.avatar-fallback { display: grid; place-items: center; font-weight: 800; }
.primary { font-weight: 700; }
.secondary { margin-top: 2px; color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: #4c5c63; font-size: 11px; font-weight: 800; }
.badge-ACTIVE, .badge-PUBLISHED, .badge-RESOLVED, .badge-ACCEPTED { background: #e4f4ec; color: #176443; }
.badge-BANNED, .badge-ARCHIVED, .badge-DISMISSED, .badge-DISBANDED, .badge-DECLINED { background: #f8e6e8; color: #9a303a; }
.badge-SUSPENDED, .badge-DRAFT, .badge-OPEN, .badge-FORMING, .badge-PENDING { background: #fff1d8; color: #86520f; }
.badge-CANCELLED, .badge-EXPIRED { background: #eceff3; color: #52606d; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border: 1px solid transparent; border-radius: 5px; background: var(--accent); color: white; font-weight: 700; cursor: pointer; }
.button:hover { background: var(--accent-dark); }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }
.button-secondary:hover { background: var(--surface-2); }
.button-danger { background: var(--danger); }
.button-small { min-height: 32px; padding: 0 10px; font-size: 12px; }

.toolbar { display: flex; gap: 8px; }
.search { display: flex; width: min(460px, 100%); gap: 8px; }
.field, select, textarea { width: 100%; min-height: 40px; border: 1px solid #cbd4d8; border-radius: 5px; background: white; color: var(--ink); padding: 8px 10px; outline: none; }
.field:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,129,93,.12); }
textarea { min-height: 112px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-field { display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 12px; font-weight: 700; }
.hint { color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.inline-form { display: flex; align-items: center; gap: 8px; }
.inline-form select { min-width: 130px; }
.flash { margin-bottom: 16px; padding: 12px 14px; border: 1px solid #b9dfcc; border-radius: 5px; background: #ebf8f1; color: #176443; }
.empty { padding: 38px 18px; color: var(--muted); text-align: center; }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.definition-list { display: grid; grid-template-columns: 150px 1fr; margin: 0; }
.definition-list dt, .definition-list dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.definition-list dt { color: var(--muted); }
.schedule { display: flex; flex-wrap: wrap; gap: 7px; }
.schedule-item { padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: #f8f9f9; font-size: 12px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 420px) 1fr; background: white; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 54px; border-right: 1px solid var(--line); }
.login-brand { margin-bottom: 54px; font-size: 20px; font-weight: 800; }
.login-panel h1 { font-size: 32px; }
.login-form { display: grid; gap: 14px; margin-top: 30px; }
.login-message { padding: 10px 12px; border-radius: 5px; background: #f8e6e8; color: #9a303a; }
.login-aside { display: flex; align-items: end; padding: 64px; background: #152127; color: white; }
.login-aside p { max-width: 620px; margin: 0; color: #aebac0; font-size: 24px; line-height: 1.45; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .sidebar { padding: 20px 12px; }
  .brand { padding-inline: 8px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: flex; align-items: center; gap: 6px; overflow-x: auto; }
  .brand { padding: 0 12px 0 0; }
  .brand span:last-child, .nav-label, .sidebar-footer { display: none; }
  .nav-link { min-width: max-content; padding: 0 12px; }
  .topbar { padding: 0 18px; }
  .content { padding: 22px 16px 40px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stats, .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .login-page { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; padding: 30px; border: 0; }
  .login-aside { display: none; }
}
