:root{
  --bg: #C0C0C0;
  --panel: #E0E0E0;
  --paper: #FFFFFF;
  --ink: #000000;
  --shadow: #7A7A7A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
}

table {
  border-collapse: collapse;
  background-color: var(--paper);
  width: 100%;
}

td, th {
  border: 2px solid var(--ink);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.container {
  width: min(760px, 100%);
  margin: 12px auto;
  border: 4px double var(--ink);
  background-color: var(--panel);
  padding: 12px;
  box-shadow: 6px 6px 0 var(--shadow);
}

.topbar{
  display: block;
  text-align: center;
}

h1 {
  margin: 6px 0 12px;
  text-align: center;
  font-size: 28px;
  text-decoration: underline;
  letter-spacing: 1px;
}

.home-link {
  cursor: pointer;
}
.home-link:hover {
  transform: translate(1px, 1px);
  text-shadow: 1px 1px 0 var(--shadow);
}

h3 { margin: 10px 0; }

.menu {
  margin-bottom: 10px;
  text-align: center;
}

button {
  font-size: 15px;
  padding: 10px 12px;
  margin: 6px;
  cursor: pointer;
  border: 2px solid var(--ink);
  background: #F2F2F2;
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  touch-action: manipulation;
}
button:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 10px 0;
}

.icon {
  border: 2px solid var(--ink);
  background-color: var(--paper);
  padding: 12px 10px;
  cursor: pointer;
  font-weight: bold;
  user-select: none;
  text-align: center;
  line-height: 1.2;
  box-shadow: 2px 2px 0 var(--ink);
  touch-action: manipulation;
}
.icon:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}

.hidden { display: none; }

input {
  width: 96px;
  padding: 8px 6px;
  font-size: 16px; /* prevents iOS zoom */
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
}

.nav-buttons {
  margin-top: 12px;
  text-align: center;
}

/* Log table is scrollable on tiny screens */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
}
.table-wrap table {
  border: none;
  background: transparent;
  width: 100%;
  min-width: 560px; /* room for UNITS col */
}
.table-wrap td, .table-wrap th { border: 2px solid var(--ink); }

/* Entry tables should NOT scroll horizontally */
.table-wrap-tight {
  width: 100%;
  overflow-x: hidden;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
}
.table-wrap-tight table {
  width: 100%;
  border: none;
  background: transparent;
  table-layout: fixed;
}
.table-wrap-tight th, .table-wrap-tight td {
  white-space: normal;
  padding: 6px 6px;
}

/* Entry-table column sizing */
.entryTable col.col1 { width: 22%; }
.entryTable col.col2 { width: 39%; }
.entryTable col.col3 { width: 39%; }

.entryTable input {
  width: 100%;
  max-width: 120px;
}

.hint { margin: 6px 0 10px; }

/* Variant selector */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.variant-btn {
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 12px 10px;
  cursor: pointer;
  font-weight: bold;
  text-align: center;
  box-shadow: 2px 2px 0 var(--ink);
  user-select: none;
}
.variant-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}
.variant-btn.selected {
  background: #D9D9D9;
  box-shadow: inset 2px 2px 0 var(--shadow);
}



/* Mobile */
@media (max-width: 640px) {
  .container {
    margin: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }
  .topbar{
    flex-direction: column;
    align-items: stretch;
  }

  h1 { font-size: 22px; }

  .icon-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  button { width: calc(50% - 16px); margin: 6px 8px; }
  .menu button { width: calc(50% - 16px); }

  .entryTable col.col1 { width: 20%; }
  .entryTable col.col2 { width: 40%; }
  .entryTable col.col3 { width: 40%; }

  .table-wrap-tight th, .table-wrap-tight td {
    padding: 6px 4px;
    font-size: 14px;
  }

  .entryTable input {
    max-width: none;
    padding: 6px 4px;
    font-size: 16px;
  }

  .variant-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  button, .menu button { width: calc(100% - 16px); }

  .entryTable col.col1 { width: 18%; }
  .entryTable col.col2 { width: 41%; }
  .entryTable col.col3 { width: 41%; }
  .table-wrap-tight th, .table-wrap-tight td { font-size: 13px; }

  .variant-grid { grid-template-columns: 1fr; }
}

.unit-inline {
  margin: 6px 0 10px;
  font-weight: bold;
}
.unit-inline label {
  margin-left: 10px;
  cursor: pointer;
}

.unit-inline input {
  width: auto;
  margin-right: 6px;
  vertical-align: middle;
}
