/* Buttons, form controls, tables, badges, dialogs and toasts. */
.icon { width: 20px; height: 20px; flex: none; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500;
}
.button:hover { background: var(--surface-alt); }
.button:disabled { opacity: 0.55; cursor: not-allowed; }
.button--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.button--primary:hover { background: var(--primary-hover); }
.button--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button--danger:hover { background: var(--danger-hover); }
.button--ghost { background: transparent; border-color: transparent; }
.button--small { min-height: 36px; padding: 0 10px; font-size: 0.9rem; }
.app-header .button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.app-header .button:hover { background: rgba(255, 255, 255, 0.12); }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border: 0; background: transparent; border-radius: var(--radius); cursor: pointer; color: inherit;
}
.icon-button:hover { background: rgba(127, 127, 127, 0.18); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: var(--gap); min-width: 0; }
.field label, .field__label { font-weight: 600; font-size: 0.95rem; }
.field__hint { font-size: 0.85rem; color: var(--text-muted); }
.input {
  width: 100%; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
}
textarea.input { min-height: 110px; resize: vertical; }
.input:disabled { background: var(--surface-alt); color: var(--text-muted); }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap); }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: var(--gap); }
.form-actions .spacer { margin-right: auto; }
.form-error { background: #fdecea; color: #7a1712; border: 1px solid #f2b8b5; border-radius: var(--radius); padding: 10px 12px; margin-bottom: var(--gap); }
.notice { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: var(--gap); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.table .actions { white-space: nowrap; text-align: right; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--surface-alt); border: 1px solid var(--border); }
.badge--ok { background: #e3f4e8; border-color: #b6dfc2; color: #14532d; }
.badge--off { background: #f1f1f1; color: #555; }
.badge--sev-informational { background: var(--sev-informational); border-color: var(--sev-informational); color: #fff; }
.badge--sev-medium { background: var(--sev-medium); border-color: var(--sev-medium); color: #fff; }
.badge--sev-high { background: var(--sev-high); border-color: var(--sev-high); color: #fff; }
.badge--sev-critical { background: var(--sev-critical); border-color: var(--sev-critical); color: #fff; }

.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-drag); }
.modal--wide { width: min(760px, calc(100vw - 24px)); }
.modal::backdrop { background: var(--overlay); }
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal__header h2 { margin: 0; font-size: 1.1rem; }
.modal__body { padding: 20px; }

.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: var(--radius); color: #fff; box-shadow: var(--shadow-drag); cursor: pointer; overflow-wrap: anywhere; }
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--info { background: #34495e; }

.menu { position: absolute; z-index: 50; min-width: 180px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-drag); padding: 4px; }
.menu button { display: flex; width: 100%; min-height: var(--tap); align-items: center; padding: 0 12px; border: 0; background: transparent; text-align: left; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-alt); }
.menu__label { padding: 8px 12px 4px; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: var(--gap); }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--gap); }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; }
.perm-group h3 { font-size: 0.95rem; margin: 0 0 4px; }
.empty { padding: 24px; text-align: center; color: var(--text-muted); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
