* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: rgba(17, 24, 39, 0.92);
  --panel-strong: #111827;
  --surface: rgba(15, 23, 42, 0.9);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #e5e7eb;
  --muted: rgba(226, 232, 240, 0.62);
  --link: #93c5fd;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --danger: #ef4444;
  --success: #22c55e;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 8px 20px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --radius-sm: 10px;
  --focus: 0 0 0 4px rgba(59, 130, 246, 0.22);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    "Apple Color Emoji",
    "Segoe UI Emoji";
  background:
    radial-gradient(1100px 550px at 15% -10%, rgba(59, 130, 246, 0.16), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(34, 197, 94, 0.12), transparent 60%),
    radial-gradient(700px 450px at 70% 110%, rgba(236, 72, 153, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  letter-spacing: 0.1px;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
textarea {
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "DejaVu Sans Mono",
    monospace;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: rgba(17, 24, 39, 0.72);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-soft);
}

.auth-card {
  width: min(100%, 460px);
}

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

.two-column {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.user-grids {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}

.user-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(15, 23, 42, 0.82);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(1200px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.modal-grid-single {
  grid-template-columns: 1fr;
}

.modal-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(15, 23, 42, 0.72);
}

.dropzone {
  border: 1px dashed rgba(148, 163, 184, 0.48);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: rgba(59, 130, 246, 0.08);
}

.dropzone-secondary {
  background: rgba(15, 23, 42, 0.55);
}

.dropzone.dragover {
  border-color: rgba(96, 165, 250, 0.9);
  box-shadow: var(--focus);
  background: rgba(59, 130, 246, 0.14);
}

.folder-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.assigned-list {
  min-height: 120px;
}

.folder-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: rgba(17, 24, 39, 0.88);
  cursor: grab;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.folder-pill.assigned {
  border-color: rgba(59, 130, 246, 0.75);
  background: rgba(37, 99, 235, 0.12);
}

.folder-pill-content {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.folder-pill-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.folder-pill code {
  white-space: normal;
  word-break: break-word;
}

.grant-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid transparent;
  letter-spacing: 0.2px;
}

.grant-type-badge.folder_group {
  background: rgba(59, 130, 246, 0.15);
  color: #bfdbfe;
  border-color: rgba(96, 165, 250, 0.35);
}

.grant-type-badge.folder {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.35);
}

.grant-type-badge.resource {
  background: rgba(34, 197, 94, 0.15);
  color: #bbf7d0;
  border-color: rgba(74, 222, 128, 0.35);
}

.compact {
  padding: 0.45rem 0.7rem;
}

.hidden {
  display: none;
}

.user-card-header h3 {
  margin: 0 0 0.35rem;
}

.grant-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.grant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid #334155;
  border-radius: 999px;
  background: #111827;
}

.grant-chip code {
  white-space: nowrap;
}

.grant-chip button {
  padding: 0.45rem 0.7rem;
}

.grant-add-form input {
  width: 100%;
}

.panel-link {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
}

.path-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.72);
}

.stack {
  display: grid;
  gap: 0.85rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.spread {
  justify-content: space-between;
}

.inline-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

label span {
  display: block;
  margin-bottom: 0.35rem;
  color: rgba(226, 232, 240, 0.76);
}

input,
select,
textarea,
button,
.button {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  padding: 0.8rem 0.95rem;
  font-size: 0.95rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.9);
  box-shadow: var(--focus);
}

textarea {
  resize: vertical;
}

textarea.editor {
  min-height: 70vh;
}

button,
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.95));
  width: auto;
  border-color: rgba(96, 165, 250, 0.45);
}

button:hover,
.button:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.85);
}

button:active,
.button:active {
  transform: translateY(0);
}

button.secondary,
.button.secondary {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(148, 163, 184, 0.28);
}

button.danger,
.button.danger {
  background: rgba(185, 28, 28, 0.92);
  border-color: rgba(248, 113, 113, 0.35);
}

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

th,
td {
  padding: 0.8rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  vertical-align: top;
  text-align: left;
}

thead th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(226, 232, 240, 0.66);
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.06);
}

