:root {
  --primary: #41b6e6;
  --accent: #def3fa;
  --danger: #ff8282;
  --bg: #f6fbfc;
  --text: #224051;
  --radius: 12px;
}

html, body {
  padding: 0;
  margin: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

header {
  background: var(--primary);
  color: white;
  padding: 1rem;
  text-align: center;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Flex row for header title and sidebar button */
.header-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.7rem;
}
.header-row h1 {
  flex: 1;
  margin: 0 auto;
  text-align: center;
  font-size: 1.5em;
}

main {
  max-width: 520px;
  margin: 1rem auto 2rem auto;
  padding: 0 1rem;
}

/* Floating Action Button Styles */
.fab {
  position: fixed;
  bottom: 2.8rem;
  right: 2.5rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 24px #0002;
  font-size: 2rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
  transition: background 0.13s, box-shadow 0.13s;
}
.fab:hover, .fab:focus {
  background: #2ba8de;
  box-shadow: 0 0 0 5px #def3fa81;
}
@media (max-width: 500px) {
  .fab {
    bottom: 1.2rem;
    right: 1.1rem;
    width: 49px;
    height: 49px;
    font-size: 1.5rem;
  }
}

.selected-list-title {
  text-align: center;
  font-size: 1.16rem;
  font-weight: 500;
  margin: 0.8rem 0 0.2rem 0;
  color: var(--primary);
  letter-spacing: 1px;
}

#inventory-list {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.inventory-card {
  background: white;
  box-shadow: 0 2px 8px #def3fa72;
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-areas:
    "daysleft name edit"
    "img qty delete"
    "img date ."
    "img deadline ."
    "img code ."
    "img location ."
    "img tags .";
  grid-template-columns: 80px 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  position: relative;
}

.inventory-photo {
  grid-area: img;
  object-fit: cover;
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
}

.item-name {
  grid-area: name;
  font-weight: 600;
  font-size: 1.1rem;
}

.item-qty {
  grid-area: qty;
  color: var(--primary);
  font-size: 1rem;
}

.item-date {
  grid-area: date;
  font-size: 0.93rem;
  color: #69889b;
}

.item-daysleft {
  grid-area: daysleft;
  font-size: 0.6rem;
  font-weight: 600;
  color: white;
  background-color: green;
  padding: 0.2rem;
  text-align: center;
}
.item-daysleft.timeleft-zero {
  background-color: blue;
}
.item-daysleft.timeleft-overdue {
  background-color: red;
}

.item-deadline {
  grid-area: deadline;
  font-size: 0.93rem;
  color: var(--danger);
}

.item-code {
  grid-area: code;
  font-size: 0.9rem;
  color: #4e81a7;
  font-family: monospace;
  letter-spacing: 2px;
}

.edit-btn, .delete-btn {
  grid-area: unset;
  margin-right: 0;
  margin-left: 6px;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 1.07rem;
  vertical-align: middle;
}

.edit-btn {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.delete-btn {
  grid-column: 3;
  grid-row: 2;
  color: var(--danger);
  justify-self: end;
}

#modal-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(68, 117, 153, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.2s;
}

.modal-hide {
  display: none !important;
}

#item-form {
  background: white;
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  max-width: 380px;
  min-width: 240px;
  width: 100%;
  box-shadow: 0 4px 40px #0001;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#item-form h2 {
  text-align: center;
}

#item-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.99rem;
}

#item-form input, #item-form textarea {
  margin-top: 4px;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  border: 1px solid #c9e9f2;
  font-size: 1rem;
  background: var(--accent);
}

#item-form button {
  margin-top: 1rem;
  padding: 0.6rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--primary);
  color: white;
  cursor: pointer;
}

.item-location {
  grid-column: 1 / span 3; /* display below other fields */
  font-size: 0.96rem;
  margin-top: 0.1rem;
  color: #377f88;
}

.item-tags {
  grid-column: 1 / span 3;
  font-size: 0.94rem;
  color: #80a7bc;
  margin-bottom: 0.1rem;
}

#item-form input[name="location"], #item-form input[name="tags"] {
  margin-bottom: 0.05rem;
}

#cancel-btn {
  background: var(--accent);
  color: var(--primary);
  margin-top: 0;
}

#overview-modal-container {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(68, 117, 153, 0.22);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

#overview-modal-container.modal-hide {
  display: none !important;
}

.overview-modal {
  background: white;
  padding: 2.2rem 1.6rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 80px #0002;
  width: 95vw;
  max-width: 440px;
  text-align: center;
  position: relative;
}

