: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;

  --row-alt: #fffbea;
}

*{ 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;
  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;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 12px;
}

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

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);
}

th, td{
  padding: 10px 10px;
  vertical-align: top;
  word-break: break-word;
}

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);
}

tfoot td{
  font-weight: 800;
  background: #f3f4f6;
  border-top: 1px solid var(--border);
}

.totals-label{
  text-align: right;
  color: var(--muted);
}

.qty-input{
  width: 64px;
  padding: 6px 8px;
  border-radius: 8px;
}

.row-actions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.archive-inline{
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
}

.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;
}

/* Narrower columns where values are just small numbers */
.med-table .col-rx{ width: 15%; }
.med-table .col-common{ width: 14%; }
.med-table .col-dosage{ width: 6%; }
.med-table .col-issuedby{ width: 11%; }
.med-table .col-issueddate{ width: 8%; }

.med-table .col-time{ width: 5%; }
.med-table .col-total{ width: 6%; }

.med-table .col-notes{ width: 18%; }
.med-table .col-actions{ width: 7%; }

.med-table .col-archived{ width: 8%; }
.med-table .col-removedby{ width: 10%; }

@media (max-width: 1100px){
  .table-wrap{
    overflow: auto;
  }

  table{
    min-width: 1150px;
    table-layout: auto;
  }
}

@media (max-width: 760px){
  .grid{
    grid-template-columns: 1fr;
  }

  .span-2{
    grid-column: auto;
  }
}