/* All colors are defined here. Change --accent to the company brand color. */
:root {
  --accent: #1f3a5f;
  --accent-text: #ffffff;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --text: #222222;
  --text-muted: #5a5a5a;
  --border: #d0d0d0;
  --stripe: #f7f8fa;
  --hover: #eaeef3;
  --error: #8b1a1a;
  --success: #1e5c2a;
  --test-bar: #f2d024;
  --test-bar-text: #222222;
  --badge-nomanifest: #ffffff;
  --badge-manifest: #6b6b6b;
  --badge-discharged: #4d6a6f;
  --badge-carryin: #2b5f9e;
  --badge-carryinend: #1d4270;
  --badge-getout: #b26a00;
  --badge-border: #2e6b3a;
  --badge-text: #ffffff;
  --disabled-bg: #eeeeee;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

[hidden] {
  display: none !important;
}

h1 {
  font-size: 20px;
  margin: 0 0 12px 0;
}

h2 {
  font-size: 16px;
  margin: 20px 0 8px 0;
}

a {
  color: var(--accent);
}

.testbar {
  background: var(--test-bar);
  color: var(--test-bar-text);
  text-align: center;
  font-weight: 600;
  padding: 4px 8px;
}

.header {
  background: var(--accent);
  color: var(--accent-text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 20px;
  padding: 8px 16px;
}

.header .brand {
  font-weight: 600;
  font-size: 16px;
}

.header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  flex: 1;
}

.header a,
.header button.link {
  color: var(--accent-text);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 2px 0;
  font: inherit;
  cursor: pointer;
}

.header a.current,
.header button.link.current {
  text-decoration: underline;
  font-weight: 600;
}

.header a:hover,
.header button.link:hover {
  text-decoration: underline;
}

.header .userbox {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  font-size: 14px;
  margin-left: auto;
}

.loading {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 16px;
  font-size: 14px;
}

.main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 12px;
  margin-bottom: 12px;
}

.signin {
  max-width: 420px;
  margin: 40px auto;
  text-align: center;
}

.signin .system {
  color: var(--text-muted);
  margin: 0 0 20px 0;
}

.signin .gbtn {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.msg {
  margin: 0 0 12px 0;
}

.msg.error,
.field-msg.error {
  color: var(--error);
}

.msg.success,
.field-msg.success {
  color: var(--success);
}

.field-msg {
  font-size: 14px;
  min-height: 18px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

/* Forms */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

input[type="text"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 8px;
  min-height: 34px;
}

textarea {
  min-height: 140px;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--disabled-bg);
  color: var(--text-muted);
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px 12px;
  align-items: end;
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  min-height: 34px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 12px;
  min-height: 34px;
  cursor: pointer;
}

button:hover {
  background: var(--hover);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.primary:hover {
  background: var(--accent);
  text-decoration: underline;
}

button.danger {
  color: var(--error);
  border-color: var(--error);
}

button.small {
  padding: 2px 8px;
  min-height: 26px;
  font-size: 13px;
}

button:disabled {
  background: var(--disabled-bg);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: default;
  text-decoration: none;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th,
table.data td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th {
  background: var(--stripe);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--text-muted);
}

table.data tbody tr:nth-child(even) {
  background: var(--stripe);
}

table.data tbody tr.clickable {
  cursor: pointer;
}

table.data tbody tr.clickable:hover {
  background: var(--hover);
}

table.data td.wrap {
  word-break: break-word;
  max-width: 320px;
}

.copy-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 10px 0;
  font-size: 14px;
}

/* Status */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--badge-text);
  white-space: nowrap;
}

.badge.s-0 {
  background: var(--badge-nomanifest);
  color: var(--text);
  border: 1px solid var(--text-muted);
}

.badge.s-1 { background: var(--badge-manifest); }
.badge.s-2 { background: var(--badge-discharged); }
.badge.s-3 { background: var(--badge-carryin); }
.badge.s-4 { background: var(--badge-carryinend); }
.badge.s-5 { background: var(--badge-getout); }
.badge.s-6 { background: var(--badge-border); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
}

.tag.deleted {
  color: var(--error);
  border-color: var(--error);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.title-row h1 {
  margin: 0;
}

.tracker {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.tracker li {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  background: var(--surface);
}

.tracker li.done {
  border-left-color: var(--badge-border);
}

.tracker li .stage-name {
  font-weight: 600;
}

.tracker li .stage-info {
  font-size: 14px;
  color: var(--text-muted);
  margin: 2px 0 4px 0;
}

.inline-form {
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--stripe);
  padding: 10px;
  margin-top: 10px;
  max-width: 520px;
}

.inline-form .row {
  margin-bottom: 8px;
}

/* Phones: tables become stacked cards. */
@media (max-width: 700px) {
  .main {
    padding: 10px;
  }

  .header {
    padding: 8px 10px;
  }

  .header .userbox {
    margin-left: 0;
  }

  .table-wrap {
    border: 0;
    background: none;
    overflow-x: visible;
  }

  table.data thead {
    display: none;
  }

  table.data,
  table.data tbody,
  table.data tr,
  table.data td {
    display: block;
    width: 100%;
  }

  table.data tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    margin-bottom: 8px;
    padding: 4px 0;
  }

  table.data tbody tr:nth-child(even) {
    background: var(--surface);
  }

  table.data td {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    border-bottom: 0;
    padding: 3px 10px;
    text-align: right;
    max-width: none;
  }

  table.data td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    flex: 0 0 40%;
  }

  table.data td.wrap {
    max-width: none;
  }
}
