:root {
  /* TOMO Color Palette */
  --tomo-green-light: #55c881;
  --tomo-green-mid: #388d4f;
  --tomo-green-muted: #6a9f77;
  --tomo-green-dark: #24632e;
  --tomo-green-bg: #dcede1;
  --tomo-green-accent: #4ab16f;
  --tomo-green-deep: #3c7b47;

  --bg-color: #ffffff;
  --container-bg: #f8f9fa;
  --text-color: #212529;
  --secondary-text: #6c757d;
  --primary-color: var(--tomo-green-accent);
  --primary-gradient: linear-gradient(135deg, var(--tomo-green-light) 0%, var(--tomo-green-dark) 100%);
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --border-color: #dee2e6;
  --button-bg: var(--tomo-green-deep);
  --button-text: #ffffff;
  --sidebar-bg: var(--tomo-green-bg);
  --logo-max-width: 100px;
  --header-height: 80px;
}

[data-theme="dark"] {
  --bg-color: #0b0e14;
  --container-bg: #161b22;
  --text-color: #f0f6fc;
  --secondary-text: #8b949e;
  --primary-color: var(--tomo-green-light);
  --primary-gradient: linear-gradient(135deg, var(--tomo-green-accent) 0%, var(--tomo-green-dark) 100%);
  --card-bg: #161b22;
  --input-bg: #0d1117;
  --border-color: #30363d;
  --button-bg: var(--tomo-green-light);
  --button-text: #0b0e14;
  --sidebar-bg: #0d1117;
  --mono-icon-fill: var(--tomo-green-light);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-color: #0b0e14;
    --container-bg: #161b22;
    --text-color: #f0f6fc;
    --secondary-text: #8b949e;
    --primary-color: var(--tomo-green-light);
    --primary-gradient: linear-gradient(135deg, var(--tomo-green-accent) 0%, var(--tomo-green-dark) 100%);
    --card-bg: #161b22;
    --input-bg: #0d1117;
    --border-color: #30363d;
    --button-bg: var(--tomo-green-light);
    --button-text: #0b0e14;
    --sidebar-bg: #0d1117;
    --mono-icon-fill: var(--tomo-green-light);
  }
}

:root:not([data-theme="dark"]):not([data-current-theme="dark"]) {
  --mono-icon-fill: var(--tomo-green-deep);
}

body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; background: var(--bg-color); color: var(--text-color); transition: background 0.3s, color 0.3s; min-height: 100vh; display: flex; flex-direction: column; }

