:root {
  --bg: #111;
  --card: #1a1a1a;
  --text: #eee;
  --accent: #2ecc71;
  --danger: #e74c3c
}

body {
  font-family: Inter, Segoe UI, Arial;
  background: #0f1720;
  color: var(--text);
  margin: 0;
  padding: 0
}

header {
  padding: 12px 20px;
  background: #081025;
  display: flex;
  align-items: center;
  justify-content: space-between
}

h1 {
  margin: 0;
  font-size: 18px
}

#info-bar {
  font-size: 13px;
  color: #9aa7b2
}

main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px;
  align-items: flex-start;  /* чтобы верх был ровный */
}

#ports-grid {
  display: grid;
  grid-template-columns: repeat(8, 64px);
  gap: 10px;
  flex-shrink: 0;  /* не даём сжиматься */
}

@media (max-width: 768px) {
  #ports-grid {
    grid-template-columns: repeat(6, 64px);
  }
}

.port {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .6)
}

.port-label {
  font-size: 12px
}

.port.down {
  background: #0b0b0b;
  color: #666;
  border: 1px solid #222
}

.port.up {
  background: linear-gradient(180deg, #1aa84a, #0b8b37);
  color: #032
}

.port.poe {
  position: relative;
  background: linear-gradient(180deg, #25c281, #1aa84a);
  color: #032
}

.port.poe::after {
  content: '⚡';
  position: absolute;
  right: 4px;
  top: 4px;
  font-size: 16px;
  color: gold
}

.port.disabled {
  background: linear-gradient(180deg, #e1524b, #b82f2f);
  color: #fff
}

#ports-table {
  flex: 1;  /* таблица занимает всё остальное пространство */
}

table {
  width: 100%;
  border-collapse: collapse
}

th,
td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #1a1a1a
}

button {
  padding: 6px 8px;
  border-radius: 4px;
  border: none;
  cursor: pointer
}

.btn-toggle {
  background: rgb(52, 152, 219);
  color: var(--text)
}

.btn-restart {
  background: rgb(243, 156, 18);
  color: var(--text)
}

small.muted {
  color: #9aa7b2
}


#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: #333;
    color: white;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.toast.success { background: #2ecc71; }
.toast.error { background: #e74c3c; }
.toast.loading { background: #3498db; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.toggle-switch input {
    display: none;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2ecc71;
}

input:checked + .slider:before {
    transform: translateX(20px);
}



/* === Адаптация для мобильных === */
@media (max-width: 1024px) {
    main {
        padding: 12px;
        gap: 12px;
    }

    .port {
        width: 56px;
        height: 56px;
        font-size: 11px;
    }

    table {
        font-size: 13px;
    }

    th, td {
        padding: 6px 8px;
    }

    /* Горизонтальная прокрутка для таблиц */
    #ports-table {
        width: 100%;
        overflow-x: auto;
    }

    table {
        min-width: 600px; /* чтобы таблица не ломалась на слишком маленьких экранах */
    }

    button {
        padding: 5px 6px;
        font-size: 12px;
    }
}

/* === Адаптация для очень маленьких экранов (< 600px) === */
@media (max-width: 600px) {
    h1 {
        font-size: 16px;
    }

    #info-bar {
        font-size: 12px;
    }

    .port {
        width: 48px;
        height: 48px;
        font-size: 10px;
    }

    /* Чтобы кнопки не были слишком большими */
    .btn-toggle, .btn-restart {
        font-size: 11px;
        padding: 4px 5px;
    }

    /* Контейнер тостов тоже чуть меньше */
    .toast {
        font-size: 12px;
        padding: 8px 10px;
    }
}
