:root {
  --bg: #f0f4f2;
  --bg-alt: #e6eeea;
  --card: #ffffff;
  --ink: #1f2b27;
  --muted: #5f726b;
  --accent: #0f766e;
  --accent-strong: #0d5f59;
  --accent-soft: #d8f1eb;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fff1dd;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --border: #d3dfda;
  --border-strong: #c0d0c9;
  --shadow: 0 12px 35px rgba(24, 39, 33, 0.08);
  --shadow-soft: 0 8px 24px rgba(24, 39, 33, 0.06);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  line-height: 1.45;
  color: var(--ink);
  background: radial-gradient(circle at top right, #e1f4ee, transparent 42%), var(--bg);
}

h1,
h2 {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.1rem;
  width: 100%;
  margin: 0;
  padding: 1rem 1.25rem;
  border-radius: 0;
  background: linear-gradient(120deg, #d6ede6 0%, #edf5f2 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.layout-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  width: 100%;
  margin: 0;
  padding: 1rem 1.25rem 1.3rem;
}

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

.card-wide {
  overflow: hidden;
  padding: 1rem;
}

.stack-lg {
  display: grid;
  gap: 0.78rem;
}

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

label {
  font-weight: 600;
}

input,
button,
a.btn {
  font: inherit;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"] {
  width: 100%;
  padding: 0.66rem 0.78rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  padding: 0.58rem 0.86rem;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-weight: 600;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.08s ease;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #fca5a5;
}

.btn-small {
  padding: 0.4rem 0.64rem;
  font-size: 0.85rem;
}

.btn-action-main {
  border-color: #bcd3cb;
  background: #f7fbf9;
}

.btn-action-secondary {
  border-color: #d6dde7;
  background: #f8fafc;
  color: #334155;
}

.btn-action-warn {
  border-color: #f3c289;
  background: var(--warn-soft);
  color: #9a3412;
}

.btn-action-danger {
  background: var(--danger-soft);
}

.alert {
  padding: 0.75rem;
  border-radius: 10px;
  margin: 0.8rem 0;
  transition: opacity 0.3s ease;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert.is-hidden {
  opacity: 0;
}

.dropzone {
  border: 2px dashed #8cbfb3;
  border-radius: 12px;
  background: #f6fbf9;
  padding: 1.2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.dropzone p {
  margin: 0;
  color: #3f5e55;
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone.is-over {
  border-color: var(--accent);
  background: #eaf8f3;
}

.table-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
  table-layout: fixed;
}

.submissions-table th:nth-child(1),
.submissions-table td:nth-child(1) {
  width: 9%;
}

.submissions-table th:nth-child(2),
.submissions-table td:nth-child(2) {
  width: 10%;
}

.submissions-table th:nth-child(3),
.submissions-table td:nth-child(3) {
  width: 12%;
}

.submissions-table th:nth-child(4),
.submissions-table td:nth-child(4) {
  width: 9%;
}

.submissions-table th:nth-child(5),
.submissions-table td:nth-child(5) {
  width: 9%;
}

.submissions-table th:nth-child(6),
.submissions-table td:nth-child(6) {
  width: 6%;
}

.submissions-table th:nth-child(7),
.submissions-table td:nth-child(7) {
  width: 7%;
}

.submissions-table th:nth-child(8),
.submissions-table td:nth-child(8) {
  width: 4%;
}

.submissions-table th:nth-child(9),
.submissions-table td:nth-child(9) {
  width: 8%;
}

.submissions-table th:nth-child(10),
.submissions-table td:nth-child(10) {
  width: 14%;
}

.submissions-table th:nth-child(11),
.submissions-table td:nth-child(11) {
  width: 12%;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 0.72rem;
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

th {
  background: #f5faf7;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #4d6660;
}

tbody tr:nth-child(even) {
  background: #fcfefd;
}

tbody tr:hover {
  background: #f3faf7;
}

.copy-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
}

.copy-group input {
  min-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #364a44;
  background: #fbfdfc;
}

.actions-col {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.actions-col form {
  margin: 0;
}

.actions-col .btn {
  min-width: 0;
}

.btn-icon {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 8px;
  position: relative;
}

.btn-icon span {
  font-size: 0.96rem;
  line-height: 1;
}

.btn-icon::after {
  content: attr(data-label);
  position: absolute;
  top: -2.05rem;
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: #1f2b27;
  color: #fff;
  font-size: 0.74rem;
  padding: 0.2rem 0.42rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 5;
}

.btn-icon:hover::after,
.btn-icon:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.badge {
  display: inline-block;
  padding: 0.26rem 0.56rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #86efac;
}

.badge-muted {
  background: #e5e7eb;
  color: #374151;
  border-color: #cbd5e1;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fdba74;
}

.empty-state {
  text-align: center;
  padding: 1.6rem 1rem;
  color: #5b6f69;
  font-weight: 500;
}

.auth-page,
.single-card-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.single-card-page .card {
  width: min(900px, 100%);
}

.viewer-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.viewer-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f0f7f4;
}

.viewer-shell {
  padding: 0;
}

.viewer-shell iframe {
  width: 100%;
  height: 100vh;
  border: 0;
  background: #fff;
}

@media (max-width: 960px) {
  .layout-grid {
    width: calc(100% - 1rem);
    margin-left: auto;
    margin-right: auto;
  }

  .topbar {
    width: 100%;
    margin: 0;
    border-radius: 0;
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }

  .layout-grid {
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0;
    padding: 0.8rem 0.9rem 1rem;
  }
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .topbar form,
  .topbar .btn {
    width: 100%;
  }

  .actions-col {
    flex-direction: column;
    align-items: stretch;
    min-width: 180px;
  }

  .actions-col .btn,
  .actions-col form {
    width: 100%;
  }

  .copy-group {
    grid-template-columns: 1fr;
  }

  .btn-icon {
    width: 2.05rem;
    height: 2.05rem;
  }
}

@media (max-width: 1040px) {
  .submissions-table,
  .submissions-table thead,
  .submissions-table tbody,
  .submissions-table tr,
  .submissions-table th,
  .submissions-table td {
    display: block;
    width: 100%;
  }

  .submissions-table thead {
    display: none;
  }

  .submissions-table tr {
    border-bottom: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    background: #fff;
  }

  .submissions-table tr:last-child {
    border-bottom: 0;
  }

  .submissions-table td {
    border-bottom: 1px dashed var(--border);
    padding: 0.5rem 0.2rem;
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 0.6rem;
    align-items: center;
  }

  .submissions-table td::before {
    content: attr(data-label);
    font-size: 0.76rem;
    font-weight: 700;
    color: #48615a;
    text-transform: uppercase;
    letter-spacing: 0.02em;
  }

  .submissions-table td:last-child {
    border-bottom: 0;
  }

  .submissions-table td.cell-link,
  .submissions-table td.cell-actions {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    align-items: stretch;
  }

  .submissions-table td.cell-link::before,
  .submissions-table td.cell-actions::before {
    margin-bottom: 0.1rem;
  }

  .submissions-table .empty-state {
    display: block;
    text-align: center;
    padding: 1rem 0.2rem;
  }

  .submissions-table .empty-state::before {
    content: none;
  }
}
