* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: #F7F5F1;
  color: #2B2620;
}

a { color: #8C6A2E; }

nav {
  background: #2B2620;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}
nav a {
  color: #E6DFD3;
  text-decoration: none;
  font-size: 14px;
}
nav a.brand {
  color: #fff;
  font-weight: bold;
  margin-right: 12px;
}
nav a:hover { color: #fff; }
nav .spacer { flex: 1; }

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

h1 { font-size: 22px; margin: 0 0 20px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 6px;
  overflow: hidden;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #EFEBE3;
  font-size: 14px;
}
th { background: #F0EBE1; font-weight: 600; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.badge-active { background: #DEE3D2; color: #3F4A33; }
.badge-paused { background: #EFE1CF; color: #6B4E1F; }
.badge-failed { background: #F3D9D3; color: #7A2E1E; }

form.inline { display: inline; }

button, .btn {
  background: #A8752E;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
}
button.secondary, a.secondary { background: #6B5B4B; }

.card {
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.login-wrap {
  max-width: 340px;
  margin: 120px auto;
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 8px;
  padding: 32px;
}
.login-wrap input {
  width: 100%;
  padding: 8px 10px;
  margin: 6px 0 16px;
  border: 1px solid #CFC7BA;
  border-radius: 4px;
  font-size: 14px;
}
.login-wrap label { font-size: 13px; color: #6B5B4B; }
.error { color: #A32D2D; font-size: 13px; margin-bottom: 12px; }
.muted { color: #6B5B4B; font-size: 13px; }

/* ===== app shell ===== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.app-header .brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-header .mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #A8752E;
  color: #A8752E;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.app-header h1 { margin: 0; font-size: 22px; }
.app-header .greeting { margin: 2px 0 0; font-size: 13px; color: #6B5B4B; }

/* ===== stat row ===== */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat {
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 10px;
  padding: 16px 18px;
}
.stat .num { font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat .label { font-size: 12px; color: #6B5B4B; margin-top: 4px; }

/* ===== quick action tiles ===== */

.section-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8C6A2E;
  margin: 0 0 12px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.tile {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 10px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #2B2620;
}
.tile:hover { border-color: #A8752E; }
.tile .icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #EFE1CF;
  color: #8C6A2E;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.tile .tile-sub {
  display: block;
  font-weight: 400;
  font-size: 12px;
  color: #6B5B4B;
  margin-top: 3px;
}

/* ===== template thumbnail cards ===== */

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.template-card {
  background: #fff;
  border: 1px solid #E2DDD4;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.thumb-frame {
  height: 160px;
  overflow: hidden;
  position: relative;
  background: #F0EBE1;
  border-bottom: 1px solid #E2DDD4;
}
.thumb-frame iframe {
  width: 400%;
  height: 400%;
  border: none;
  transform: scale(0.25);
  transform-origin: top left;
  pointer-events: none;
}
.template-card .body { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.template-card .name { font-weight: 600; font-size: 14px; }
.template-card .meta-line { font-size: 12px; color: #6B5B4B; }
.template-card .actions { display: flex; gap: 8px; margin-top: 8px; }
.template-card .actions .btn, .template-card .actions button { flex: 1; text-align: center; font-size: 12px; padding: 7px 10px; }

/* ===== quick-add composer ===== */

.composer { display: flex; flex-direction: column; gap: 10px; }
.composer .row { display: flex; gap: 10px; flex-wrap: wrap; }
.composer input, .composer select {
  padding: 8px 10px;
  border: 1px solid #CFC7BA;
  border-radius: 4px;
  font-size: 13px;
  flex: 1;
  min-width: 160px;
}
.composer label { font-size: 12px; color: #6B5B4B; display: block; margin-bottom: 3px; }
.composer .field { flex: 1; min-width: 160px; }

/* ===== toast ===== */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2B2620;
  color: #fff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
