* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #111316;
  color: #e9eded;
  font: 16px/1.5 system-ui;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

aside {
  background: #090b0d;
  border-right: 1px solid #34373b;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

aside img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

strong {
  font-size: 23px;
  color: #ffcf4d;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

aside nav {
  flex-direction: column;
}

footer {
  margin-top: auto;
}

main {
  padding: clamp(22px, 5vw, 70px);
  max-width: 1180px;
  width: 100%;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 22px;
  margin-top: 32px;
}

section h2 {
  margin: 0 0 8px;
}

a {
  color: #eee;
  text-decoration-color: #797e86;
  text-underline-offset: 5px;
}

.active, a:hover {
  color: #ffcf4d;
}

form, section, details {
  background: #1b1e22;
  padding: 18px;
  margin: 16px 0;
  border: 1px solid #373b40;
  border-radius: 8px;
}

form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 14px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 14px;
}

input, select, button, textarea {
  font: inherit;
  padding: 6px 9px;
  border: 1px solid #626871;
  border-radius: 4px;
  background: #121417;
  color: #fff;
}

.template-editor {
  width: 100%;
  min-width: 0;
}

.template-editor textarea {
  width: 100%;
  resize: vertical;
  font-family: monospace;
}

button, a.button {
  padding: 6px 9px;
  background: #ffcf4d;
  color: #151515;
  font-weight: 650;
  cursor: pointer;
}

a.button {
  padding: 6px 9px;
  display: inline-block;
  font: inherit;
  font-weight: 650;
  border: 1px solid #626871;
  border-radius: 4px;
  text-decoration: none;
}

section {
  padding: 12px 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 6px;
  border-bottom: 1px solid #3b4046;
  text-align: left;
}

small, th {
  color: #b0b8be;
}

pre {
  overflow: auto;
  background: #101215;
  padding: 15px;
}

summary {
  cursor: pointer;
}

p[role=status] {
  border-left: 3px solid #ffcf4d;
  padding: 8px 12px;
}

footer form, section form {
  display: inline-flex;
  margin: 4px;
  padding: 0;
  border: 0;
}

form[action="/login"] {
  flex-direction: column;
  align-items: center;
}

form[action="/login"] label,
form[action="/login"] button {
  width: 100%;
  max-width: 220px;
  text-align: center;
}

form[action="/login"] input {
  width: 100%;
  min-width: 0;
}

input[type=checkbox] {
  width: auto;
}

input[name="publica"],
input[name="server_key"] {
  width: 380px;
  max-width: 100%;
}

form[action="/alterar/mikrotik"] input[name="privada"] {
  width: 380px;
  max-width: 100%;
}

form[action="/alterar/alterar-peer"] input[name="nome"],
form[action="/alterar/peer"] input[name="nome"]{
  width: 140px;
}

.private-access-list {
  overflow-x: auto;
}

.private-access-list table {
  min-width: 760px;
}

.ihm-list table {
  min-width: 520px;
}

.ihm-list .device-type,
form[action="/alterar/ihm"] .device-type {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  white-space: nowrap;
}

.ihm-list .device-type {
  justify-content: flex-start;
}

.users-list input[name="usuario"],
.users-list input[name="senha"] {
  width: 180px;
}

.private-access-list td {
  vertical-align: top;
}

.private-access-list input[name="octeto"] {
  width: 90px;
}

.private-access-list input[name="nome"] {
  width: 160px;
}

.private-access-list input[name="publica"] {
  width: 410px;
  font-family: monospace;
}

.private-access-list input[name="privada"] {
  width: 210px;
}

.private-access-list small {
  display: block;
  max-width: 150px;
  margin-top: 6px;
}

.private-access-list form {
  background: transparent;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  align-items: center;
  gap: 8px;
}

.private-access-list button,
.private-access-list a.button {
  background: transparent;
  color: inherit;
  font-weight: 400;
}

.peer-list table {
  min-width: 600px;
}

.peer-list .peer-summary td {
  border-bottom: 0;
  padding-bottom: 6px;
}

.peer-list .peer-summary td:first-child,
.peer-list .peer-summary td:last-child {
  width: 1%;
  white-space: nowrap;
}

.peer-list form {
  flex-wrap: nowrap;
}

.peer-list .peer-key-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.peer-list .peer-key-fields input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.private-access-list button:hover,
.private-access-list a.button:hover {
  border-color: #ffcf4d;
  color: #ffcf4d;
}

.event-help summary {
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid #626871;
  border-radius: 4px;
}

.event-help-content {
  max-height: 360px;
  overflow: auto;
  margin-top: 12px;
  font-size: 14px;
}

.history-table-container {
  overflow-x: auto;
}

.history-table {
  table-layout: fixed;
  min-width: 640px;
}

.history-table .history-event { width: 35%; }
.history-table .history-factory { width: 15%; }
.history-table .history-user { width: 25%; }
.history-table .history-date { width: 25%; }

.history-table th,
.history-table td {
  overflow-wrap: anywhere;
}

.history-pagination {
  align-items: center;
  gap: 6px;
  margin: 18px 0;
}

.history-pagination a,
.history-pagination .current,
.history-pagination .disabled {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 34px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  text-decoration: none;
}

.history-pagination .current {
  border-color: #ffcf4d;
  color: #ffcf4d;
}

.history-pagination a:hover {
  border-color: #626871;
}

.history-pagination .disabled {
  color: #737981;
  cursor: default;
}

@media (max-width:700px) {
  body {
    display: block;
  }
  aside {
    padding: 14px;
  }
  aside nav {
    flex-direction: row;
  }
  main {
    padding: 18px;
  }
  table {
    font-size: 14px;
  }
}
