:root {
  --bg-top: #0f1418;
  --bg-bottom: #182027;
  --window: rgba(25, 31, 38, 0.92);
  --window-strong: #202831;
  --border: rgba(198, 150, 62, 0.16);
  --border-strong: rgba(198, 150, 62, 0.34);
  --ink: #e9dcc5;
  --muted: #9f947f;
  --accent: #ba8c32;
  --accent-strong: #8f651d;
  --gold: #c1902f;
  --danger: #b45444;
  --danger-strong: #8f3427;
  --shadow: 0 22px 50px rgba(0, 0, 0, 0.32);
  --radius: 18px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(193, 144, 47, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(56, 87, 101, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.shell {
  width: min(1500px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 12px 0 18px;
}

.hidden {
  display: none !important;
}

.login-panel {
  min-height: calc(100vh - 56px);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  align-items: center;
}

.login-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(2.7rem, 6vw, 4.5rem);
  line-height: 0.92;
  max-width: 8ch;
}

.intro,
.muted,
.window-meta,
.status,
.pill-label,
.eyebrow {
  color: var(--muted);
}

.login-card,
.window,
.pill {
  background: var(--window);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.login-card {
  padding: 20px;
}

input,
select,
textarea,
button {
  font: inherit;
}

label {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(198, 150, 62, 0.15);
  background: rgba(12, 16, 20, 0.92);
  color: var(--ink);
}

button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #12151a;
  cursor: pointer;
  font-weight: 600;
}

button.ghost {
  background: rgba(30, 38, 46, 0.98);
  color: var(--ink);
  border: 1px solid var(--border);
}

button.danger {
  background: linear-gradient(135deg, var(--danger) 0%, var(--danger-strong) 100%);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 10px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 12px;
  min-width: 180px;
}

.pill strong {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 10px;
}

.desktop {
  display: grid;
  gap: 10px;
}

.breadcrumb-bar .window-body {
  padding: 10px 12px;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.breadcrumb-item {
  min-width: 0;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(198, 150, 62, 0.14);
  background: rgba(17, 22, 28, 0.86);
  color: var(--ink);
}

.breadcrumb-item.active {
  background: rgba(186, 140, 50, 0.16);
  border-color: rgba(186, 140, 50, 0.3);
}

.breadcrumb-sep {
  color: var(--muted);
}

.window-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.window-wide {
  grid-column: 2;
}

.side-column {
  grid-column: 1;
}

.main-column {
  grid-column: 2;
}

.window-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(42, 50, 58, 0.98) 0%, rgba(29, 36, 44, 0.98) 100%);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}

.window-dots {
  display: flex;
  gap: 6px;
}

.window-dots span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  display: block;
  background: #e5b44c;
}

.window-dots span:first-child {
  background: #d97764;
}

.window-dots span:last-child {
  background: #5ca48b;
}

.window-meta {
  margin-left: auto;
  font-size: 0.87rem;
}

.title-action {
  margin-left: auto;
  padding: 4px 10px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  border: 1px solid var(--border);
}

.window-body {
  padding: 10px;
}

.explorer-body {
  padding: 10px;
}

.explorer-current {
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(17, 22, 28, 0.72);
  border: 1px solid rgba(198, 150, 62, 0.1);
}

.tree-root,
.tree-node {
  display: grid;
  gap: 2px;
}

.tree-row {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 4px;
  align-items: center;
}

.tree-toggle {
  width: 16px;
  height: 16px;
  border-radius: 6px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 11px;
}

.tree-toggle:hover {
  background: rgba(186, 140, 50, 0.1);
  border-color: rgba(186, 140, 50, 0.16);
}

.tree-toggle.empty {
  cursor: default;
  opacity: 0.28;
}

.tree-button {
  width: 100%;
  padding: 5px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
}

.tree-button:hover,
.tree-button.active {
  background: rgba(186, 140, 50, 0.12);
  border-color: rgba(186, 140, 50, 0.22);
}

.tree-entry {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tree-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-folder-icon,
.tile-icon {
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
}

.tree-folder-icon {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(180deg, #d2a24a 0%, #8e631f 100%);
  box-shadow: inset 0 0 0 1px rgba(88, 58, 12, 0.16);
}

.tree-folder-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: -3px;
  width: 8px;
  height: 5px;
  border-radius: 3px 3px 0 0;
  background: #e7ca83;
}

.tree-children {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 1px solid rgba(76, 55, 36, 0.1);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric-tile {
  padding: 11px;
  border-radius: 14px;
  background: rgba(17, 22, 28, 0.86);
  border: 1px solid var(--border);
}

.metric-tile span,
.metric-tile strong {
  display: block;
}

.metric-tile strong {
  font-size: 1.5rem;
}

.folder-grid {
  display: grid;
  gap: 8px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 8px;
}

.access-section {
  gap: 12px;
}

.access-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(17, 22, 28, 0.82);
  border: 1px solid var(--border);
}

.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.access-card textarea,
.access-card input {
  background: rgba(11, 15, 19, 0.95);
}

.subpanel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(14, 19, 24, 0.78);
}

.subpanel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.item-section {
  display: grid;
  gap: 10px;
}

.item-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.item-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.desktop-tile {
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(17, 22, 28, 0.94);
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 4px;
  min-height: 76px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.desktop-tile:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.empty-tile {
  cursor: default;
}

.desktop-tile strong,
.desktop-tile small {
  display: block;
}

.tile-topline,
.tile-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.device-id-panel {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(10, 13, 17, 0.9);
  border: 1px solid rgba(198, 150, 62, 0.14);
}

.device-id-panel code {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.device-role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.role-main {
  background: rgba(186, 140, 50, 0.18);
  border: 1px solid rgba(186, 140, 50, 0.3);
  color: #f1d08d;
}

.role-secondary {
  background: rgba(92, 164, 139, 0.14);
  border: 1px solid rgba(92, 164, 139, 0.28);
  color: #b7e5d5;
}

.tile-copy-button {
  position: relative;
  z-index: 1;
}

.tile-icon {
  width: 30px;
  height: 26px;
}

.tile-icon-folder {
  border-radius: 8px;
  background: linear-gradient(180deg, #ddb761 0%, #c38e2f 100%);
}

.tile-icon-folder::before {
  content: "";
  position: absolute;
  left: 2px;
  top: -7px;
  width: 16px;
  height: 10px;
  border-radius: 8px 8px 0 0;
  background: #eed79d;
}

.tile-icon-user {
  border-radius: 50% 50% 40% 40%;
  background: linear-gradient(180deg, #6e95cf 0%, #4f72aa 100%);
}

.tile-icon-user::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
}

.tile-icon-device {
  border-radius: 7px;
  background: linear-gradient(180deg, #7b8d93 0%, #53656d 100%);
}

.tile-icon-device::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  width: 28px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.3);
}

.section-empty {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: rgba(17, 22, 28, 0.6);
}

.form-grid {
  display: grid;
  gap: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-row input {
  width: auto;
}

.info-row {
  display: grid;
  gap: 5px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(198, 150, 62, 0.08);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row-key strong {
  word-break: break-all;
}

.connection-body .button-row {
  margin-top: 8px;
}

.qr-section {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.connection-qr {
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: 16px;
  background: #f6f0e4;
  border: 1px solid rgba(198, 150, 62, 0.2);
}

.connection-qr svg {
  width: min(100%, 220px);
  height: auto;
  display: block;
}

#connection-qr-payload {
  min-height: 82px;
  resize: vertical;
}

.status {
  min-height: 1.2em;
}

.muted-window {
  opacity: 0.58;
}

.action-list {
  display: grid;
  gap: 8px;
}

.action-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.action-button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(198, 150, 62, 0.16);
  background: rgba(17, 22, 28, 0.92);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-start;
  text-align: left;
}

.action-button:disabled {
  background: rgba(17, 22, 28, 0.72);
  color: var(--muted);
}

.action-button strong,
.action-button small {
  display: block;
}

.action-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #11151a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.compact-toolbar {
  padding-block: 8px;
}

.compact-action {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 12px;
  justify-content: center;
}

.compact-action strong {
  white-space: normal;
  font-size: 0.92rem;
}

.drop-target-active {
  border-color: rgba(186, 140, 50, 0.6) !important;
  box-shadow: inset 0 0 0 1px rgba(186, 140, 50, 0.28);
  background: rgba(186, 140, 50, 0.1) !important;
}

.dragging {
  opacity: 0.55;
}

.context-menu {
  position: fixed;
  z-index: 30;
  min-width: 200px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(18, 23, 29, 0.98);
  border: 1px solid rgba(198, 150, 62, 0.18);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 4px;
}

.context-menu button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 9px 10px;
}

.context-menu button:hover:not(:disabled) {
  background: rgba(186, 140, 50, 0.12);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 10, 14, 0.76);
  backdrop-filter: blur(8px);
}

.overlay-card {
  width: min(92vw, 620px);
  border-radius: var(--radius);
  background: var(--window);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.overlay-body {
  display: grid;
  gap: 14px;
}

.overlay-qr {
  padding: 22px;
}

.overlay-qr svg {
  width: min(100%, 420px);
}

@media (max-width: 1180px) {
  .workspace,
  .window-grid,
  .login-panel {
    grid-template-columns: 1fr;
  }

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

  .window-wide {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 16px, 1500px);
  }

  .topbar,
  .topbar-actions,
  .item-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .action-toolbar,
  .content-grid,
  .item-section-grid {
    grid-template-columns: 1fr;
  }
}
