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

/* === Base elements === */
body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1 {
  font-size: var(--font-size-title);
  line-height: var(--line-height-heading);
  margin-bottom: var(--space-3);
}

h2 {
  font-size: var(--font-size-heading);
  line-height: var(--line-height-heading);
  margin-bottom: var(--space-2);
}

h3 {
  font-size: var(--font-size-body);
  line-height: var(--line-height-heading);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-2);
}

a {
  color: var(--color-accent);
}

a:hover {
  text-decoration: none;
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-4) 0;
}

ul, ol {
  padding-left: var(--space-4);
  margin-bottom: var(--space-2);
}

/* === Layout === */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3);
}

/* === Super Admin Banner === */
.super-admin-banner {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-2) var(--space-3);
  font-weight: 600;
  text-align: center;
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-text);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  padding: 0;
}

.btn-link:hover {
  text-decoration: none;
}

/* === Flash Messages === */
.flash-messages {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-3);
}

.flash {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  background: var(--color-surface);
}

.flash-error,
.flash-danger {
  color: var(--color-error);
  background: var(--color-surface);
}

.flash-success {
  color: var(--color-success);
  background: var(--color-surface);
}

.flash-warning {
  color: var(--color-warning);
  background: var(--color-surface);
}

/* === Buttons === */
button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  line-height: var(--line-height-body);
  cursor: pointer;
  border: 1px solid var(--color-accent);
  background: var(--color-accent);
  color: var(--color-bg);
  text-decoration: none;
}

button:hover,
.btn:hover {
  opacity: 0.85;
}

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

.btn-secondary:hover {
  background: var(--color-surface);
  opacity: 1;
}

.btn-sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--font-size-body);
}

.btn-danger {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-error);
}

.btn-danger:hover {
  background: var(--color-surface);
  opacity: 1;
}

/* === Inputs === */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
textarea,
select {
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  line-height: var(--line-height-body);
  background: var(--color-bg);
  color: var(--color-text);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
  outline: none;
}

textarea {
  width: 100%;
  resize: vertical;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: var(--space-1);
}

.form-group {
  margin-bottom: var(--space-3);
}

.form-group input,
.form-group textarea {
  width: 100%;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg);
  margin-bottom: var(--space-3);
}

th, td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  text-align: left;
}

th {
  background: var(--color-surface);
  font-weight: 600;
}

tbody tr:nth-child(even) td {
  background: var(--color-surface);
}

/* === Cards === */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

/* === Empty State === */
.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-5) var(--space-3);
}

.empty-state .lucide {
  display: block;
  margin: 0 auto var(--space-3);
  width: var(--space-6);
  height: var(--space-6);
}

.empty-state p {
  margin-bottom: var(--space-3);
}

/* === Top Bar === */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.top-bar a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.top-bar a:hover {
  color: var(--color-text);
}

/* === Page Header === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-3);
}

.page-header h1 {
  margin-bottom: 0;
}

/* === Page Shell === */
.page-shell {
  display: flex;
  flex: 1;
}

.page-shell > main {
  flex: 1;
  min-width: 0;
}

/* === Sidebar === */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-3);
}

.sidebar-header {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.sidebar-group-label {
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-2);
  margin-bottom: var(--space-1);
  font-size: var(--font-size-body);
}

.sidebar-link {
  display: block;
  padding: var(--space-1) var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}

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

.sidebar-link.active {
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-bg);
}

/* === Sidebar Children (expandable modules) === */
.sidebar-parent {
  display: flex;
  align-items: center;
}

.sidebar-parent .sidebar-link {
  flex: 1;
  min-width: 0;
}

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: var(--space-1);
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

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

.sidebar-chevron {
  width: 1em;
  height: 1em;
}

.sidebar-children {
  padding-left: var(--space-3);
}

.sidebar-child-link {
  font-size: var(--font-size-body);
}

