:root {
  --primary: #1a73e8;
  --dark: #1e293b;
  --light: #f8fafc;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: #f0f4f8; color: #334155; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--dark); color: #fff;
  padding: 0; display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-logo {
  padding: 24px 20px; font-size: 1.3rem; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.05);
}
.sidebar-logo span { color: var(--primary); }
.sidebar nav { flex: 1; padding: 16px 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; color: rgba(255,255,255,.7);
  text-decoration: none; font-size: .9rem; transition: all .2s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,.1); color: #fff;
  border-left: 3px solid var(--primary);
}
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: .8rem; color: rgba(255,255,255,.4); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  background: #fff; padding: 16px 28px; display: flex;
  align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar h1 { font-size: 1.2rem; font-weight: 600; color: var(--dark); }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.avatar {
  width: 36px; height: 36px; background: var(--primary);
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 700; font-size: .85rem;
}
.content { flex: 1; padding: 28px; overflow-y: auto; }

/* Cards */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 24px;
}
.card-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.stat-val { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: #64748b; margin-top: 2px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: .9rem;
  font-weight: 500; cursor: pointer; border: none;
  text-decoration: none; transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1557b0; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--dark); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; color: #475569; }
.form-control {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; transition: border .2s;
  background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { background: #f8fafc; padding: 12px 16px; text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; border-bottom: 2px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 20px; font-size: .75rem; font-weight: 600;
}
.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #2563eb; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: #dcfce7; color: #166534; border-left: 4px solid #16a34a; }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }

/* Auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e293b 0%, #1a73e8 100%); }
.auth-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-logo { text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--dark); margin-bottom: 8px; }
.auth-logo span { color: var(--primary); }
.auth-sub { text-align: center; color: #64748b; font-size: .9rem; margin-bottom: 28px; }
.auth-footer { text-align: center; font-size: .85rem; margin-top: 20px; color: #64748b; }
.auth-footer a { color: var(--primary); text-decoration: none; }

/* Templates grid */
.templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.template-card {
  border: 3px solid transparent; border-radius: 12px; overflow: hidden;
  cursor: pointer; transition: all .2s; position: relative;
}
.template-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.template-card.selected { border-color: var(--primary); }
.template-preview {
  height: 140px; display: flex; flex-direction: column;
  justify-content: space-between; padding: 12px;
}
.template-preview .bar { height: 8px; border-radius: 4px; opacity: .8; }
.template-preview .line { height: 5px; border-radius: 3px; opacity: .5; margin-top: 6px; }
.template-name { padding: 10px 12px; background: #fff; font-size: .82rem; font-weight: 600; text-align: center; border-top: 1px solid var(--border); }
.template-card .check {
  position: absolute; top: 8px; right: 8px;
  background: var(--primary); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: none; align-items: center;
  justify-content: center; font-size: .8rem;
}
.template-card.selected .check { display: flex; }

/* Page Builder */
.builder-wrap { display: flex; height: calc(100vh - 64px); overflow: hidden; }
.builder-sidebar {
  width: 280px; background: #fff; border-right: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0;
}
.builder-sidebar h3 { padding: 16px; font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; border-bottom: 1px solid var(--border); }
.block-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; transition: background .15s;
  border-bottom: 1px solid #f1f5f9; font-size: .88rem;
}
.block-item:hover { background: #f0f4ff; color: var(--primary); }
.block-item svg { width: 18px; height: 18px; color: #94a3b8; flex-shrink: 0; }
.block-item:hover svg { color: var(--primary); }

.builder-canvas {
  flex: 1; background: #f0f4f8; overflow-y: auto; padding: 20px;
}
.canvas-inner {
  max-width: 900px; margin: 0 auto; background: #fff;
  border-radius: 8px; min-height: 600px; box-shadow: var(--shadow);
  overflow: hidden;
}
.section-block {
  position: relative; border: 2px dashed transparent;
  transition: border .15s;
}
.section-block:hover { border-color: var(--primary); }
.section-controls {
  position: absolute; top: 8px; right: 8px;
  display: none; gap: 4px; z-index: 10;
}
.section-block:hover .section-controls { display: flex; }
.ctrl-btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .8rem;
}
.ctrl-btn.danger { background: #ef4444; }
.ctrl-btn.move { background: #64748b; cursor: grab; }

.builder-props {
  width: 280px; background: #fff; border-left: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0; padding: 16px;
}
.builder-props h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: #64748b; margin-bottom: 16px; }
.prop-group { margin-bottom: 16px; }
.prop-group label { font-size: .8rem; color: #64748b; display: block; margin-bottom: 4px; }
.prop-input {
  width: 100%; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: .85rem;
}
.prop-input:focus { outline: none; border-color: var(--primary); }

/* Builder topbar */
.builder-topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--dark); color: #fff; padding: 12px 20px; gap: 12px;
}
.builder-topbar a { color: rgba(255,255,255,.7); text-decoration: none; font-size: .85rem; }
.builder-topbar a:hover { color: #fff; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .builder-props { display: none; }
}
