:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: #ecfdf5;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* Header */
.header {
  background: linear-gradient(135deg, #064e3b, #065f46);
  color: #ffffff;
  padding: 18px 0;
  box-shadow: 0 2px 10px rgba(6, 78, 59, 0.2);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand p {
  font-size: 13px;
  color: #a7f3d0;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.header .btn-outline {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.25);
}

.header .btn-outline:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 20px;
  padding-top: 22px;
  padding-bottom: 32px;
  flex: 1;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 17px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.char-count {
  font-size: 12px;
  color: var(--muted);
  background: #f1f5f9;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

input[type="text"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.14);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

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

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: #f8fafc;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text);
}

.btn-danger-outline {
  background: #ffffff;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger-outline:hover {
  background: #fef2f2;
}

.file-btn {
  cursor: pointer;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
}

.draft-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Templates */
.templates-box {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 14px;
}

.subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.subhead h3 {
  font-size: 14px;
  font-weight: 700;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.tpl-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
}

.tpl-title {
  font-weight: 600;
  cursor: pointer;
  color: var(--primary-hover);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-title:hover {
  text-decoration: underline;
}

.guide-box {
  background: var(--primary-soft);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  color: #065f46;
}

.guide-box ol {
  margin-top: 6px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Stats & Progress */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  min-width: 100px;
  flex: 1;
}

.stat-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
}

.stat-val {
  font-size: 20px;
  font-weight: 700;
}

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

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

.progress-wrap {
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.25s ease;
}

/* Filter Bar */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 165px 165px;
  gap: 10px;
  margin-bottom: 14px;
}

/* Link Cards */
.link-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s ease;
}

.link-card:hover {
  border-color: #94a3b8;
}

.link-card.done {
  background: #f8fafc;
  border-color: #a7f3d0;
}

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

.link-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.link-name {
  font-weight: 700;
  font-size: 15px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-cat {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-done {
  background: #dcfce7;
  color: #166534;
}

.badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.link-url {
  font-size: 12.5px;
  color: var(--primary-hover);
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.link-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.link-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-box {
  position: relative;
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #0f172a;
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  z-index: 200;
}

.footer {
  border-top: 1px solid var(--border);
  background: #ffffff;
  padding: 14px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    grid-template-columns: 1fr;
  }
  .link-card {
    flex-direction: column;
    align-items: stretch;
  }
  .link-actions {
    justify-content: flex-start;
  }
}
