/* Modern Admin Design - Unified with qually.pro brand */

:root {
  --bg-primary: #f8fafb;
  --bg-secondary: #ffffff;
  --bg-soft: #f5f8fc;
  --bg-accent-mint: #f0fdf9;
  --bg-accent-blue: #f0f6ff;
  --bg-accent-warm: #fffbf7;
  
  --border-main: #e5e8ec;
  --border-soft: #eef0f4;
  
  --text-primary: #0f1419;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --brand-blue: #1f6bed;
  --brand-blue-light: #e0edff;
  --brand-mint: #10b981;
  --brand-warm: #f97316;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(240, 249, 245, 0.3) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Main container */
.page {
  max-width: 1720px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Header / Navigation */
.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.top-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 1px solid var(--border-main);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.top-nav a:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: var(--brand-blue-light);
}

.top-nav a.active {
  background: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
}

/* Hero section */
.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-soft);
}

.hero > div:first-child h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.hero > div:first-child p {
  font-size: 15px;
  color: var(--text-muted);
}

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

.hero-actions a,
.hero-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 18px;
  border: 1px solid var(--border-main);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hero-actions a:hover,
.hero-actions button:hover {
  border-color: var(--brand-blue);
  background: var(--brand-blue-light);
  color: var(--brand-blue);
}

.hero-actions a.primary,
.hero-actions button.primary {
  background: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
}

.hero-actions a.primary:hover,
.hero-actions button.primary:hover {
  background: #1555c7;
  border-color: #1555c7;
  box-shadow: 0 8px 20px rgba(31, 107, 237, 0.25);
}

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border-main);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stat .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-blue);
}

/* Panels */
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-main);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.panel h2,
.panel h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.panel p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Accordion / Details */
.accordion {
  cursor: pointer;
  user-select: none;
}

.accordion summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  list-style: none;
}

.accordion summary:hover {
  color: var(--brand-blue);
}

.accordion summary::before {
  content: '▶';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.accordion[open] summary::before {
  transform: rotate(90deg);
}

.accordion-body {
  padding: 16px 0 0 32px;
}

/* Grids */
.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.progress-item {
  background: var(--bg-accent-blue);
  border: 1px solid #d4e0f7;
  border-radius: 12px;
  padding: 16px;
  transition: all 0.2s ease;
}

.progress-item:hover {
  border-color: var(--brand-blue);
  box-shadow: 0 4px 12px rgba(31, 107, 237, 0.12);
}

.progress-item strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.progress-item .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--brand-blue);
}

/* Table styles */
.table-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border-main);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table thead {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-main);
}

table th {
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
}

table tbody tr:hover {
  background: var(--bg-accent-blue);
}

table tbody tr:last-child td {
  border-bottom: none;
}

/* Buttons */
button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-main);
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  border-color: var(--brand-blue);
  background: var(--brand-blue-light);
  color: var(--brand-blue);
}

button.primary {
  background: var(--brand-blue);
  color: white;
  border-color: var(--brand-blue);
}

button.primary:hover {
  background: #1555c7;
  box-shadow: 0 4px 12px rgba(31, 107, 237, 0.25);
}

/* Inputs */
input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border-main);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all 0.2s ease;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  background: #fafbff;
  box-shadow: 0 0 0 3px rgba(31, 107, 237, 0.1);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Embedded mode: when opened inside the main app iframe */
body.embedded .top-nav,
body.embedded .sidebar,
body.embedded .topbar .actions {
  display: none !important;
}

body.embedded .layout {
  grid-template-columns: 1fr !important;
}

body.embedded .main {
  max-width: none !important;
  padding: 20px 24px !important;
}

body.embedded .page {
  padding: 18px 16px;
}

body.embedded .app {
  padding: 10px;
}

/* Responsive */
@media (max-width: 768px) {
  .page {
    padding: 20px 16px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hero > div:first-child h1 {
    font-size: 28px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .panel {
    padding: 18px;
  }

  .progress-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
