@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
  --ink: #0e131c;
  --ink-soft: #1a2230;
  --ink-muted: #8b95a8;
  --surface: #f3f5f8;
  --surface-2: #ffffff;
  --line: #e4e8ef;
  --line-strong: #d0d7e2;
  --brand: #0b8574;
  --brand-hover: #0a6b5e;
  --brand-soft: #ecfdf8;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --ok: #067647;
  --ok-soft: #ecfdf3;
  --sidebar-w: 16.5rem;
  --radius: 0.75rem;
  --shadow: 0 1px 2px rgba(14, 19, 28, 0.04), 0 8px 24px rgba(14, 19, 28, 0.04);
}

* { box-sizing: border-box; }

html, body.app {
  min-height: 100%;
  margin: 0;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(11, 133, 116, 0.08), transparent 55%),
    radial-gradient(900px 500px at -10% 100%, rgba(14, 19, 28, 0.05), transparent 50%),
    var(--surface);
  -webkit-font-smoothing: antialiased;
}

body.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* —— Full-width top navbar —— */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  min-height: 3.5rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}
.topbar-brand-text {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1rem;
}
.topbar-brand-text span { font-weight: 500; color: #64748b; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
  margin-left: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.topbar-link {
  flex-shrink: 0;
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #5b6578;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: background 0.12s ease, color 0.12s ease;
}
.topbar-link:hover { background: #eef2f7; color: var(--ink); }
.topbar-link.is-active {
  background: var(--brand-soft);
  color: var(--brand-hover);
}

.app-topbar-actions {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
}
.topbar-user {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
  max-width: 10rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-logout { margin: 0; }

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.menu-toggle {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: #fff;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 0;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block;
  width: 1rem;
  height: 1.5px;
  background: var(--ink);
  border-radius: 2px;
}

/* —— Sidebar —— */
.sidebar {
  position: sticky;
  top: 3.5rem;
  align-self: flex-start;
  width: var(--sidebar-w);
  height: calc(100vh - 3.5rem);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--ink) 0%, #121925 100%);
  color: #e8edf5;
  z-index: 40;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.sidebar-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  background: linear-gradient(145deg, #12b89e, #0b8574);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}

.sidebar-title {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 0.98rem;
  white-space: nowrap;
}
.sidebar-title span { font-weight: 500; opacity: 0.72; }

.sidebar-close {
  display: none;
  background: transparent;
  border: 0;
  color: var(--ink-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.sidebar-nav {
  flex: 1;
  overflow: auto;
  padding: 0.85rem 0.7rem 1rem;
  scrollbar-width: thin;
}

.nav-group { margin-bottom: 1.15rem; }

.nav-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6d7a90;
  padding: 0.15rem 0.65rem 0.45rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.52rem 0.7rem;
  margin-bottom: 0.15rem;
  border-radius: 0.55rem;
  color: #c5cede;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.nav-item.is-active {
  background: rgba(18, 184, 158, 0.16);
  color: #7ff0d8;
  box-shadow: inset 0 0 0 1px rgba(18, 184, 158, 0.28);
}
.nav-status {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(14, 19, 28, 0.55);
}
.nav-status--lg {
  width: 0.7rem;
  height: 0.7rem;
}
.nav-status--green { background: #34d399; }
.nav-status--orange { background: #fbbf24; }
.nav-status--red { background: #f87171; }
.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: 0.7;
  font-size: 0.7rem;
}

.nav-group-context {
  margin-top: 0.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.nav-context-name {
  padding: 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-context-meta {
  padding: 0.15rem 0.7rem 0.55rem;
  font-size: 0.72rem;
  color: #7d8aa0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-foot {
  padding: 0.85rem 0.85rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
  min-width: 0;
}
.sidebar-user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(18, 184, 158, 0.2);
  color: #7ff0d8;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 0.7rem; color: #7d8aa0; }
.sidebar-logout button {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #c5cede;
  border-radius: 0.55rem;
  padding: 0.45rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.sidebar-logout button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 18, 0.45);
  z-index: 30;
}

/* —— Main —— */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 1.5rem 0;
  font-size: 0.8rem;
  color: #6b7689;
}
.crumbs a { color: #5b6578; text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.crumbs-sep { color: #c2cad6; }
.crumbs-current { color: var(--ink); font-weight: 600; }

.flash-stack {
  margin: 0.85rem 1.5rem 0;
  display: grid;
  gap: 0.5rem;
}
.flash {
  margin: 0;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  font-weight: 550;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: 0 1px 2px rgba(14, 19, 28, 0.04);
}
.flash-text { flex: 1; min-width: 0; line-height: 1.4; }
.flash-dismiss {
  border: 0;
  background: transparent;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 0.15rem;
}
.flash-dismiss:hover { opacity: 1; }
.flash-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #abefc6; }
.flash-err { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdca; }

.ui-busy {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  padding: 1rem;
}
.ui-busy[hidden] { display: none !important; }
.ui-busy-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  max-width: min(24rem, calc(100vw - 2rem));
  text-align: center;
}
.ui-busy-spinner {
  width: 1.75rem;
  height: 1.75rem;
  margin: 0 auto 0.85rem;
  border: 2.5px solid #e2e8f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: ui-spin 0.7s linear infinite;
}
.ui-busy-msg {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 550;
  color: #334155;
  line-height: 1.4;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }
body.is-busy { cursor: progress; }
button.is-loading { opacity: 0.75; cursor: wait; }

.app-content {
  padding: 1.25rem 1.5rem 2.5rem;
  width: 100%;
  max-width: none;
}

.app-content > h1,
.app-content .page-title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}

/* —— Forms / buttons / cards —— */
.input {
  display: block;
  width: 100%;
  border-radius: 0.6rem;
  border: 1px solid var(--line-strong);
  background: #fff;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 133, 116, 0.15);
}
.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 550;
  color: #4b5568;
  margin-bottom: 0.15rem;
}
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border-radius: 0.6rem;
  padding: 0.5rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  border: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary {
  background: #fff;
  color: #334155;
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover { background: #f8fafc; border-color: #b8c2d1; }

.card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
a.card:hover {
  border-color: rgba(11, 133, 116, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(14, 19, 28, 0.04), 0 12px 28px rgba(14, 19, 28, 0.06);
}

.pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-700, #0a6b5e);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  letter-spacing: 0.01em;
}

.hidden { display: none !important; }

.tab {
  padding: 0.65rem 0.95rem;
  color: #64748b;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
}
.tab:hover { color: var(--ink); }
.tab-active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 650;
}

.quota { margin-bottom: 0.35rem; }
.quota-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #5b6578;
  margin-bottom: 0.35rem;
}
.quota-bar {
  height: 0.45rem;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d9f8a, #12b89e);
}

/* tables */
.app-content table { border-collapse: collapse; }
.app-content thead { color: #6b7689; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.app-content tbody tr { border-top: 1px solid var(--line); }
.app-content td, .app-content th { padding: 0.7rem 0.35rem; text-align: left; }

/* login */
body.login-page {
  min-height: 100vh;
  margin: 0;
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 80% 0%, rgba(11, 133, 116, 0.22), transparent 55%),
    radial-gradient(700px 400px at 10% 100%, rgba(14, 19, 28, 0.35), transparent 50%),
    linear-gradient(160deg, #0e131c 0%, #182233 45%, #0f2a28 100%);
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 24rem;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 1.25rem;
  padding: 2rem 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.login-brand .sidebar-mark { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
.login-card h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.login-card .login-sub {
  margin: 0 0 1.5rem;
  color: #64748b;
  font-size: 0.875rem;
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 3.5rem;
    height: calc(100vh - 3.5rem);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.25);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; top: 3.5rem; }
  .menu-toggle { display: inline-flex; }
  .topbar-nav { display: none; }
  .topbar-user { display: none; }
  .app-content { padding: 1rem 1rem 2rem; }
  .crumbs { padding-left: 1rem; padding-right: 1rem; }
  .flash-stack { margin-left: 1rem; margin-right: 1rem; }
  .app-topbar-inner { padding-left: 0.85rem; padding-right: 0.85rem; }
}

/* File manager / admin UI dialogs */
.fm-dialog {
  border: 0;
  padding: 0;
  border-radius: 1rem;
  max-width: min(28rem, calc(100vw - 2rem));
  width: 100%;
  background: transparent;
  box-shadow: none;
}
.fm-dialog--md {
  max-width: min(36rem, calc(100vw - 2rem));
}
.fm-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.fm-dialog-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  max-height: min(90vh, 40rem);
  overflow-y: auto;
}

.fm-bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #f8fafc;
}
.fm-bulk-count { font-size: 0.875rem; color: #475569; }
.fm-bulk-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fm-upload-progress {
  height: 0.5rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  position: relative;
}
.fm-upload-progress-bar {
  height: 100%;
  background: var(--brand, #0f766e);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.fm-check {
  width: 1rem;
  height: 1rem;
  accent-color: var(--brand, #0f766e);
  cursor: pointer;
}
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.55rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  cursor: pointer;
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; }
