:root{
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;

  --btn: #2563eb;
  --btn-hover: #1e4fd1;

  --btn2: #f3f4f6;
  --btn2-hover: #e5e7eb;

  --danger: #dc2626;
  --danger-bg: #fee2e2;

  /* pastel alternation */
  --row-alt: #fffbea; /* soft warm */
}

*{ box-sizing: border-box; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container{
  margin: 0 auto;
  padding: 90px 14px 40px; /* navbar spacing */
  max-width: 1100px;
}

.container.wide{
  max-width: 1600px;
  width: min(1600px, 98vw);
}

.header h1{
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 2.6vw, 2.2rem);
}

.subtitle{
  margin: 0 0 10px;
  color: var(--muted);
}

.disclaimer{
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffbea;
  color: #92400e;
}

.card{
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(0,0,0,0.04);
}

.card-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.header-actions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label{
  display:block;
  font-size: .95rem;
  color: var(--muted);
}

input, select, textarea{
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus{
  border-color: var(--btn);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

textarea{ resize: vertical; }
.span-2{ grid-column: 1 / -1; }

.actions{
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--btn2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.05s ease;
}

button:hover{ background: var(--btn2-hover); }
button:active{ transform: scale(0.98); }

button.primary{
  background: var(--btn);
  border-color: var(--btn);
  color: #ffffff;
  font-weight: 700;
}
button.primary:hover{ background: var(--btn-hover); }

button.danger{
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger);
}
button.danger:hover{ background: #fecaca; }

button.ghost{
  background: transparent;
}
button.ghost:hover{ background: #f9fafb; }

.table-wrap{
  overflow: hidden;     /* desktop: no horizontal scroll */
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 12px;
}

table{
  width: 100%;
  border-collapse: separate; /* enables row borders cleanly */
  border-spacing: 0;
  table-layout: fixed;
}

/* HEADER */
thead th{
  text-align: left;
  font-size: .9rem;
  color: var(--muted);
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

/* CELL STYLING */
th, td{
  padding: 10px 10px;
  vertical-align: top;
  word-break: break-word;
}

/* Row borders + alternating pastel backgrounds */
tbody tr{
  border: 1px solid var(--border);
}

tbody tr td{
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

tbody tr td:first-child{
  border-left: 1px solid var(--border);
}

tbody tr:nth-child(even){
  background: var(--row-alt);
}

/* Totals row */
tfoot td{
  font-weight: 800;
  background: #f3f4f6;
  border-top: 1px solid var(--border);
}

.totals-label{
  text-align: right;
  color: var(--muted);
}

/* Inline inputs inside table */
.qty-input{
  width: 80px;
  padding: 6px 8px;
  border-radius: 8px;
}

.taken-cell{
  text-align: center;
}
.taken-cell input[type="checkbox"]{
  transform: scale(1.15);
}

/* Actions */
.row-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Archive inline fields */
.archive-inline{
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
}

/* Column sizing */
.med-table .col-taken{ width: 6%; }
.med-table .col-rx{ width: 15%; }
.med-table .col-common{ width: 14%; }
.med-table .col-dosage{ width: 9%; }
.med-table .col-issuedby{ width: 11%; }
.med-table .col-issueddate{ width: 8%; }

.med-table .col-time{ width: 7%; }
.med-table .col-total{ width: 8%; }
.med-table .col-actions{ width: 10%; }

.med-table .col-archived{ width: 8%; }
.med-table .col-removedby{ width: 10%; }
.med-table .col-notes{ width: 16%; }

.footer-actions{
  display:flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.footer{
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Mobile: allow horizontal scroll */
@media (max-width: 900px){
  .table-wrap{ overflow: auto; }
  table{ min-width: 1100px; table-layout: auto; }
}

@media (max-width: 760px){
  .grid{ grid-template-columns: 1fr; }
  .span-2{ grid-column: auto; }
}