:root{
  --bg:#0b0f19;
  --panel:#111827;
  --panel2:#0f172a;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --line:#243044;
  --accent:#22c55e;
  --warn:#f59e0b;
  --danger:#ef4444;
  --card:#0b1224;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius:16px;
}

*{ box-sizing:border-box; }
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(1200px 600px at 20% 0%, rgba(34,197,94,.12), transparent 50%),
              radial-gradient(1000px 500px at 80% 20%, rgba(59,130,246,.10), transparent 50%),
              var(--bg);
  color:var(--text);
}

.app{
  display:grid;
  grid-template-columns: 320px 1fr;
  min-height:100vh;
}

.sidebar{
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border-right:1px solid var(--line);
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:16px;
  position:sticky;
  top:0;
  height:100vh;
}

.sidebar.collapsed{
  width:72px;
  grid-column:1;
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-footer .user-chip,
.sidebar.collapsed .sidebar-actions button:nth-child(2){
  display:none;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:10px 10px;
  border:1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0,0,0,.15);
}
.brand-mark{
  width:40px;height:40px;border-radius:12px;
  background: linear-gradient(135deg, rgba(34,197,94,.9), rgba(34,197,94,.2));
  box-shadow: 0 8px 24px rgba(34,197,94,.2);
}
.brand-title{ font-weight:700; letter-spacing:.2px; }
.brand-subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  overflow:auto;
  padding-right:4px;
}

.nav-item{
  display:flex;
  gap:10px;
  align-items:center;
  width:100%;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  text-align:left;
}
.nav-item:hover{
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.06);
}
.nav-item.active{
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.22);
}
.nav-dot{
  width:10px;height:10px;border-radius:99px;
  background: rgba(156,163,175,.35);
}
.nav-item.active .nav-dot{
  background: var(--accent);
}

.sidebar-footer{
  margin-top:auto;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.06);
}
.user-chip{
  display:flex;
  justify-content:space-between;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.15);
}
.user-chip-label{ color:var(--muted); font-size:12px; }
.user-chip-name{ font-weight:600; }

.sidebar-actions{
  display:flex;
  gap:10px;
}

.main{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.topbar{
  position:sticky;
  top:0;
  z-index:5;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:16px 18px;
  border-bottom:1px solid var(--line);
  background: rgba(11,15,25,.65);
  backdrop-filter: blur(12px);
}

.topbar-left{
  display:flex;
  gap:12px;
  align-items:center;
}

.hamburger{
  display:none;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.2);
  color: var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
}

.page-title{ font-size:18px; font-weight:800; }
.page-subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

.content{
  padding:22px 18px 40px;
  max-width: 1100px;
}

.card{
  background: rgba(0,0,0,.15);
  border:1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
  margin-bottom:14px;
}

.card h2{ margin:0 0 8px 0; font-size:16px; }
.card h3{ margin:0 0 6px 0; font-size:14px; color:var(--muted); font-weight:600; }
.muted{ color:var(--muted); }

.grid{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap:10px;
}
.kv{
  border:1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.18);
  border-radius:14px;
  padding:12px;
}
.kv .k{ color:var(--muted); font-size:12px; }
.kv .v{ margin-top:6px; font-size:14px; font-weight:700; }

ul{ margin:10px 0 0 18px; }
li{ margin:6px 0; color: var(--text); }

.table-wrap{ overflow:auto; }
table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
}
th, td{
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding:10px 10px;
  text-align:left;
  vertical-align:top;
}
th{
  color: var(--muted);
  font-weight:700;
}

.callout{
  border-radius: var(--radius);
  padding:14px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.18);
}
.callout.strong{ border-color: rgba(34,197,94,.30); background: rgba(34,197,94,.10); }
.callout.info{ border-color: rgba(59,130,246,.25); background: rgba(59,130,246,.08); }
.callout.warning{ border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.08); }
.callout .title{ font-weight:800; margin-bottom:6px; }

.btn-primary, .btn-secondary{
  border-radius:12px;
  padding:10px 12px;
  cursor:pointer;
  border:1px solid rgba(255,255,255,.10);
  font-weight:700;
  text-decoration:none;
  display:inline-block;
}
.btn-primary{
  background: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.35);
  color: var(--text);
}
.btn-secondary{
  background: rgba(0,0,0,.18);
  color: var(--text);
}
.btn-primary:hover, .btn-secondary:hover{ filter: brightness(1.08); }

.footer{
  margin-top:auto;
  border-top:1px solid rgba(255,255,255,.06);
  padding:14px 18px;
  display:flex;
  gap:14px;
  justify-content:space-between;
}

