:root {
  --color-primary: #FF8811;
  --color-primary-dark: #E3730A;
  --color-secondary: #F4D06F;
  --color-bg: #FFF8F0;
  --color-surface: #FFFFFF;
  --color-teal: #9DD9D2;
  --color-dark: #392F5A;
  --color-dark-soft: #4A3E71;
  --color-text: #2A2438;
  --color-text-muted: #756E8A;
  --color-border: #EEE3D3;
  --color-danger: #D64545;
  --color-success: #2E9E6D;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 4px 18px rgba(57, 47, 90, 0.08);
  --shadow-pop: 0 10px 30px rgba(57, 47, 90, 0.18);
  --sidebar-width: 250px;
  --topbar-height: 68px;
  --transition-fast: 150ms ease;
  --transition-med: 220ms ease;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
ul { list-style: none; margin: 0; padding: 0; }

svg { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ---------- Fixed App Shell ---------- */
.app-shell { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-dark);
  color: #EDE9F5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { width: 20px; height: 20px; }
.sidebar-brand .brand-text { font-size: 16px; font-weight: 700; letter-spacing: 0.2px; line-height: 1.25; }
.sidebar-brand .brand-text span { display: block; font-size: 10.5px; font-weight: 600; color: #B8AFD6; letter-spacing: 1.2px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow: hidden; }

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: #D8D2E8;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-nav .nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav .nav-item.active { background: var(--color-primary); color: #fff; font-weight: 600; }

.sidebar-footer { padding: 14px 20px 16px; border-top: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; }
.sidebar-footer-label { font-size: 11px; color: #C9C2E0; margin-bottom: 3px; }
.sidebar-footer-brand { font-size: 13px; font-weight: 700; color: var(--color-secondary); }
.sidebar-footer-brand:hover { color: var(--color-primary); text-decoration: underline; }

.main-area { flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; min-width: 0; }

.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--color-dark); }
.topbar-user { display: flex; align-items: center; gap: 18px; position: relative; }
.topbar-clock { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); white-space: nowrap; padding-right: 18px; border-right: 1px solid var(--color-border); }

.avatar-badge {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-secondary);
  color: var(--color-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

.user-menu-trigger { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); }
.user-menu-trigger:hover { background: var(--color-bg); }

.user-dropdown {
  position: absolute; top: 52px; right: 0;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); min-width: 190px; padding: 6px; display: none; z-index: 40;
}
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: var(--radius-sm);
  border: none; background: transparent; font-size: 13.5px; color: var(--color-text);
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--color-bg); }

.content-area { flex: 1; overflow: auto; padding: 22px 26px; }
.content-area.no-scroll { overflow: hidden; }