.overview-modal .big-code {
  font-size: 3rem;
  font-family: 'Segoe UI', 'Roboto Mono', monospace;
  letter-spacing: 10px;
  color: var(--primary);
  background: var(--accent);
  padding: 0.6rem 1.7rem;
  border-radius: 22px;
  margin: 1.3rem auto 1.5rem auto;
  display: inline-block;
  box-shadow: 0 0 0 2px var(--accent);
}

.overview-modal img {
  margin: 0.5rem auto 1.3rem auto;
  width: 94px;
  max-width: 98vw;
  height: 94px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  background: var(--accent);
  display: block;
}

.overview-modal h2 {
  font-size: 1.28rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.overview-modal .row {
  margin-bottom: 0.3rem;
  font-size: 1.05rem;
}

.overview-modal .modal-close-btn {
  position: absolute;
  top: 0.85rem;
  right: 1.15rem;
  background: none;
  border: none;
  color: #69889b;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 500px) {
  .overview-modal {
    padding: 1.4rem 0.5rem;
    max-width: 99vw;
  }
  .overview-modal .big-code {
    font-size: 2.2rem;
    padding: 0.5rem 0.3rem;
  }
}

.lang-btn {
  background: var(--accent);
  color: var(--primary);
  border: none;
  border-radius: var(--radius);
  margin-left: 0.85em;
  padding: 0.5rem 0.9rem;
  font-size: 0.6rem;
  cursor: pointer;
}
.lang-btn:hover {
  background: var(--primary);
  color: white;
}

.filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}

.filter-btn {
  background: var(--accent);
  color: var(--primary);
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 1rem;
  font-size: 0.98rem;
  cursor: pointer;
  transition: background 0.14s;
  font-weight: 500;
  margin-right: 0.1rem;
}

.filter-btn.selected,
.filter-btn:active {
  background: var(--primary);
  color: #fff;
}

.filter-btn:hover {
  background: #68c7f6;
  color: white;
}

/* Sidebar layout for desktop/mobile */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
  background: var(--accent);
  padding: 1rem 0.6rem;
  min-width: 180px;
  max-width: 260px;
  margin: 0;
  border-radius: var(--radius);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  box-shadow: 2px 0 14px #0002;
  z-index: 2001;
  transform: translateX(-105%);
  transition: transform 0.2s cubic-bezier(.65,.05,.36,1);
}
.sidebar.sidebar-visible {
  transform: translateX(0);
}
.sidebar.sidebar-collapsed {
  transform: translateX(-105%);
}

.sidebar-toggle-btn {
  background: var(--accent);
  border: none;
  color: var(--primary);
  border-radius: var(--radius);
  font-size: 1.6em;
  padding: 0.22em 0.7em;
  margin-right: 0.5em;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.14s;
}
.sidebar-toggle-btn:hover {
  background: var(--primary);
  color: white;
}

.sidebar-list-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
  background: white;
  border-radius: 8px;
  padding: 0.3em 0.55em;
  transition: background 0.13s;
  cursor: pointer;
}
.sidebar-list-row.selected {
  background: var(--primary);
  color: white;
}
.sidebar-list-row:hover:not(.selected) {
  background: #f3fdff;
}

.sidebar-list-name {
  flex: 1;
  outline: none;
  padding: 0.08em 0;
  font-size: 1.06rem;
  font-weight: 500;
  user-select: text;
}

.sidebar-edit-btn {
  background: none;
  color: var(--primary);
  border: none;
  font-size: 1.09rem;
  margin-left: 7px;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 7px;
  transition: background .13s;
}
.sidebar-edit-btn:hover {
  background: #e6f4fb;
}

.sidebar-list-edit {
  flex: 1;
  font-size: 1rem;
  border-radius: 4px;
  border: 1px solid #b7dcef;
  margin-right: 4px;
  padding: 2px 7px;
}

.sidebar-delete-btn {
  background: none;
  color: var(--danger);
  border: none;
  font-size: 1.17rem;
  margin-left: 7px;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 7px;
  transition: background .13s;
}
.sidebar-delete-btn:hover {
  background: #ffeaea;
}

.sidebar-add-btn {
  margin-top: 0.77em;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1rem;
  border-radius: 7px;
  padding: 0.45em 1em;
  cursor: pointer;
  font-weight: 600;
}

/* Responsive sidebar */
@media (max-width: 650px) {
  .sidebar {
    min-width: 0;
    max-width: 90vw;
    padding: 0.7rem 0.22rem;
  }
}

footer {
  text-align: center;
  color: #7ea1bd;
  font-size: 0.96rem;
  margin-bottom: 1.7rem;
}