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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  line-height: 1.5;
}

/* Keep the overall app shell fixed; scrolling happens in panels. */
.app-body {
  overflow: hidden;
}

/* Login page */
.container {
  max-width: 700px;
  margin: 2rem auto;
  padding: 0 1rem;
}

h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #25d366;
}

.login-card {
  max-width: 400px;
  margin: 2rem auto;
}

/* App layout */
.app-layout {
  display: flex;
  height: 100vh;
  min-height: 0;
}

.sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h1 {
  font-size: 1.2rem;
  color: #25d366;
  margin: 0;
  text-align: left;
}

.nav-links {
  list-style: none;
  padding: 0.5rem 0;
  flex: 1;
}

.nav-links a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-links a.active {
  border-left: 3px solid #25d366;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sidebar-footer span {
  color: rgba(255,255,255,0.6);
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  max-width: 900px;
  min-height: 0;
}

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.page-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
}

/* Card */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.clickable {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s;
  cursor: pointer;
}

.clickable:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.hint {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.75rem;
  font-weight: normal;
}

/* Badge */
.badge {
  background: #25d366;
  color: #fff;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 10px;
  font-weight: normal;
  display: inline-block;
}

.badge-draft { background: #95a5a6; }
.badge-sending { background: #f39c12; }
.badge-sent { background: #25d366; }
.badge-pending { background: #95a5a6; }
.badge-error { background: #e74c3c; }

.badge-reply-none { background: #95a5a6; }
.badge-reply-ano { background: #25d366; }
.badge-reply-ne { background: #e74c3c; }
.badge-reply-other { background: #f39c12; }

/* Tags */
.tag {
  background: #e8f5e9;
  color: #2e7d32;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin: 1px;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #25d366;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.form-row input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.form-row input:focus {
  outline: none;
  border-color: #25d366;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Dropzone */
.dropzone {
  border: 2px dashed #ccc;
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: #25d366;
}

.dropzone p {
  color: #888;
}

/* Column mapping */
.mapping-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mapping-row label {
  min-width: 70px;
  font-weight: 600;
  font-size: 0.9rem;
}

.mapping-row select {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}

.mapping-row select:focus {
  outline: none;
  border-color: #25d366;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  font-weight: 600;
  background: #fafafa;
}

/* Compose */
textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0.75rem;
}

textarea:focus {
  outline: none;
  border-color: #25d366;
}

/* Buttons */
.btn {
  background: #25d366;
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  font-family: inherit;
}

.btn:hover { background: #1fb855; }
.btn:disabled { background: #ccc; cursor: not-allowed; }

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-secondary {
  background: #6c757d;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-danger {
  background: #e74c3c;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-link {
  background: none;
  border: none;
  color: #25d366;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  font-family: inherit;
}

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

.btn-link-danger {
  color: #e74c3c;
}

/* Search */
.search-bar {
  margin-bottom: 1rem;
}

.search-bar input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.search-bar input:focus {
  outline: none;
  border-color: #25d366;
}

/* Bulk actions bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff3cd;
}

.bulk-bar select {
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}

.stat-card:hover {
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
}

.stat-card.active {
  border-color: #333;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

.stat-confirmed .stat-number { color: #25d366; }
.stat-declined .stat-number { color: #e74c3c; }
.stat-waiting .stat-number { color: #95a5a6; }
.stat-other .stat-number { color: #f39c12; }

/* Campaign */
.campaign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.campaign-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
  color: #666;
}

.meta-text {
  color: #999;
}

.campaign-stats-mini {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.stat-ok { color: #25d366; }
.stat-err { color: #e74c3c; }
.stat-wait { color: #95a5a6; }

.campaign-info p {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

.campaign-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Segment card */
.segment-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.segment-actions {
  display: flex;
  gap: 0.5rem;
}

/* Reclassify select */
.reclassify-select {
  padding: 0.25rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* Progress */
.progress-bar {
  background: #eee;
  border-radius: 6px;
  height: 12px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  background: #25d366;
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

.progress-text {
  text-align: center;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.75rem;
}

.log {
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.log-item {
  padding: 0.3rem 0;
  border-bottom: 1px solid #f5f5f5;
}

.log-item.ok { color: #25d366; }
.log-item.error { color: #e74c3c; }

.error {
  color: #e74c3c;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.success {
  color: #25d366;
  font-size: 0.9rem;
}

.empty {
  text-align: center;
  color: #999;
  padding: 2rem;
}

/* Responsive */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    height: auto;
    overflow-y: hidden;
  }

  .sidebar-header {
    border-bottom: none;
    border-right: 1px solid rgba(255,255,255,0.1);
    padding: 0.75rem 1rem;
  }

  .nav-links {
    display: flex;
    padding: 0;
    overflow-x: auto;
  }

  .nav-links a {
    padding: 0.75rem 1rem;
    white-space: nowrap;
  }

  .nav-links a.active {
    border-left: none;
    border-bottom: 3px solid #25d366;
  }

  .sidebar-footer {
    border-top: none;
    border-left: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem;
  }

  .main-content {
    padding: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
