:root {
  --bg: #e8efeb;
  --bg-soft: #f4f8f6;
  --surface: #ffffff;
  --ink: #101c18;
  --muted: #5a6a63;
  --line: #d2ddd7;
  --brand: #0d6a5a;
  --brand-deep: #08493e;
  --brand-soft: rgba(13, 106, 90, 0.12);
  --accent: #c45c26;
  --accent-soft: rgba(196, 92, 38, 0.12);
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.1);
  --ok: #067647;
  --ok-soft: rgba(6, 118, 71, 0.12);
  --sidebar: #0c1f1a;
  --sidebar-text: #dce8e3;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Vazirmatn", "Tahoma", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.7;
  background:
    radial-gradient(1000px 420px at 100% -8%, rgba(13, 106, 90, 0.14), transparent 55%),
    radial-gradient(820px 380px at 0% 110%, rgba(196, 92, 38, 0.1), transparent 50%),
    linear-gradient(180deg, #f2f6f4 0%, var(--bg) 40%, #e4ebe7 100%);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }

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

/* ——— Shell ——— */
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(500px 280px at 0% 0%, rgba(13, 106, 90, 0.35), transparent 70%),
    var(--sidebar);
  color: var(--sidebar-text);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  padding: 0 8px;
  animation: rise 0.55s var(--ease) both;
}

.brand-mark {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  line-height: 1.1;
}

.brand-tag {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #8eaaa2;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #c5d7d0;
  padding: 11px 12px;
  border-radius: 12px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  transform: translateX(-2px);
}

.nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 600;
}

.nav-ico {
  width: 1.25rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.95rem;
}

.nav-section {
  margin: 12px 8px 6px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #7f9890;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-foot .name { color: #fff; font-weight: 600; }
.usage { margin-top: 4px; font-size: 0.8rem; color: #8eaaa2; }

.usage-bar {
  margin-top: 10px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.usage-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #1d9b84);
  border-radius: inherit;
}

.main {
  padding: 28px 32px 48px;
  animation: rise 0.45s var(--ease) both;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.crumb {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.crumb a { font-weight: 600; }

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ——— Controls ——— */
label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field { width: 100%; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
input[type="color"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover { background: var(--brand-deep); }
.btn:active { transform: scale(0.98); }
.btn-secondary { background: #e2ebe7; color: var(--ink); }
.btn-secondary:hover { background: #d3dfd9; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); }
.btn-danger { background: var(--danger); }
.btn-accent { background: var(--accent); }
.btn-sm { padding: 7px 11px; font-size: 0.85rem; }
.btn-block { width: 100%; }

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  animation: rise 0.35s var(--ease) both;
}

.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}

.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar select { max-width: 160px; }

/* ——— File list ——— */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
  animation: rise 0.4s var(--ease) both;
}

.item:hover {
  border-color: #b7c9c1;
  transform: translateY(-1px);
  background: #fbfffd;
}

.item-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-deep);
  background: var(--brand-soft);
  position: relative;
}

.item-icon.is-folder { background: var(--accent-soft); color: var(--accent); }

.item-color-dot {
  position: absolute;
  inset-inline-end: -2px;
  bottom: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.item-title {
  font-weight: 700;
  color: var(--ink);
}

.item-title:hover { color: var(--brand); }

.item-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.menu {
  position: relative;
}

.menu-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  z-index: 20;
  display: none;
  animation: pop 0.18s var(--ease) both;
}

.menu.open .menu-panel { display: grid; gap: 2px; }

.menu-panel button,
.menu-panel a {
  display: block;
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}

.menu-panel button:hover,
.menu-panel a:hover { background: var(--bg-soft); }

.menu-panel .danger { color: var(--danger); }

.empty {
  text-align: center;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.45);
}

.empty h3 { margin: 0 0 8px; }
.empty p { margin: 0 0 18px; color: var(--muted); }

/* ——— Gallery / tables ——— */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.gallery-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s var(--ease);
}

.gallery-card:hover { transform: translateY(-2px); }

.gallery-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #dfe8e4;
}

.gallery-card .cap {
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: right;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}
th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
}

/* ——— Auth / public ——— */
.auth-wrap,
.public-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-stage {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  animation: rise 0.55s var(--ease) both;
}

