:root{
  --ink:#0F3B3E;
  --paper:#F2F9F8;
  --paper-alt:#DCEFEC;
  --teal:#1E8A8C;
  --teal-dark:#166669;
  --stamp:#C1440E;
  --line:#BFDEDC;
  --muted:#5C8886;
  --danger:#B23A2E;
}
*{box-sizing:border-box;}
body{
  margin:0;
  min-height:100vh;
  background:var(--ink);
  font-family:Georgia,'Times New Roman',serif;
  color:var(--ink);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}

#login-screen{
  background:var(--paper);
  width:100%;
  max-width:380px;
  padding:40px 36px;
  border-radius:2px;
  box-shadow:0 0 0 1px var(--line);
  text-align:center;
}
.stamp-title{
  font-size:13px;
  letter-spacing:3px;
  text-transform:uppercase;
  color:var(--stamp);
  font-family:'Courier New',monospace;
  margin:0 0 6px;
}
#login-screen h1{
  font-size:26px;
  font-weight:400;
  margin:0 0 28px;
  border-bottom:2px solid var(--ink);
  padding-bottom:16px;
}
input[type=password], input[type=text]{
  width:100%;
  padding:11px 12px;
  font-family:'Courier New',monospace;
  font-size:14px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:2px;
  margin-bottom:14px;
}
input:focus{ outline:2px solid var(--teal); outline-offset:1px; }
button{
  font-family:'Courier New',monospace;
  font-size:13px;
  letter-spacing:1px;
  text-transform:uppercase;
  padding:11px 18px;
  border:1px solid var(--ink);
  background:var(--ink);
  color:var(--paper);
  border-radius:2px;
  cursor:pointer;
}
button:hover{background:var(--teal-dark); border-color:var(--teal-dark);}
button.ghost{ background:transparent; color:var(--ink); }
button.ghost:hover{background:var(--paper-alt);}
#login-error{color:var(--danger); font-size:13px; font-family:'Courier New',monospace; min-height:18px; margin-bottom:4px;}

#app-screen{display:none; width:100%; max-width:960px;}
.sheet-box{ background:var(--paper); box-shadow:0 0 0 1px var(--line); border-radius:2px; }
header.app-header{
  display:flex; align-items:baseline; justify-content:space-between;
  padding:22px 28px; border-bottom:2px solid var(--ink);
}
header.app-header h1{font-size:22px; font-weight:400; margin:0;}
header.app-header .actions{display:flex; gap:10px;}
header.app-header button{padding:8px 14px; font-size:11px;}

.panel{padding:24px 28px;}
.panel + .panel{border-top:1px solid var(--line);}

.upload-row{display:flex; flex-wrap:wrap; gap:12px; align-items:center;}
.upload-row input[type=text]{width:180px; margin:0;}
.upload-row input[type=file]{font-family:'Courier New',monospace; font-size:13px;}
.upload-row button{padding:10px 16px; font-size:12px;}
#upload-status{font-family:'Courier New',monospace; font-size:12px; color:var(--muted); margin-top:10px; min-height:16px;}
.hint{font-family:'Courier New',monospace; font-size:11px; color:var(--muted); margin:8px 0 0;}

.section-label{
  font-family:'Courier New',monospace; font-size:11px; letter-spacing:2px;
  text-transform:uppercase; color:var(--muted); margin:0 0 14px;
}

.history-list{list-style:none; padding:0; margin:0; display:flex; flex-direction:column; gap:6px;}
.history-item{
  display:flex; align-items:center; gap:12px; padding:10px 12px;
  border:1px solid var(--line); border-radius:2px; background:#fff; cursor:pointer; font-size:13px;
}
.history-item:hover{border-color:var(--teal);}
.history-item.active{border-color:var(--teal); background:var(--paper-alt);}
.history-item .date-stamp{
  font-family:'Courier New',monospace; font-size:11px; color:var(--stamp);
  border:1px solid var(--stamp); padding:2px 6px; border-radius:2px; white-space:nowrap;
}
.history-item .fname{flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.history-item .by{color:var(--muted); font-size:12px; font-family:'Courier New',monospace;}
.history-delete{
  background:transparent; border:1px solid var(--danger); color:var(--danger);
  font-size:10px; padding:4px 8px; flex:none;
}
.history-delete:hover{background:var(--danger); color:#fff;}

.tab-bar{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:14px;}
.tab-btn{
  font-family:'Courier New',monospace; font-size:11px; padding:6px 10px;
  border:1px solid var(--line); background:#fff; border-radius:2px; cursor:pointer;
  color:var(--ink); max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.tab-btn:hover{border-color:var(--teal);}
.tab-btn.active{background:var(--teal); border-color:var(--teal); color:#fff;}

.search-row{margin-bottom:12px;}
#search-input{width:100%; max-width:320px; margin:0;}

.color-legend{
  display:flex; flex-wrap:wrap; gap:6px 16px; padding:12px 16px;
  background:var(--paper-alt); border:1px solid var(--line); border-radius:2px; margin-bottom:16px;
}
.color-legend-item{
  display:flex; align-items:center; gap:6px; font-size:11.5px;
  font-family:'Courier New',monospace; white-space:nowrap;
}
.color-legend-swatch{width:13px; height:13px; border-radius:2px; border:1px solid rgba(0,0,0,0.2); flex:none;}

.table-wrap{overflow-x:auto; border:1px solid var(--line); max-height:520px; overflow-y:auto;}
table.data{border-collapse:collapse; width:100%; font-family:'Courier New',monospace; font-size:12.5px;}
table.data th, table.data td{border:1px solid var(--line); padding:6px 10px; text-align:left; white-space:nowrap;}
table.data th{background:var(--paper-alt); font-weight:700; position:sticky; top:0;}
table.data tr:nth-child(even) td{background:#FCFEFD;}
#empty-state{font-size:14px; color:var(--muted); padding:24px 0; text-align:center;}