pre {
  white-space: pre-wrap;
  margin: 0;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.alert.success {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: rgba(220, 252, 231, 0.95);
}

.alert.error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: rgba(254, 226, 226, 0.95);
}

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

.pathbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.58);
}

.path-seg {
  color: rgba(226, 232, 240, 0.9);
  text-decoration: none;
  padding: 0.25rem 0.45rem;
  border-radius: 10px;
}

.path-seg:hover {
  background: rgba(59, 130, 246, 0.12);
  text-decoration: none;
}

.path-sep {
  color: rgba(226, 232, 240, 0.35);
}

.explorer-table td:first-child {
  width: 44%;
}

.explorer-name {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.explorer-icon {
  width: 26px;
  height: 26px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.18);
  flex: 0 0 auto;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}

.explorer-icon.folder {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%2393c5fd' d='M2.5 5.5A2.5 2.5 0 0 1 5 3h3.4c.6 0 1.1.2 1.5.6l.9.9c.2.2.5.3.8.3H15A2.5 2.5 0 0 1 17.5 7.3v7.2A2.5 2.5 0 0 1 15 17H5A2.5 2.5 0 0 1 2.5 14.5V5.5Zm2.5-.5A.5.5 0 0 0 4.5 5.5v9A.5.5 0 0 0 5 15h10a.5.5 0 0 0 .5-.5V7.3a.5.5 0 0 0-.5-.5h-3.6c-.8 0-1.6-.3-2.1-.9l-.8-.8A.5.5 0 0 0 8.4 5H5Z'/%3E%3C/svg%3E");
}

.explorer-icon.file {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='%23cbd5e1' d='M6 2.5A2.5 2.5 0 0 0 3.5 5v10A2.5 2.5 0 0 0 6 17.5h8A2.5 2.5 0 0 0 16.5 15V7.2c0-.7-.3-1.3-.8-1.8l-2-2c-.5-.5-1.1-.9-1.8-.9H6Zm0 2h5.9c.1 0 .3.1.4.2l2 2c.1.1.2.3.2.4V15a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V5A.5.5 0 0 1 6 4.5Zm2 5h4v1H8v-1Zm0 2.5h6v1H8v-1Z'/%3E%3C/svg%3E");
}

.explorer-name a,
.explorer-name code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
}

.folder-tree {
  gap: 0.6rem;
}

.tree-node {
  display: grid;
  gap: 0.35rem;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.72);
  padding: 0.7rem 0.85rem;
  position: relative;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.tree-row:hover {
  background: rgba(59, 130, 246, 0.07);
  border-color: rgba(96, 165, 250, 0.35);
}

.tree-row-draggable {
  cursor: grab;
}

.tree-row-main {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex: 1;
}

.tree-guides {
  height: 30px;
  flex: 0 0 auto;
  background-image: repeating-linear-gradient(
    to right,
    transparent 0px,
    transparent 8px,
    rgba(148, 163, 184, 0.22) 8px,
    rgba(148, 163, 184, 0.22) 9px,
    transparent 9px,
    transparent 18px
  );
  opacity: 0.9;
}

.tree-row:hover .tree-guides {
  background-image: repeating-linear-gradient(
    to right,
    transparent 0px,
    transparent 8px,
    rgba(96, 165, 250, 0.28) 8px,
    rgba(96, 165, 250, 0.28) 9px,
    transparent 9px,
    transparent 18px
  );
}

.tree-row-content {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.tree-row-content code {
  white-space: normal;
  word-break: break-word;
}

.tree-toggle {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.4);
  color: rgba(226, 232, 240, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
  font-size: 0.95rem;
  transform: none;
}

.tree-toggle:hover:not(:disabled) {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(59, 130, 246, 0.12);
}

.tree-toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

.tree-action {
  flex: 0 0 auto;
  transform: none;
}

.tree-action:hover {
  transform: none;
}

.tree-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
  flex: 0 0 auto;
}

.tree-row.is-selected {
  border-color: rgba(59, 130, 246, 0.72);
  background: rgba(59, 130, 246, 0.08);
}