.auth-hero {
  padding: 48px 40px;
  background:
    radial-gradient(620px 340px at 15% 0%, rgba(252, 168, 48, 0.28), transparent 55%),
    radial-gradient(520px 280px at 90% 80%, rgba(72, 168, 216, 0.35), transparent 60%),
    linear-gradient(160deg, #0c3c6c 0%, #1a6fa0 48%, #48a8d8 100%);
  color: #eef7fc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 520px;
}

.auth-hero .brand-mark {
  font-size: 2.6rem;
}

.auth-hero h2 {
  margin: 24px 0 10px;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.35;
  max-width: 14ch;
}

.auth-hero p {
  margin: 0;
  color: #c5e4f4;
  max-width: 28ch;
}

.auth-hero .brand-tag {
  color: #fca830 !important;
}

.auth-panel {
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-panel h1 {
  margin: 0 0 8px;
  font-size: 1.55rem;
}

.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }

.security-level-field {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 0;
  display: grid;
  gap: 10px;
}
.security-level-field legend {
  padding: 0 6px;
  font-weight: 700;
  font-size: .95rem;
}
.security-level-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
}
.security-level-option:has(input:checked) {
  border-color: var(--brand, #0d6a5a);
  box-shadow: 0 0 0 1px var(--brand, #0d6a5a);
}
.security-level-option input {
  margin-top: 4px;
  flex-shrink: 0;
}
.security-level-option span {
  display: grid;
  gap: 4px;
}
.security-level-option strong {
  font-size: .95rem;
}
.security-level-option small {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.55;
}

.public-card,
.auth-card-simple {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 32px;
  animation: rise 0.45s var(--ease) both;
}

.public-card h1,
.auth-card-simple h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

.file-chip {
  margin: 18px 0;
  padding: 14px;
  border-radius: 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}

/* ——— Modal ——— */
.modal-root[hidden] { display: none !important; }

.modal-root {
  position: fixed;
  inset: 0;
  /* باید بالاتر از .ex-command (60–70) و منوها باشد؛ این فایل بعد از filegator.css لود می‌شود */
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 24, 20, 0.45);
  backdrop-filter: blur(3px);
  animation: fade 0.2s var(--ease) both;
}

.modal {
  position: relative;
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 22px;
  z-index: 1;
  animation: pop 0.22s var(--ease) both;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.mobile-nav-btn {
  display: none;
  position: fixed;
  inset-inline-start: 16px;
  bottom: 16px;
  z-index: 40;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-tabs a {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.settings-tabs a.active,
.settings-tabs a:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.item-grid {
  grid-template-columns: 1fr;
  align-items: start;
}

.item-grid .item-icon {
  width: 100%;
  height: 120px;
  font-size: 1.4rem;
}

.item-grid .item-actions {
  width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}

.pager a {
  min-width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.pager a.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.preview-shell {
  overflow: hidden;
}

.wm-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 2;
  font-size: clamp(1.4rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(13, 106, 90, 0.18);
  transform: rotate(-18deg);
  user-select: none;
}

.doc-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Vazirmatn", ui-monospace, monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  max-height: 75vh;
  overflow: auto;
  background: #f7f8f7;
  border-radius: 12px;
  padding: 16px 18px;
}

/* FileGator-inspired browser */
.browser {
  position: relative;
  min-height: 60vh;
}

.browser.is-dragover .drop-overlay {
  display: grid;
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  background: rgba(12, 31, 26, 0.55);
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
}

.drop-overlay:not([hidden]) {
  display: grid;
}

.drop-overlay-card {
  background: var(--surface);
  color: var(--brand-deep);
  font-weight: 800;
  font-size: 1.15rem;
  padding: 28px 36px;
  border-radius: 14px;
  border: 2px dashed var(--brand);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.9rem;
}

.breadcrumb a {
  font-weight: 600;
}

.bc-sep {
  color: var(--muted);
  opacity: 0.7;
}

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

.toolbar-inline .search-input {
  min-width: 160px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.multi-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.multi-actions-idle,
.multi-actions-bulk {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.browser-table-wrap {
  padding: 0;
  overflow: auto;
}

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

.browser-table th,
.browser-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

.browser-table thead th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}

.browser-table tbody tr:hover {
  background: rgba(13, 106, 90, 0.04);
}

.browser-table tr.is-selected {
  background: var(--brand-soft);
}

.browser-table .col-check {
  width: 42px;
}

.browser-table .col-size {
  width: 110px;
  white-space: nowrap;
}

.browser-table .col-time {
  width: 170px;
  white-space: nowrap;
  font-size: 0.85rem;
}

.browser-table .col-actions {
  width: 1%;
  white-space: nowrap;
}

.name-link {
  color: var(--ink);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.name-link:hover {
  color: var(--brand);
}

.type-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 26px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

.type-badge.is-folder {
  background: var(--brand-soft);
  color: var(--brand-deep);
  border-color: transparent;
}

.item-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.browser-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.check-cell {
  position: absolute;
  top: 8px;
  left: 8px;
}

.files-grid .item {
  position: relative;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  filter: brightness(0.95);
  color: #fff;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(110%);
    transition: transform 0.28s var(--ease);
    z-index: 45;
  }
  html[dir="rtl"] .sidebar { inset: 0 0 0 auto; }
  body.nav-open .sidebar { transform: none; }
  .mobile-nav-btn { display: inline-flex; }
  .main { padding: 20px 16px 88px; }
  .auth-stage { grid-template-columns: 1fr; }
  .auth-hero { min-height: auto; padding: 32px 28px; }
  .grid-2 { grid-template-columns: 1fr; }
  .item { grid-template-columns: auto 1fr; }
  .item-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