/* ---------- Cards ---------- */
.card { background: var(--color-surface); border-radius: var(--radius-md); border: 1px solid var(--color-border); box-shadow: var(--shadow-card); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-card { padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.orange { background: rgba(255,136,17,0.14); color: var(--color-primary); }
.stat-icon.teal { background: rgba(157,217,210,0.35); color: #2A7F76; }
.stat-icon.yellow { background: rgba(244,208,111,0.35); color: #9C7A17; }
.stat-icon.purple { background: rgba(57,47,90,0.10); color: var(--color-dark); }
.stat-icon.danger { background: rgba(214,69,69,0.12); color: var(--color-danger); }

.stat-value { font-size: 21px; font-weight: 700; color: var(--color-dark); line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13.5px; font-weight: 600; transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-dark); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--color-dark); margin-bottom: 6px; }
.form-control { width: 100%; padding: 11px 13px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 14px; background: #fff; color: var(--color-text); transition: border-color var(--transition-fast), box-shadow var(--transition-fast); }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(255,136,17,0.15); }
.form-hint { font-size: 11.5px; color: var(--color-text-muted); margin-top: 4px; }
.form-error { font-size: 12.5px; color: var(--color-danger); margin-top: 4px; }
.form-section { margin-bottom: 26px; }
.form-section-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: var(--color-dark); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.form-section-title .icon { width: 16px; height: 16px; color: var(--color-primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th { background: var(--color-bg); color: var(--color-dark); text-align: left; padding: 11px 14px; font-weight: 700; position: sticky; top: 0; border-bottom: 1px solid var(--color-border); }
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--color-border); }
table.data-table tr:hover td { background: rgba(255,136,17,0.04); }
table.data-table tr:last-child td { border-bottom: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-teal { background: rgba(157,217,210,0.35); color: #226158; }
.badge-orange { background: rgba(255,136,17,0.15); color: var(--color-primary-dark); }
.badge-purple { background: rgba(57,47,90,0.10); color: var(--color-dark); }
.badge-gray { background: #EFEAF6; color: #6B6285; }
.badge-danger { background: rgba(214,69,69,0.12); color: var(--color-danger); }

/* ---------- Modal / Confirm dialog ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(42,36,56,0.45); display: none; align-items: center; justify-content: center; z-index: 100; animation: fadeIn var(--transition-med); }
.modal-backdrop.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); width: 420px; max-width: 92vw; padding: 24px; animation: popIn var(--transition-med); }
.modal-box.modal-lg { width: 780px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--color-dark); margin-bottom: 8px; }
.modal-body { font-size: 13.5px; color: var(--color-text-muted); margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---------- Toast ---------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--color-dark); color: #fff; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-pop); animation: popIn var(--transition-med); min-width: 220px; }
.toast.success { background: var(--color-success); }
.toast.error { background: var(--color-danger); }

/* ---------- Login (no scroll) ---------- */
.auth-shell { height: 100vh; width: 100vw; overflow: hidden; display: flex; align-items: stretch; background: var(--color-bg); }
.auth-panel-left {
  flex: 1;
  background: linear-gradient(160deg, var(--color-dark) 0%, #4A3E71 100%);
  color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::after { content: ''; position: absolute; width: 340px; height: 340px; border-radius: 50%; background: rgba(255,136,17,0.16); right: -120px; bottom: -140px; }
.auth-panel-left::before { content: ''; position: absolute; width: 220px; height: 220px; border-radius: 50%; background: rgba(157,217,210,0.12); left: -80px; top: -80px; }
.auth-panel-left .brand-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; margin-bottom: 22px; position: relative; z-index: 1; }
.auth-panel-left .brand-icon svg { width: 28px; height: 28px; }
.auth-panel-left h1 { font-size: 30px; margin: 0 0 10px; position: relative; z-index: 1; }
.auth-panel-left .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--color-secondary); margin-bottom: 8px; position: relative; z-index: 1; }
.auth-panel-left p { font-size: 14px; color: #C9C2E0; max-width: 380px; line-height: 1.6; position: relative; z-index: 1; }
.auth-feature-list { margin-top: 30px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.auth-feature-list .feature { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: #E5E1F2; }
.auth-feature-list .feature .icon { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.auth-panel-right { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 21px; color: var(--color-dark); margin: 0 0 6px; }
.auth-card .subtitle { font-size: 13px; color: var(--color-text-muted); margin-bottom: 26px; }

.link-inline { color: var(--color-primary); font-weight: 600; }
.link-inline:hover { text-decoration: underline; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-header h1 { font-size: 19px; color: var(--color-dark); margin: 0; }
.page-header .subtitle { font-size: 12.5px; color: var(--color-text-muted); margin-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--color-bg); border: 1px solid var(--color-border); font-size: 12px; }
.chip .remove { color: var(--color-danger); cursor: pointer; font-weight: 700; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); font-size: 13px; }

/* ---------- Tenant cards ---------- */
.tenant-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; align-content: start; }
.tenant-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow var(--transition-fast), border-color var(--transition-fast); }
.tenant-card:hover { box-shadow: var(--shadow-pop); border-color: var(--color-primary); }
.tenant-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.tenant-card-icon { width: 42px; height: 42px; border-radius: 12px; background: rgba(57,47,90,0.08); color: var(--color-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tenant-card-icon svg { width: 22px; height: 22px; }
.tenant-card-name { font-size: 15px; font-weight: 700; color: var(--color-dark); }
.tenant-card-domain { font-size: 12.5px; color: var(--color-text-muted); display: flex; align-items: center; gap: 5px; }
.tenant-card-domain svg { width: 13px; height: 13px; }
.tenant-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--color-border); }

/* ---------- Provisioning timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline-step { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before {
  content: '';
  position: absolute; left: 13px; top: 28px; bottom: 0;
  width: 2px; background: var(--color-border);
}
.timeline-step:last-child::before { display: none; }
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-bg); border: 2px solid var(--color-border); color: var(--color-text-muted);
  z-index: 1;
}
.timeline-dot svg { width: 14px; height: 14px; }
.timeline-step.success .timeline-dot { background: rgba(46,158,109,0.12); border-color: var(--color-success); color: var(--color-success); }
.timeline-step.failed .timeline-dot { background: rgba(214,69,69,0.12); border-color: var(--color-danger); color: var(--color-danger); }
.timeline-step.running .timeline-dot { background: rgba(255,136,17,0.12); border-color: var(--color-primary); color: var(--color-primary); animation: pulse 1.4s ease infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,136,17,0.35); } 50% { box-shadow: 0 0 0 6px rgba(255,136,17,0); } }
.timeline-content { padding-top: 3px; }
.timeline-label { font-size: 13.5px; font-weight: 600; color: var(--color-dark); }
.timeline-message { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.detail-row:last-child { border-bottom: none; }
.detail-row-label { color: var(--color-text-muted); }
.detail-row-value { color: var(--color-dark); font-weight: 600; text-align: right; }
.detail-row-value.mono { font-family: 'Consolas', 'SF Mono', monospace; font-size: 12px; }