.modal{
  display:none;
  position:fixed;
  z-index:20;
  left:0;top:0;
  width:100%;height:100%;
  background: rgba(0,0,0,.6);
}
.modal-content{
  background: var(--panel);
  margin: 10% auto;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.10);
  width: min(520px, 92%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.close{ float:right; font-size:28px; cursor:pointer; color: var(--muted); }
.form-group{ margin: 12px 0; }
label{ display:block; color: var(--muted); font-size:12px; margin-bottom:6px; }
input{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.2);
  color: var(--text);
}
.share-result{ margin-top:10px; color: var(--muted); font-size:12px; }

/* Logo Container (Direct Access) */
.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: #000000;
}

.logo-placeholder {
  background: transparent;
  padding: 20px;
}

.logo-image {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Access Container */
.access-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.access-box {
  background: var(--panel);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 500px;
  width: 100%;
  border: 1px solid var(--line);
}

.access-box h1 {
  margin-bottom: 20px;
  color: var(--text);
  text-align: center;
}

.welcome-text {
  font-size: 18px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 10px;
}

.access-box p {
  margin-bottom: 20px;
  color: var(--muted);
  text-align: center;
}

.code-input-group {
  margin-bottom: 20px;
}

.code-input {
  width: 100%;
  padding: 15px;
  font-size: 32px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  transition: border-color 0.3s;
  background: rgba(0,0,0,.2);
  color: var(--text);
}

.code-input:focus {
  outline: none;
  border-color: var(--accent);
}

.error-message {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid rgba(239,68,68,.3);
}

.success-message {
  background: rgba(34,197,94,.15);
  color: #86efac;
  padding: 20px;
  border-radius: 6px;
  margin-top: 20px;
  border: 1px solid rgba(34,197,94,.3);
}

.success-message h3 {
  margin-bottom: 10px;
}

.success-message code {
  background: rgba(0,0,0,.2);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  color: var(--text);
}

/* Admin Container */
.admin-container {
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}

.admin-header {
  background: var(--panel);
  padding: 20px 30px;
  border-radius: 8px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.admin-header h1 {
  color: var(--text);
}

.admin-content {
  max-width: 1400px;
  margin: 0 auto;
}

.admin-section {
  background: var(--panel);
  padding: 30px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.admin-section h2 {
  margin-bottom: 20px;
  color: var(--text);
}

.message {
  background: rgba(59,130,246,.15);
  color: #93c5fd;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid rgba(59,130,246,.3);
}

/* Invites Table */
.invites-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

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

.invites-table th {
  background: rgba(0,0,0,.2);
  font-weight: 600;
  color: var(--text);
}

.invites-table tr:hover {
  background: rgba(255,255,255,.04);
}

.link-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.link-cell a:hover {
  text-decoration: underline;
}

.code-cell {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--text);
}

.status-badge {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.active {
  background: rgba(34,197,94,.2);
  color: var(--accent);
}

.status-badge.revoked {
  background: rgba(239,68,68,.2);
  color: #fca5a5;
}

/* Share Container */
.share-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.share-box {
  background: var(--panel);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 500px;
  width: 100%;
  border: 1px solid var(--line);
}

.share-box h1 {
  margin-bottom: 20px;
  color: var(--text);
  text-align: center;
}

.share-box p {
  margin-bottom: 20px;
  color: var(--muted);
  text-align: center;
}

.share-result {
  margin-top: 20px;
}

.share-result a {
  color: var(--accent);
  word-break: break-all;
}

/* Admin Login */
.admin-login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg);
}

.admin-login-box {
  background: var(--panel);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--line);
}

.admin-login-box h1 {
  margin-bottom: 30px;
  color: var(--text);
  text-align: center;
}

@media (max-width: 980px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ position:fixed; left:0; top:0; bottom:0; width: 320px; transform: translateX(-105%); transition: transform .2s ease; z-index:30; }
  .sidebar.open{ transform: translateX(0); }
  .hamburger{ display:inline-flex; }
  .content{ padding:18px 14px 40px; }
  .grid{ grid-template-columns: 1fr; }
}

/* Responsive */
@media (max-width: 768px) {
  .invites-table {
    font-size: 12px;
  }
  
  .invites-table th,
  .invites-table td {
    padding: 8px;
  }
  
  .link-cell {
    max-width: 100px;
  }
}

/* Edit Mode Styles */
.edit-buttons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 10;
}

.edit-btn, .delete-btn {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(0,0,0,.4);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(4px);
}

.edit-btn:hover {
  background: rgba(59,130,246,.3);
  border-color: rgba(59,130,246,.5);
}

.delete-btn:hover {
  background: rgba(239,68,68,.3);
  border-color: rgba(239,68,68,.5);
}

.card {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.25);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0,0,0,.35);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}
