/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-page: #f2f3f5;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-hover: #f7f7f8;
  --bg-active: #f2f3f5;

  --border-light: #e4e6ea;
  --border-faint: #f0f0f2;

  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --text-hint: #bbb;

  --accent-green: #22a06b;
  --accent-green-bg: rgba(34, 160, 107, 0.08);
  --accent-amber: #a07d12;
  --accent-amber-bg: rgba(212, 160, 23, 0.1);
  --accent-red: #a03333;
  --accent-red-bg: rgba(196, 74, 74, 0.08);
  --accent-blue: #1a6bb5;
  --accent-blue-bg: rgba(26, 107, 181, 0.08);

  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(0, 0, 0, 0.07);
  --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.7);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --sidebar-width: 224px;
  --transition: 0.15s ease;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

/* ===== LOGIN PAGE ===== */
.login-page {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 0 20px;
  animation: fadeUp 0.4s ease;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  justify-content: center;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
}

.login-logo-text {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.login-logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.login-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
}

.login-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.login-card .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: #b0b0b0;
}

.form-group input::placeholder {
  color: var(--text-hint);
}

.form-error {
  font-size: 12px;
  color: var(--accent-red);
  margin-top: 6px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--text-primary);
  color: #fff;
  width: 100%;
  padding: 12px 20px;
}

.btn-primary:hover {
  background: #333;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-glass {
  background: var(--glass-bg);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  color: var(--text-primary);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
}

.btn-glass:active {
  transform: scale(0.98);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 0.5px solid transparent;
}

.btn-ghost:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 0.5px solid transparent;
}

.btn-danger:hover {
  background: rgba(196, 74, 74, 0.14);
}

/* ===== LAYOUT ===== */
.layout {
  display: flex;
  height: 100%;
  animation: fadeIn 0.3s ease;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 0.5px solid var(--border-light);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
  padding: 0 8px;
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
}

.sidebar-logo-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition);
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.sidebar-link.active {
  background: var(--bg-active);
  color: var(--text-primary);
  font-weight: 500;
}

.sidebar-link svg {
  flex-shrink: 0;
}

.sidebar-link.active svg path,
.sidebar-link.active svg rect,
.sidebar-link.active svg circle {
  stroke: var(--text-primary);
}

.sidebar-footer {
  border-top: 0.5px solid var(--border-light);
  padding-top: 16px;
  margin-top: 16px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover {
  background: var(--bg-hover);
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
}

.sidebar-user-name {
  font-size: 12px;
  font-weight: 500;
}

.sidebar-user-role {
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
}

.page-header .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 26px;
  font-weight: 600;
}

.stat-card .value.green { color: var(--accent-green); }
.stat-card .value.amber { color: var(--accent-amber); }
.stat-card .value.red { color: var(--accent-red); }

/* ===== ORG CARDS LIST ===== */
.org-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.org-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.org-card:hover {
  border-color: #ccc;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.org-card.frozen {
  opacity: 0.55;
}

.org-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.org-card-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.org-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
}

.org-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.org-card-slug {
  font-size: 12px;
  color: var(--text-muted);
}

.org-card-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== BADGES ===== */
.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.badge-active {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.badge-grace {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
}

.badge-readonly {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
}

.badge-frozen {
  background: var(--accent-red-bg);
  color: var(--accent-red);
}

.badge-plan {
  background: var(--glass-bg);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===== ORG CARD STATS ===== */
.org-card-stats {
  display: flex;
  gap: 32px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 0.5px solid var(--border-faint);
}

.org-card-stats .stat-label {
  font-size: 11px;
  color: var(--text-hint);
}

.org-card-stats .stat-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== ORG DETAIL PAGE ===== */
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 20px;
  transition: color var(--transition);
}

.detail-back:hover {
  color: var(--text-secondary);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.detail-header .org-card-icon {
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.detail-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.detail-header .slug {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.detail-field {
  background: var(--bg-card);
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.detail-field .label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-field .value {
  font-size: 15px;
  font-weight: 500;
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 28px;
}

/* ===== CREATE ORG PAGE ===== */
.create-form {
  max-width: 520px;
}

.create-form .form-group {
  margin-bottom: 22px;
}

.create-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.create-form .form-actions {
  display: flex;
  gap: 10px;
  margin-top: 32px;
}

.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 0.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-card);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23999' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.form-group select:focus {
  border-color: #b0b0b0;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: var(--font);
  z-index: 1000;
  animation: slideUp 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.toast-success {
  background: var(--accent-green);
  color: #fff;
}

.toast-error {
  background: #d44;
  color: #fff;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%;
  max-width: 440px;
  animation: fadeUp 0.2s ease;
}

.modal h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ===== LOADING ===== */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-light);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn .spinner {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
  border-color: rgba(255,255,255,0.3);
  border-top-color: #fff;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .org-card-stats { flex-wrap: wrap; gap: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .create-form .form-row { grid-template-columns: 1fr; }
}
