:root {
  --primary: #34A853;
  /* requested green */
  --primary-600: #2c8f46;
  --primary-50: #e9f7ef;
  --bg: #0f1115;
  --panel: #151922;
  --panel-2: #1b2030;
  --text: #e6e8ee;
  --muted: #a8afc1;
  --line: #2a3142;
  --white: #ffffff;
}

/* Reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 80% -10%, rgba(52, 168, 83, .15), transparent 60%), var(--bg);
  color: var(--text);
  letter-spacing: 0.2px;
  background-repeat: no-repeat;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Components */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.card.pad {
  padding: 20px;
}

.shadow-soft {
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25), inset 0 1px 0 rgba(255, 255, 255, .02);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1000px) {
  .grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 700px) {

  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
  transition: .2s ease;
}

.btn.primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 8px 20px rgba(52, 168, 83, .35);
}

.btn.primary:hover {
  background: var(--primary-600);
  transform: translateY(-1px);
}

.btn.primary:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.icon {
  padding: 8px;
  border-radius: 10px;
}

.input,
select,
textarea {
  width: 100%;
  background: #0f1420;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: .2s;
}

.input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(52, 168, 83, .15);
}

.kbd {
  background: #0e1420;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #0f1522;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #0f1522;
  color: var(--muted);
}

.pill.ok {
  color: #0cd17a;
  border-color: rgba(12, 209, 122, .25);
}

.pill.warn {
  color: #ffb020;
  border-color: rgba(255, 176, 32, .25);
}

.pill.danger {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, .25);
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 10px 12px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
}

.tab.active {
  color: var(--text);
  border-color: var(--line);
  border-bottom-color: transparent;
  background: #0f1420;
}

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(15, 17, 21, .6);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .2px;
}

.logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: conic-gradient(from 120deg, var(--primary), #8ef0b0 40%, var(--primary) 90%);
  box-shadow: 0 0 0 2px rgba(52, 168, 83, .3) inset;
}

.footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-bottom: 40px;
}

.hidden {
  display: none !important;
}

.toast {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.licenses-search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.licenses-search input {
  width: 280px;
}

/* Responsive device views */
.devices-table-view {
  display: block;
}

.devices-cards-view {
  display: none;
}

@media (max-width: 768px) {
  .devices-table-view {
    display: none;
  }

  .devices-cards-view {
    display: block;
  }
}

/* --- Mobile fixes --- */
@media (max-width: 600px) {
  .header-inner {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  .toolbar {
    width: 100%;
    justify-content: center;
  }

  .licenses-search {
    flex-direction: column;
  }

  .licenses-search input {
    width: 100%;
  }

  .sharing-popup .device-meta {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 2px !important;
  }

  .sharing-popup .mdot {
    display: none;
  }
}

@media (max-width: 500px) {
  .grid.cols-2 {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 400px) {
  .card.pad {
    padding: 14px;
  }

  h1,
  h2,
  h3,
  h4 {
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  .toast {
    bottom: 10px !important;
    right: 10px !important;
    left: 10px;
    max-width: calc(100% - 20px);
  }
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--line);
  transition: .3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch input:checked+.toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked+.toggle-slider:before {
  transform: translateX(20px);
}

.toggle-switch input:disabled+.toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch input:disabled+.toggle-slider:before {
  cursor: not-allowed;
}

/* Danger button styles */
.btn.danger {
  background: transparent;
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.btn.danger:hover {
  background: #ff6b6b;
  color: var(--white);
  border-color: #ff6b6b;
  transform: translateY(-1px);
}

/* Logout button styles */
.btn.logout {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.logout:hover {
  background: #ff6b6b;
  color: var(--white);
  border-color: #ff6b6b;
  transform: translateY(-1px);
}

/* Device name permission states */
.device-name-editable {
  cursor: pointer;
  color: var(--primary);
}

.device-name-editable:hover {
  color: var(--primary-600);
}

.device-name-readonly {
  cursor: default;
  color: var(--text);
}