/* === Tab Row === */
.tab-row {
  display: flex;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.tab-link {
  display: inline-block;
  padding: var(--space-2) 0;
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-link:hover {
  color: var(--color-text);
}

.tab-link.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
  font-weight: 600;
}

/* === Inline editing === */
.input-inline {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  background: var(--color-bg);
}

.input-inline:focus {
  border-color: var(--color-accent);
  outline: none;
}

.btn-danger-link {
  background: none;
  border: none;
  color: var(--color-error);
  cursor: pointer;
  padding: 0;
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  text-decoration: none;
}

.btn-danger-link:hover {
  opacity: 0.7;
}

.settings-error {
  margin-bottom: var(--space-2);
}

.error-row td {
  border-top: none;
  padding-top: 0;
}

/* === Project Content === */
.project-content {
  padding: var(--space-4);
}

.project-top-bar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.project-top-bar a {
  color: var(--color-text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.project-top-bar a:hover {
  color: var(--color-text);
}

/* === Project Grid === */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.project-card a {
  font-weight: 600;
  text-decoration: none;
  color: var(--color-text);
}

.project-card a:hover {
  text-decoration: underline;
}

/* === Module Grid === */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.module-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.module-card a {
  text-decoration: none;
  font-weight: 600;
  color: var(--color-text);
}

.module-card:hover {
  background: var(--color-surface);
}

/* === Note Card === */
.note-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
}

.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
}

/* === Nav Links === */
.nav-links {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) 0;
  margin-bottom: var(--space-3);
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--color-text);
}

/* === Section === */
.section {
  margin-bottom: var(--space-5);
}

.section h2 {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* === Login === */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: var(--space-6) var(--space-3);
}

.login-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: var(--space-4);
}

/* === Inline form === */
.inline-form {
  display: inline;
}

/* === Actions row === */
.actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

/* === Utility === */
.text-muted {
  color: var(--color-text-muted);
}

.text-error {
  color: var(--color-error);
}

.text-success {
  color: var(--color-success);
}

/* === stepflo-table — sort & filter === */

/* Override default nth-child zebra; JS manages striping via .st-even */
table.stepflo-table tbody tr:nth-child(even) td {
  background: var(--color-bg);
}
table.stepflo-table tbody tr.st-even > td {
  background: var(--color-surface);
}

.st-header {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  user-select: none;
}

.st-label {
  flex: 1;
  min-width: 0;
}

.st-sort-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  color: var(--color-text-muted);
}

.st-icon {
  display: block;
}

.st-filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.st-filter-btn:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.st-filter-btn.st-filter-active {
  color: var(--color-accent);
}

/* Dropdown panel */
.st-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  min-width: 200px;
  max-width: 280px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: normal;
}

.st-dd-sort {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  color: var(--color-text);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-family: var(--font-family);
  font-weight: normal;
}

.st-dd-sort:hover {
  background: var(--color-surface);
  opacity: 1;
}

.st-dd-divider {
  border-top: 1px solid var(--color-border);
  margin: var(--space-1) 0;
}

.st-dd-search {
  width: 100%;
  margin-bottom: var(--space-1);
}

.st-dd-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
}

.st-dd-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-weight: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.st-dd-item:hover {
  background: var(--color-surface);
}

.st-dd-item input[type="checkbox"] {
  flex-shrink: 0;
}

.st-dd-selectall {
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.st-dd-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* === Import preview === */
.import-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-weight: 600;
}

.import-badge {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  font-weight: normal;
}

.import-badge-dup {
  background: #FFF3E0;
  color: var(--color-warning);
}

.import-badge-warn {
  background: #FFF3E0;
  color: var(--color-warning);
}

.import-badge-skip {
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-bg);
  margin-bottom: var(--space-3);
}

.import-preview-table th,
.import-preview-table td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  text-align: left;
}

.import-preview-table th {
  background: var(--color-surface);
  font-weight: 600;
}

.import-row-duplicate td,
.import-row-duplicate_in_file td {
  background: #FFF8E1;
}

.import-row-warning td {
  background: #FFF8E1;
}

.import-row-skip td {
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.import-status {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body);
  white-space: nowrap;
}

.import-status-ok {
  color: var(--color-success);
}

.import-status-dup {
  color: var(--color-warning);
}

.import-status-warn {
  color: var(--color-warning);
}

.import-status-skip {
  color: var(--color-text-muted);
}

.import-actions {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* === Contact expand rows === */
.contact-row {
  cursor: pointer;
}

.contact-row:hover td {
  background: var(--color-surface);
}

.contact-name-cell {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.contact-name-cell .chevron-collapsed,
.contact-name-cell .chevron-expanded {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.contact-detail-cell {
  padding: 0;
  border-top: none;
}

.contact-detail-inner {
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.contact-detail-inner p {
  margin-bottom: var(--space-2);
}

.contact-actions {
  width: 1%;
  white-space: nowrap;
  padding: var(--space-2);
}


/* === Information module === */
.info-section {
  margin-bottom: var(--space-4);
}

.info-fields {
  margin-bottom: var(--space-3);
}

.info-row {
  display: flex;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.info-label {
  width: 130px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--color-text-muted);
}

.info-value {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
}

/* === Lucide icons === */
i[data-lucide] {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

.lucide {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  stroke-width: 1.5;
}
