:root {
  --canvas: #0e0f11;
  --surface: #18191b;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --surface-active: rgba(255, 255, 255, 0.08);
  --ink: #f2f2f2;
  --muted: #8a8f98;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.12);
  --accent: #5e6ad2;
  --accent-hover: #6b78e3;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --input-bg: #0b0c0d;
  --input-border: #35373c;
  --input-focus: rgba(255, 255, 255, 0.3);
  --btn-bg: #f1f2f4;
  --btn-border: #f1f2f4;
  --btn-text: #111214;
  --btn-hover: #e8e8e8;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
}

.app-sidebar {
  position: fixed;
  z-index: 10;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease;
}

/* Linear-style workspace header */
.sidebar-header {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-header:hover {
  background: var(--surface-hover);
}
.workspace-icon {
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.nav-list {
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
}

.nav-caption {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  margin: 12px 8px 4px;
}

.nav-list a {
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  min-height: 28px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.1s ease;
}

.nav-list a:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.nav-list a span:not(.nav-text) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.nav-list svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-list a.active {
  background: var(--surface-active);
  color: var(--ink);
}

.nav-list a.active span {
  color: var(--ink);
}

.sidebar-user {
  margin-top: auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.sidebar-user .avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user b {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.sidebar-user a {
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
}
.sidebar-user a:hover {
  color: var(--ink);
}

.app-main {
  margin-left: 240px;
  padding: 0 40px 60px;
  max-width: 100%;
  transition: margin-left 0.18s ease;
}

.app-topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(14, 15, 17, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-left: -40px;
  margin-right: -40px;
  padding: 0 40px;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.topbar-title span {
  color: var(--ink);
}

.sidebar-toggle, .icon-button {
  height: 24px;
  width: 24px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}

.sidebar-toggle:hover, .icon-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

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

.live-status {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.live-status i {
  width: 6px;
  height: 6px;
  background: #44b556;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(68, 181, 86, 0.2);
}

.sidebar-backdrop {
  display: none;
}

.panel, .stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.panel {
  padding: 24px;
}

.panel h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 20px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.stat {
  padding: 20px;
  min-height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}
.stat .stat-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  color: var(--muted);
  opacity: 0.7;
}

.stat small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 24px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--line);
  font-size: 13px;
  margin: 0;
  width: 100%;
}

.table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table td {
  padding: 12px;
  color: var(--ink);
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  padding: 4px 8px;
  border: 1px solid transparent;
}
.status-paid {
  background: rgba(68, 181, 86, 0.1);
  color: #44b556;
  border-color: rgba(68, 181, 86, 0.2);
}
.status-pending {
  background: rgba(245, 166, 35, 0.1);
  color: #f5a623;
  border-color: rgba(245, 166, 35, 0.2);
}
.status-expired, .status-default {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-color: var(--line);
}

.narrow {
  max-width: 640px;
}

.form-control {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font-size: 13px;
  height: 32px;
  padding: 0 10px;
  box-shadow: none;
  transition: all 0.15s ease;
}

.form-control:focus {
  background: var(--input-bg);
  color: var(--ink);
  border-color: var(--input-focus);
  box-shadow: none;
  outline: none;
}
.form-control::placeholder {
  color: #4a4d55;
}

.form-label {
  color: var(--muted) !important;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}

.btn-primary {
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--btn-text);
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  transition: background 0.1s;
}
.btn-primary:hover {
  background: var(--btn-hover);
  border-color: var(--btn-hover);
}

.panel hr {
  border-color: var(--line);
  margin: 24px 0;
}

/* Toast logic */
.toast-notice {
  position: fixed;
  z-index: 20;
  top: 72px;
  right: 24px;
  max-width: 360px;
  padding: 14px 18px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  font-size: 13px;
  font-weight: 500;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success {
  border-left: 4px solid #44b556;
}

.toast-error {
  border-left: 4px solid #e5484d;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Dropdown and Avatar styles */
.avatar-button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  border: none;
  cursor: pointer;
  padding: 0;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  min-width: 180px;
  padding: 4px;
  z-index: 100;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-header {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.dropdown-menu hr {
  margin: 4px 0;
  border-color: var(--line);
}

.dropdown-menu a {
  display: block;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.dropdown-menu a:hover {
  background: var(--surface-hover);
}

@media (min-width: 801px) {
  body.sidebar-mini .app-sidebar {
    width: 64px;
  }
  body.sidebar-mini .app-main {
    margin-left: 64px;
  }
  body.sidebar-mini .sidebar-header {
    justify-content: center;
    padding: 0;
  }
  body.sidebar-mini .sidebar-header span,
  body.sidebar-mini .nav-caption,
  body.sidebar-mini .nav-list a .nav-text,
  body.sidebar-mini .sidebar-user-info {
    display: none;
  }
  body.sidebar-mini .sidebar-header img {
    margin-right: 0 !important;
  }
  body.sidebar-mini .nav-list a {
    justify-content: center;
    padding: 0;
  }
  body.sidebar-mini .sidebar-user {
    justify-content: center;
    padding: 12px 0;
  }
}

@media (max-width: 800px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: none;
  }
  .app-body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    position: fixed;
    z-index: 5;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
  }
  .app-body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .app-main, .app-body.sidebar-open .app-main {
    margin: 0;
    padding: 0 20px 30px;
  }
  .app-topbar {
    margin-left: -20px;
    margin-right: -20px;
    padding: 0 20px;
  }
  .live-status {
    display: none;
  }
}

/* Login Page Styles */
.login-bg {
  background: var(--canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--canvas);
  padding: 32px 0;
}
.login-logo {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
  color: var(--ink);
}
.login-logo span {
  color: var(--accent);
}
.login-card h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.login-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-footer {
  text-align: center;
  margin-top: 24px !important;
  color: var(--muted);
  font-size: 11px;
}