/* Landing Page Styles */
.landing-container-outer { display: flex; flex-direction: column; width: 100%; }
.landing-header { height: var(--header-height); background: rgba(var(--bg-color), 0.8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 1000; border-bottom: 1px solid var(--border-color); }
.header-content { max-width: 1200px; margin: 0 auto; height: 100%; display: flex; justify-content: space-between; align-items: center; padding: 0 2rem; }
.header-logo { height: 30px; transition: filter 0.3s ease; }
[data-current-theme="light"] .header-logo { filter: brightness(0); }
[data-current-theme="dark"] .header-logo { filter: brightness(0) invert(1); }
.sidebar-logo { height: 30px; transition: filter 0.3s ease; }
[data-current-theme="light"] .sidebar-logo { filter: brightness(0); }
[data-current-theme="dark"] .sidebar-logo { filter: brightness(0) invert(1); }
#login-section { display: flex; align-items: center; gap: 1rem; }
.google-login-btn, #go-to-portal-btn { display: flex; align-items: center; gap: 10px; background: var(--card-bg); color: var(--text-color); border: 1px solid var(--border-color); padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: transform 0.1s, box-shadow 0.2s; }
.google-login-btn:hover, #go-to-portal-btn:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.1); transform: translateY(-1px); }
.google-icon { width: 20px; height: 20px; }

.landing-main { max-width: 1100px; margin: 0 auto; padding: 4rem 2rem; }
.gradient-text { background: var(--primary-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 800; }

.hero { text-align: center; margin-bottom: 6rem; }
.hero h1 { font-size: 4rem; font-weight: 800; margin-bottom: 1.5rem; line-height: 1.1; letter-spacing: -0.02em; }
.hero-subtitle { font-size: 1.25rem; color: var(--secondary-text); max-width: 700px; margin: 0 auto 2.5rem; line-height: 1.6; }
.hero-cta { display: flex; justify-content: center; gap: 1rem; }
.primary-btn { background: var(--primary-color); color: white; padding: 12px 28px; border-radius: 8px; font-size: 1rem; font-weight: 600; border: none; cursor: pointer; }
.secondary-btn { background: transparent; color: var(--text-color); padding: 12px 28px; border-radius: 8px; font-size: 1rem; font-weight: 600; border: 1px solid var(--border-color); cursor: pointer; }

.features { margin-bottom: 8rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; }
.feature-item { background: var(--card-bg); padding: 2.5rem; border-radius: 16px; border: 1px solid var(--border-color); transition: transform 0.3s; }
.feature-item:hover { transform: translateY(-5px); }
.feature-icon svg { width: 48px; height: 48px; fill: var(--mono-icon-fill); margin-bottom: 1.5rem; }
.feature-item h3 { font-size: 1.5rem; margin-bottom: 1rem; }
.feature-item p { color: var(--secondary-text); line-height: 1.5; }

.pricing-section { text-align: center; margin-bottom: 6rem; }
.pricing-section h2 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; }
.pricing-section > p { color: var(--secondary-text); margin-bottom: 3rem; }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; max-width: 1200px; margin: 0 auto; }
.pricing-card { background: var(--card-bg); padding: 3rem 2rem; border-radius: 16px; border: 1px solid var(--border-color); display: flex; flex-direction: column; position: relative; }
@media (min-width: 992px) {
  .pricing-grid { grid-template-columns: repeat(3, 1fr); }
}
.pricing-card.featured { border: 2px solid var(--primary-color); transform: scale(1.05); }
.popular-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--primary-color); color: white; padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: bold; text-transform: uppercase; }
.pricing-card h4 { font-size: 1.25rem; margin-bottom: 1rem; color: var(--secondary-text); }
.price { font-size: 3rem; font-weight: 800; margin-bottom: 1.5rem; }
.price small { font-size: 1rem; font-weight: 400; color: var(--secondary-text); }
.pricing-features { list-style: none; padding: 0; margin: 2rem 0; text-align: left; }
.pricing-features li { padding: 0.5rem 0; border: none; margin: 0; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.pricing-features li::before { content: "✓"; color: var(--primary-color); font-weight: bold; }
.pricing-footer { margin-top: 3rem; font-size: 0.9rem; color: var(--secondary-text); }

.landing-footer { border-top: 1px solid var(--border-color); padding: 4rem 2rem; text-align: center; color: var(--secondary-text); }

/* Portal Styles */
.portal-container { display: none; flex: 1; height: 100vh; overflow: hidden; }
.sidebar { width: 280px; background: var(--sidebar-bg); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 1.5rem; }
.sidebar-item { padding: 0.85rem 1.25rem; cursor: pointer; border-radius: 10px; margin-bottom: 0.5rem; transition: all 0.2s; font-weight: 500; }
.sidebar-item:hover { background: var(--border-color); }
.sidebar-item.active { background: var(--primary-color); color: white; }
.main-content { flex: 1; overflow-y: auto; padding: 3rem; }

.sidebar-logo { max-width: 100%; margin-bottom: 3rem; }
.user-info-sidebar { padding-top: 1.5rem; border-top: 1px solid var(--border-color); margin-top: auto; }
.theme-toggle-btn:hover { background: var(--border-color); }

.sun-icon, .moon-icon { width: 20px; height: 20px; fill: var(--text-color); display: none; }
[data-current-theme="dark"] .sun-icon { display: block; }
[data-current-theme="light"] .moon-icon { display: block; }

.user-info-sidebar .name { font-weight: 600; display: block; margin-bottom: 2px; }
.user-info-sidebar .email { color: var(--secondary-text); display: block; font-size: 0.85rem; margin-bottom: 1rem; overflow: hidden; text-overflow: ellipsis; }

.action-btn { background: transparent; color: var(--text-color); border: 1px solid var(--border-color); padding: 6px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; position: relative; margin-right: 4px; }
.action-btn:hover { background: var(--border-color); }
.action-btn svg { width: 18px; height: 18px; fill: currentColor; }
.action-btn.danger:hover { background: rgba(220, 53, 69, 0.1); color: #dc3545; border-color: #dc3545; }
.action-btn.success:hover { background: rgba(40, 167, 69, 0.1); color: #28a745; border-color: #28a745; }
.action-btn.primary:hover { background: rgba(0, 123, 255, 0.1); color: #007bff; border-color: #007bff; }
button { background: var(--button-bg); color: var(--button-text); border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; transition: opacity 0.2s; }
button:hover { opacity: 0.8; }
input, select { background: var(--input-bg); border: 1px solid var(--border-color); color: var(--text-color); padding: 8px; border-radius: 4px; margin-bottom: 10px; width: 100%; box-sizing: border-box; }
.panel { display: none; }
.panel.active { display: block; }
.card { background: var(--card-bg); padding: 1.5rem; border-radius: 8px; border: 1px solid var(--border-color); margin-bottom: 1.5rem; }
table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: center; padding: 0.75rem; border-bottom: 1px solid var(--border-color); }
.badge { padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }
.badge-normal { background: #6a9f77; color: white; }
.badge-admin { background: #24632e; color: white; }
.badge-enabled { background: #55c881; color: white; }
.badge-disabled { background: #ff4b2b; color: white; }
.badge-created { background: #6c757d; color: white; }
.badge-pending { background: #ffc107; color: black; }
.badge-approved { background: #55c881; color: white; }
li { background: var(--card-bg); padding: 1rem; margin-bottom: 10px; border-radius: 6px; border: 1px solid var(--border-color); list-style: none; }
a { color: var(--primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Theme Selector Styles */
.theme-selector { position: fixed; top: 10px; right: 10px; z-index: 1000; display: none; }

/* Sidebar Footer and Actions */
.user-info-sidebar { padding: 1rem; border-top: 1px solid var(--border-color); margin-top: auto; font-size: 0.9rem; }
.footer-actions { display: flex; align-items: center; gap: 10px; margin-top: 0.5rem; }
.theme-toggle-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; flex-shrink: 0; }
.logout-container { flex-grow: 1; display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1.25rem; cursor: pointer; border-radius: 10px; transition: background 0.2s; color: #ff4d4f; font-weight: 600; border: 1px solid transparent; }
.logout-container:hover { background: rgba(255, 77, 79, 0.1); border-color: rgba(255, 77, 79, 0.2); }
.account-button { padding: 0.85rem 1.25rem; cursor: pointer; border-radius: 10px; margin-bottom: 0.5rem; transition: all 0.2s; font-weight: 500; display: flex; flex-direction: column; border: 1px solid transparent; }
.account-button:hover { background: var(--border-color); border-color: var(--tomo-green-accent); }
.account-button.active { background: var(--primary-color); color: white; }
.account-button .name { font-weight: bold; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button .email { color: var(--secondary-text); display: block; font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-button.active .email { color: rgba(255,255,255,0.8); }
.logout-icon { width: 18px; height: 18px; fill: currentColor; }

/* Toast Notifications */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 250px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideIn 0.3s ease-out forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { background-color: var(--tomo-green-light); color: #0b0e14; }
.toast.warning { background-color: #ffc107; color: #0b0e14; }
.toast.error { background-color: #dc3545; color: white; }

.toast-close {
  margin-left: 15px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

/* Utils */
.copy-btn {
  padding: 4px 8px;
  font-size: 0.8rem;
  margin-left: 8px;
}

.key-display {
  font-family: monospace;
  background: rgba(0,0,0,0.05);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
}
[data-theme="dark"] .key-display { background: rgba(255,255,255,0.05); }

/* Fixes */
.action-btn.primary:hover { background: rgba(85, 200, 129, 0.1); color: var(--tomo-green-light); border-color: var(--tomo-green-light); }
#add-app-form .action-btn.primary { background-color: var(--tomo-green-light); color: #0b0e14; border: none; }
#add-app-form .action-btn.primary:hover { opacity: 0.8; }
